pub enum StopReason {
EndTurn,
MaxTokens,
StopSequence,
ToolUse,
ContentFilter,
Other(String),
}Expand description
Normalized reason the model stopped generating.
Maps the per-provider stop-reason strings into one shared enum so
downstream consumers can distinguish
“ran out of room” (MaxTokens) from “finished naturally” (EndTurn)
without knowing which provider produced the response. Without this,
a truncated completion might otherwise surface as a parse error with no
hint that the model ran out of max_tokens.
Variants§
EndTurn
Model finished generating naturally. Anthropic end_turn,
OpenAI stop, Bedrock end_turn.
MaxTokens
Generation hit the max_tokens budget and was truncated.
Anthropic max_tokens, OpenAI length, Bedrock max_tokens.
StopSequence
A configured stop sequence appeared in the output. Anthropic
stop_sequence, OpenAI stop with a sequence match, Bedrock
stop_sequence.
ToolUse
Model emitted a tool-use block as its terminal action. Anthropic
tool_use, Bedrock tool_use. OpenAI uses tool_calls.
ContentFilter
Provider-side safety / content filter aborted generation.
OpenAI content_filter, Bedrock content_filtered or
guardrail_intervened.
Other(String)
An upstream-specific stop-reason value we don’t normalize. Carries the raw string so logs and downstream parsing can still see what the provider sent.
Trait Implementations§
Source§impl Clone for StopReason
impl Clone for StopReason
Source§fn clone(&self) -> StopReason
fn clone(&self) -> StopReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StopReason
impl Debug for StopReason
impl Eq for StopReason
Source§impl PartialEq for StopReason
impl PartialEq for StopReason
impl StructuralPartialEq for StopReason
Auto Trait Implementations§
impl Freeze for StopReason
impl RefUnwindSafe for StopReason
impl Send for StopReason
impl Sync for StopReason
impl Unpin for StopReason
impl UnsafeUnpin for StopReason
impl UnwindSafe for StopReason
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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