pub struct GenerateResult {
pub tokens: Option<TokenUsage>,
pub generation: String,
pub tool_calls: Vec<ToolCall>,
}Expand description
The result of an LLM call.
When the model asks for tools, tool_calls holds them (same type for every provider)
and generation holds the same calls as an OpenAI-style JSON array, so code that
reads generation keeps working. Use GenerateResult::with_tool_calls to build one.
Fields§
§tokens: Option<TokenUsage>§generation: String§tool_calls: Vec<ToolCall>Implementations§
Source§impl GenerateResult
impl GenerateResult
Sourcepub fn with_tool_calls(self, calls: Vec<ToolCall>) -> Self
pub fn with_tool_calls(self, calls: Vec<ToolCall>) -> Self
Sets tool_calls and mirrors them into generation as JSON. Empty calls
leave the result untouched.
pub fn has_tool_calls(&self) -> bool
pub fn to_hashmap(&self) -> HashMap<String, String>
Trait Implementations§
Source§impl Clone for GenerateResult
impl Clone for GenerateResult
Source§impl Debug for GenerateResult
impl Debug for GenerateResult
Source§impl Default for GenerateResult
impl Default for GenerateResult
Source§impl<'de> Deserialize<'de> for GenerateResult
impl<'de> Deserialize<'de> for GenerateResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GenerateResult
impl RefUnwindSafe for GenerateResult
impl Send for GenerateResult
impl Sync for GenerateResult
impl Unpin for GenerateResult
impl UnsafeUnpin for GenerateResult
impl UnwindSafe for GenerateResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more