#[non_exhaustive]pub enum FinishReason {
Stop,
Length,
ToolCalls,
ContentFilter,
Other(String),
}Expand description
Normalized generation ending. Unmapped provider values remain in Self::Other.
Failure statuses may accompany parseable output; callers must decide whether
such output is usable rather than treating every response as successful.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Stop
Natural end of the response.
Length
The response hit the output-token limit.
ToolCalls
The model stopped to call one or more tools.
ContentFilter
The provider filtered the content.
Other(String)
A provider-specific reason outside the normalized vocabulary, carried verbatim in the provider’s own wire spelling.
Implementations§
Source§impl FinishReason
impl FinishReason
Sourcepub fn reconcile_with_output(self, has_tool_call: bool) -> Self
pub fn reconcile_with_output(self, has_tool_call: bool) -> Self
Changes Self::Stop to Self::ToolCalls when output contains a tool
call. All other reasons remain unchanged. Response builders and streaming
aggregation apply this reconciliation.
Sourcepub fn truncated_output(&self) -> bool
pub fn truncated_output(&self) -> bool
Returns whether the reason is Self::Length or Self::ContentFilter.
These reasons permit answerless turns without treating absent content as
a malformed response. Unknown reasons are not classified as truncation.
Sourcepub fn no_answer_message(&self) -> String
pub fn no_answer_message(&self) -> String
Formats an answerless-turn diagnostic with budget or filtering advice for known truncation reasons, and a generic explanation otherwise.
Trait Implementations§
Source§impl Clone for FinishReason
impl Clone for FinishReason
Source§impl Debug for FinishReason
impl Debug for FinishReason
Source§impl<'de> Deserialize<'de> for FinishReason
impl<'de> Deserialize<'de> for FinishReason
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>,
impl Eq for FinishReason
Source§impl PartialEq for FinishReason
impl PartialEq for FinishReason
Source§impl Serialize for FinishReason
impl Serialize for FinishReason
impl StructuralPartialEq for FinishReason
Auto Trait Implementations§
impl Freeze for FinishReason
impl RefUnwindSafe for FinishReason
impl Send for FinishReason
impl Sync for FinishReason
impl Unpin for FinishReason
impl UnsafeUnpin for FinishReason
impl UnwindSafe for FinishReason
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
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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