Struct ChatResponse
pub struct ChatResponse {
pub text: Option<String>,
pub tool_calls: Vec<ToolCall>,
pub usage: Option<TokenUsage>,
pub reasoning_content: Option<String>,
}Expand description
An LLM response that may contain text, tool calls, or both.
Fields§
§text: Option<String>Text content of the response (may be empty if only tool calls).
tool_calls: Vec<ToolCall>Tool calls requested by the LLM.
usage: Option<TokenUsage>Token usage reported by the model_provider, if available.
reasoning_content: Option<String>Raw reasoning/thinking content from thinking models (e.g. DeepSeek-R1, Kimi K2.5, GLM-4.7). Preserved as an opaque pass-through so it can be sent back in subsequent API requests — some model_providers reject tool-call history that omits this field.
Implementations§
Source§impl ChatResponse
impl ChatResponse
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
True when the LLM wants to invoke at least one tool.
Sourcepub fn text_or_empty(&self) -> &str
pub fn text_or_empty(&self) -> &str
Convenience: return text content or empty string.
Sourcepub fn is_semantically_empty_terminal(&self) -> bool
pub fn is_semantically_empty_terminal(&self) -> bool
True when this response cannot make progress or complete a turn.
Reasoning content is intentionally excluded: it may need to be round-tripped to a provider, but it is not a user-visible final answer. A response containing one or more tool calls remains valid even when its text is empty.
Trait Implementations§
Source§impl Clone for ChatResponse
impl Clone for ChatResponse
Source§fn clone(&self) -> ChatResponse
fn clone(&self) -> ChatResponse
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ChatResponse
impl RefUnwindSafe for ChatResponse
impl Send for ChatResponse
impl Sync for ChatResponse
impl Unpin for ChatResponse
impl UnsafeUnpin for ChatResponse
impl UnwindSafe for ChatResponse
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> 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>
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