pub enum FinishReason {
Stop,
Length,
ToolCalls,
ContentFilter,
Other(String),
}Expand description
Why the model stopped generating, normalized across providers.
The variant a caller acts on is FinishReason::Length: the output hit a
token limit — the request’s own max_tokens, or whatever the serving stack
enforces on its own — and the content is cut mid-thought. That arrives as
HTTP 200 with no refusal, so this field is the only thing in the response
that says the text is incomplete.
Variants§
Stop
The model finished on its own.
Length
Generation was cut at an output-token limit; the content is incomplete.
ToolCalls
The model stopped to call tools.
ContentFilter
The provider suppressed output (safety filter, recitation).
Other(String)
A reason this crate does not recognize, kept verbatim.
Implementations§
Source§impl FinishReason
impl FinishReason
Sourcepub fn from_wire(value: &str) -> Self
pub fn from_wire(value: &str) -> Self
Reads a provider’s wire spelling. OpenAI-compatible endpoints (OpenAI,
OpenRouter, llama.cpp, vLLM) say stop / length / tool_calls /
function_call / content_filter; Gemini says STOP / MAX_TOKENS /
SAFETY / … — one reader for both, since the spellings do not collide.
Trait Implementations§
Source§impl Clone for FinishReason
impl Clone for FinishReason
Source§fn clone(&self) -> FinishReason
fn clone(&self) -> FinishReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more