pub struct GenerateTextResult<O> {
pub steps: Vec<StepResult>,
pub total_usage: Usage,
pub output: O,
}Expand description
Result of a completed generation loop.
Fields§
§steps: Vec<StepResult>All steps in order (at least one).
total_usage: UsageUsage summed over all steps.
output: OThe structured output (() when none was requested).
Implementations§
Source§impl<O> GenerateTextResult<O>
impl<O> GenerateTextResult<O>
Sourcepub fn last_step(&self) -> &StepResult
pub fn last_step(&self) -> &StepResult
The final step.
§Panics
Panics if callers manually construct or mutate a result with no steps. Generation loops always record at least one step before returning a result.
Sourcepub fn reasoning_text(&self) -> Option<String>
pub fn reasoning_text(&self) -> Option<String>
Reasoning text of the final step.
Sourcepub fn finish_reason(&self) -> &FinishReason
pub fn finish_reason(&self) -> &FinishReason
Finish reason of the final step.
Sourcepub fn usage(&self) -> &Usage
pub fn usage(&self) -> &Usage
Token usage summed over every step.
Use last_step().usage for the final model call alone.
Sourcepub fn provider_metadata(&self) -> Option<&ProviderMetadata>
pub fn provider_metadata(&self) -> Option<&ProviderMetadata>
Provider metadata of the final step.
Sourcepub fn content(&self) -> impl Iterator<Item = &StepContent>
pub fn content(&self) -> impl Iterator<Item = &StepContent>
Iterates over content from every step in generation order.
Sourcepub fn files(&self) -> impl Iterator<Item = &GeneratedFile>
pub fn files(&self) -> impl Iterator<Item = &GeneratedFile>
Iterates over files generated in every step.
Sourcepub fn sources(&self) -> impl Iterator<Item = &Source>
pub fn sources(&self) -> impl Iterator<Item = &Source>
Iterates over citation sources from every step.
Sourcepub fn tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
pub fn tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
Iterates over parsed tool calls from every step.
Sourcepub fn static_tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
pub fn static_tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
Iterates over static tool calls from every step.
Sourcepub fn dynamic_tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
pub fn dynamic_tool_calls(&self) -> impl Iterator<Item = &ParsedToolCall>
Iterates over dynamic tool calls from every step.
Sourcepub fn tool_results(&self) -> impl Iterator<Item = &ToolResult>
pub fn tool_results(&self) -> impl Iterator<Item = &ToolResult>
Iterates over final tool results from every step.
Sourcepub fn static_tool_results(&self) -> impl Iterator<Item = &ToolResult>
pub fn static_tool_results(&self) -> impl Iterator<Item = &ToolResult>
Iterates over static tool results from every step.
Sourcepub fn dynamic_tool_results(&self) -> impl Iterator<Item = &ToolResult>
pub fn dynamic_tool_results(&self) -> impl Iterator<Item = &ToolResult>
Iterates over dynamic tool results from every step.
Sourcepub fn final_step(&self) -> &StepResult
pub fn final_step(&self) -> &StepResult
The final step, using the reference SDK’s naming.
Sourcepub fn raw_finish_reason(&self) -> Option<&str>
pub fn raw_finish_reason(&self) -> Option<&str>
The provider’s unnormalized finish reason from the final step.
Sourcepub fn request(&self) -> &StepRequest
pub fn request(&self) -> &StepRequest
Request metadata from the final step.
Sourcepub fn response(&self) -> &StepResponse
pub fn response(&self) -> &StepResponse
Response metadata and messages from the final step.
Sourcepub fn response_messages(&self) -> Vec<Message>
pub fn response_messages(&self) -> Vec<Message>
Messages of all steps, ready to append to the conversation history.
Sourcepub fn map_output<P>(self, f: impl FnOnce(O) -> P) -> GenerateTextResult<P>
pub fn map_output<P>(self, f: impl FnOnce(O) -> P) -> GenerateTextResult<P>
Maps the output.
Trait Implementations§
Source§impl<O: Clone> Clone for GenerateTextResult<O>
impl<O: Clone> Clone for GenerateTextResult<O>
Source§fn clone(&self) -> GenerateTextResult<O>
fn clone(&self) -> GenerateTextResult<O>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more