#[non_exhaustive]pub struct ModelTurn {
pub text: String,
pub tool_calls: Vec<ToolCall>,
pub usage: Option<TokenUsage>,
pub response_model: Option<String>,
pub response_id: Option<String>,
pub finish_reason: Option<String>,
}Available on crate feature
tool-loop only.Expand description
What one turn produced.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.text: StringThe turn’s text.
tool_calls: Vec<ToolCall>The calls the model asked for; empty when it answered.
usage: Option<TokenUsage>Token usage, when the provider reported it.
response_model: Option<String>The model that answered, when the provider named it.
response_id: Option<String>The provider’s id for the completion, when it gave one; recorded as
gen_ai.response.id.
finish_reason: Option<String>Why the model stopped, as the provider spelled it (stop,
tool_calls, length, …); recorded as
gen_ai.response.finish_reasons.
Implementations§
Source§impl ModelTurn
impl ModelTurn
Sourcepub fn new(text: impl Into<String>, tool_calls: Vec<ToolCall>) -> ModelTurn
pub fn new(text: impl Into<String>, tool_calls: Vec<ToolCall>) -> ModelTurn
A turn of text and tool_calls.
Sourcepub const fn with_usage(self, usage: TokenUsage) -> ModelTurn
pub const fn with_usage(self, usage: TokenUsage) -> ModelTurn
Sets the token usage.
Sourcepub fn with_response_model(self, model: impl Into<String>) -> ModelTurn
pub fn with_response_model(self, model: impl Into<String>) -> ModelTurn
Sets the model the provider says answered.
Sourcepub fn with_response_id(self, id: impl Into<String>) -> ModelTurn
pub fn with_response_id(self, id: impl Into<String>) -> ModelTurn
Sets the provider’s id for the completion.
Sourcepub fn with_finish_reason(self, reason: impl Into<String>) -> ModelTurn
pub fn with_finish_reason(self, reason: impl Into<String>) -> ModelTurn
Sets why the model stopped, as the provider spelled it.
Trait Implementations§
impl Eq for ModelTurn
impl StructuralPartialEq for ModelTurn
Auto Trait Implementations§
impl Forget for ModelTurn
impl Freeze for ModelTurn
impl Move for ModelTurn
impl RefUnwindSafe for ModelTurn
impl Send for ModelTurn
impl Sync for ModelTurn
impl Unpin for ModelTurn
impl UnsafeUnpin for ModelTurn
impl UnwindSafe for ModelTurn
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].