pub struct ModelResponse {
pub parts: Vec<ModelResponsePart>,
pub model_name: Option<String>,
pub timestamp: DateTime<Utc>,
pub finish_reason: Option<FinishReason>,
pub usage: Option<RequestUsage>,
pub vendor_id: Option<String>,
pub vendor_details: Option<Value>,
pub kind: String,
}Expand description
A complete model response containing multiple parts.
Fields§
§parts: Vec<ModelResponsePart>The response parts.
model_name: Option<String>Name of the model that generated this response.
timestamp: DateTime<Utc>When this response was received.
finish_reason: Option<FinishReason>Why the model stopped generating.
usage: Option<RequestUsage>Token usage for this request.
vendor_id: Option<String>Vendor-specific response ID.
vendor_details: Option<Value>Vendor-specific details.
kind: StringKind identifier.
Implementations§
Source§impl ModelResponse
impl ModelResponse
Sourcepub fn new() -> ModelResponse
pub fn new() -> ModelResponse
Create a new empty response.
Sourcepub fn with_parts(parts: Vec<ModelResponsePart>) -> ModelResponse
pub fn with_parts(parts: Vec<ModelResponsePart>) -> ModelResponse
Create a response with the given parts.
Sourcepub fn text(content: impl Into<String>) -> ModelResponse
pub fn text(content: impl Into<String>) -> ModelResponse
Create a simple text response.
Sourcepub fn add_part(&mut self, part: ModelResponsePart)
pub fn add_part(&mut self, part: ModelResponsePart)
Add a part.
Sourcepub fn with_model_name(self, name: impl Into<String>) -> ModelResponse
pub fn with_model_name(self, name: impl Into<String>) -> ModelResponse
Set the model name.
Sourcepub fn with_finish_reason(self, reason: FinishReason) -> ModelResponse
pub fn with_finish_reason(self, reason: FinishReason) -> ModelResponse
Set the finish reason.
Sourcepub fn with_usage(self, usage: RequestUsage) -> ModelResponse
pub fn with_usage(self, usage: RequestUsage) -> ModelResponse
Set the usage.
Sourcepub fn with_vendor_id(self, id: impl Into<String>) -> ModelResponse
pub fn with_vendor_id(self, id: impl Into<String>) -> ModelResponse
Set the vendor ID.
Sourcepub fn with_vendor_details(self, details: Value) -> ModelResponse
pub fn with_vendor_details(self, details: Value) -> ModelResponse
Set vendor details.
Sourcepub fn text_parts(&self) -> impl Iterator<Item = &TextPart>
pub fn text_parts(&self) -> impl Iterator<Item = &TextPart>
Get all text parts.
Sourcepub fn tool_call_parts(&self) -> impl Iterator<Item = &ToolCallPart>
pub fn tool_call_parts(&self) -> impl Iterator<Item = &ToolCallPart>
Get all tool call parts.
Sourcepub fn thinking_parts(&self) -> impl Iterator<Item = &ThinkingPart>
pub fn thinking_parts(&self) -> impl Iterator<Item = &ThinkingPart>
Get all thinking parts.
Sourcepub fn file_parts(&self) -> impl Iterator<Item = &FilePart>
pub fn file_parts(&self) -> impl Iterator<Item = &FilePart>
Get all file parts.
Sourcepub fn text_parts_vec(&self) -> Vec<&TextPart>
👎Deprecated: Use text_parts() iterator instead
pub fn text_parts_vec(&self) -> Vec<&TextPart>
Get all text parts as a vector.
Sourcepub fn tool_call_parts_vec(&self) -> Vec<&ToolCallPart>
👎Deprecated: Use tool_call_parts() iterator instead
pub fn tool_call_parts_vec(&self) -> Vec<&ToolCallPart>
Get all tool call parts as a vector.
Sourcepub fn thinking_parts_vec(&self) -> Vec<&ThinkingPart>
👎Deprecated: Use thinking_parts() iterator instead
pub fn thinking_parts_vec(&self) -> Vec<&ThinkingPart>
Get all thinking parts as a vector.
Sourcepub fn file_parts_vec(&self) -> Vec<&FilePart>
👎Deprecated: Use file_parts() iterator instead
pub fn file_parts_vec(&self) -> Vec<&FilePart>
Get all file parts as a vector.
Sourcepub fn builtin_tool_call_parts(
&self,
) -> impl Iterator<Item = &BuiltinToolCallPart>
pub fn builtin_tool_call_parts( &self, ) -> impl Iterator<Item = &BuiltinToolCallPart>
Get all builtin tool call parts.
Sourcepub fn builtin_tool_call_parts_vec(&self) -> Vec<&BuiltinToolCallPart>
👎Deprecated: Use builtin_tool_call_parts() iterator instead
pub fn builtin_tool_call_parts_vec(&self) -> Vec<&BuiltinToolCallPart>
Get all builtin tool call parts as a vector.
Sourcepub fn has_builtin_tool_calls(&self) -> bool
pub fn has_builtin_tool_calls(&self) -> bool
Check if this response contains builtin tool calls.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Get combined text content.
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
Check if this response contains tool calls.
Trait Implementations§
Source§impl Clone for ModelResponse
impl Clone for ModelResponse
Source§fn clone(&self) -> ModelResponse
fn clone(&self) -> ModelResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more