pub struct AnnotatedLlmResponse {
pub id: Option<String>,
pub model: Option<String>,
pub message: Option<MessageContent>,
pub tool_calls: Option<Vec<ResponseToolCall>>,
pub finish_reason: Option<FinishReason>,
pub usage: Option<Usage>,
pub api_specific: Option<ApiSpecificResponse>,
pub extra: Map<String, Json>,
}Expand description
Structured view of an LLM response, produced by a response codec from raw JSON API output.
The extra field captures any top-level keys not modeled by the known
fields, ensuring lossless round-trip through serde.
Fields§
§id: Option<String>Response ID from the API (e.g., “chatcmpl-abc123”, “resp_abc123”, “msg_abc123”).
model: Option<String>The model that actually served the request (may differ from requested model).
message: Option<MessageContent>The assistant’s response content, reusing MessageContent from request types.
tool_calls: Option<Vec<ResponseToolCall>>Tool calls requested by the model, normalized across APIs.
Uses ResponseToolCall (arguments as Json) NOT the request-side
ToolCall (arguments as String).
finish_reason: Option<FinishReason>Why generation stopped, normalized across APIs.
usage: Option<Usage>Token usage statistics.
api_specific: Option<ApiSpecificResponse>API-specific response data that cannot be normalized across providers.
extra: Map<String, Json>Catch-all for unmodeled top-level fields, ensuring lossless round-trip.
Implementations§
Source§impl AnnotatedLlmResponse
impl AnnotatedLlmResponse
Sourcepub fn response_text(&self) -> Option<&str>
pub fn response_text(&self) -> Option<&str>
Extract the text content of the response message.
For MessageContent::Text, returns the string directly.
For MessageContent::Parts, returns the text of the first
super::request::ContentPart::Text part.
Returns None if message is None.
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
Check if the response contains any tool calls.
Returns true if tool_calls is Some with at least one element.
Trait Implementations§
Source§impl Clone for AnnotatedLlmResponse
impl Clone for AnnotatedLlmResponse
Source§fn clone(&self) -> AnnotatedLlmResponse
fn clone(&self) -> AnnotatedLlmResponse
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 AnnotatedLlmResponse
impl Debug for AnnotatedLlmResponse
Source§impl<'de> Deserialize<'de> for AnnotatedLlmResponse
impl<'de> Deserialize<'de> for AnnotatedLlmResponse
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>,
Source§impl PartialEq for AnnotatedLlmResponse
impl PartialEq for AnnotatedLlmResponse
Source§fn eq(&self, other: &AnnotatedLlmResponse) -> bool
fn eq(&self, other: &AnnotatedLlmResponse) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for AnnotatedLlmResponse
impl Serialize for AnnotatedLlmResponse
impl StructuralPartialEq for AnnotatedLlmResponse
Auto Trait Implementations§
impl Freeze for AnnotatedLlmResponse
impl RefUnwindSafe for AnnotatedLlmResponse
impl Send for AnnotatedLlmResponse
impl Sync for AnnotatedLlmResponse
impl Unpin for AnnotatedLlmResponse
impl UnsafeUnpin for AnnotatedLlmResponse
impl UnwindSafe for AnnotatedLlmResponse
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<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request