Skip to main content

ModelResponse

Struct ModelResponse 

Source
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: String

Kind identifier.

Implementations§

Source§

impl ModelResponse

Source

pub fn new() -> ModelResponse

Create a new empty response.

Source

pub fn with_parts(parts: Vec<ModelResponsePart>) -> ModelResponse

Create a response with the given parts.

Source

pub fn text(content: impl Into<String>) -> ModelResponse

Create a simple text response.

Source

pub fn add_part(&mut self, part: ModelResponsePart)

Add a part.

Source

pub fn with_model_name(self, name: impl Into<String>) -> ModelResponse

Set the model name.

Source

pub fn with_finish_reason(self, reason: FinishReason) -> ModelResponse

Set the finish reason.

Source

pub fn with_usage(self, usage: RequestUsage) -> ModelResponse

Set the usage.

Source

pub fn with_vendor_id(self, id: impl Into<String>) -> ModelResponse

Set the vendor ID.

Source

pub fn with_vendor_details(self, details: Value) -> ModelResponse

Set vendor details.

Source

pub fn text_parts(&self) -> impl Iterator<Item = &TextPart>

Get all text parts.

Source

pub fn tool_call_parts(&self) -> impl Iterator<Item = &ToolCallPart>

Get all tool call parts.

Source

pub fn thinking_parts(&self) -> impl Iterator<Item = &ThinkingPart>

Get all thinking parts.

Source

pub fn file_parts(&self) -> impl Iterator<Item = &FilePart>

Get all file parts.

Source

pub fn text_parts_vec(&self) -> Vec<&TextPart>

👎Deprecated: Use text_parts() iterator instead

Get all text parts as a vector.

Source

pub fn tool_call_parts_vec(&self) -> Vec<&ToolCallPart>

👎Deprecated: Use tool_call_parts() iterator instead

Get all tool call parts as a vector.

Source

pub fn thinking_parts_vec(&self) -> Vec<&ThinkingPart>

👎Deprecated: Use thinking_parts() iterator instead

Get all thinking parts as a vector.

Source

pub fn file_parts_vec(&self) -> Vec<&FilePart>

👎Deprecated: Use file_parts() iterator instead

Get all file parts as a vector.

Source

pub fn has_files(&self) -> bool

Check if this response contains file parts.

Source

pub fn builtin_tool_call_parts( &self, ) -> impl Iterator<Item = &BuiltinToolCallPart>

Get all builtin tool call parts.

Source

pub fn builtin_tool_call_parts_vec(&self) -> Vec<&BuiltinToolCallPart>

👎Deprecated: Use builtin_tool_call_parts() iterator instead

Get all builtin tool call parts as a vector.

Source

pub fn has_builtin_tool_calls(&self) -> bool

Check if this response contains builtin tool calls.

Source

pub fn text_content(&self) -> String

Get combined text content.

Source

pub fn has_tool_calls(&self) -> bool

Check if this response contains tool calls.

Source

pub fn is_empty(&self) -> bool

Check if the response is empty.

Source

pub fn len(&self) -> usize

Get the number of parts.

Trait Implementations§

Source§

impl Clone for ModelResponse

Source§

fn clone(&self) -> ModelResponse

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModelResponse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ModelResponse

Source§

fn default() -> ModelResponse

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ModelResponse

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ModelResponse, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromIterator<ModelResponsePart> for ModelResponse

Source§

fn from_iter<T>(iter: T) -> ModelResponse

Creates a value from an iterator. Read more
Source§

impl PartialEq for ModelResponse

Source§

fn eq(&self, other: &ModelResponse) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ModelResponse

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ModelResponse

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> GraphState for T
where T: Clone + Send + Sync + Debug + 'static,

Source§

impl<T> PersistableState for T