pub struct LlmGenerationData {
pub messages: Vec<Message>,
pub tools: Vec<ToolDefinitionSummary>,
pub output: LlmGenerationOutput,
pub metadata: LlmGenerationMetadata,
}Expand description
Data for llm.generation event
Emitted after each LLM API call to provide full visibility into the messages sent to the model and the response received.
Fields§
§messages: Vec<Message>Messages sent to the LLM (including system prompt)
tools: Vec<ToolDefinitionSummary>Tools available to the LLM for this generation
output: LlmGenerationOutputOutput from the LLM
metadata: LlmGenerationMetadataMetadata about the generation
Implementations§
Source§impl LlmGenerationData
impl LlmGenerationData
Sourcepub fn success(
messages: Vec<Message>,
tools: Vec<ToolDefinitionSummary>,
text: Option<String>,
tool_calls: Vec<ToolCall>,
model: String,
provider: Option<String>,
usage: Option<TokenUsage>,
duration_ms: Option<u64>,
time_to_first_token_ms: Option<u64>,
) -> Self
pub fn success( messages: Vec<Message>, tools: Vec<ToolDefinitionSummary>, text: Option<String>, tool_calls: Vec<ToolCall>, model: String, provider: Option<String>, usage: Option<TokenUsage>, duration_ms: Option<u64>, time_to_first_token_ms: Option<u64>, ) -> Self
Create a successful generation event
Sourcepub fn success_with_metadata(
messages: Vec<Message>,
tools: Vec<ToolDefinitionSummary>,
text: Option<String>,
tool_calls: Vec<ToolCall>,
model: String,
provider: Option<String>,
usage: Option<TokenUsage>,
duration_ms: Option<u64>,
time_to_first_token_ms: Option<u64>,
finish_reasons: Option<Vec<String>>,
response_id: Option<String>,
) -> Self
pub fn success_with_metadata( messages: Vec<Message>, tools: Vec<ToolDefinitionSummary>, text: Option<String>, tool_calls: Vec<ToolCall>, model: String, provider: Option<String>, usage: Option<TokenUsage>, duration_ms: Option<u64>, time_to_first_token_ms: Option<u64>, finish_reasons: Option<Vec<String>>, response_id: Option<String>, ) -> Self
Create a successful generation event with full metadata
Sourcepub fn success_with_retry(
messages: Vec<Message>,
tools: Vec<ToolDefinitionSummary>,
text: Option<String>,
tool_calls: Vec<ToolCall>,
model: String,
provider: Option<String>,
usage: Option<TokenUsage>,
duration_ms: Option<u64>,
time_to_first_token_ms: Option<u64>,
finish_reasons: Option<Vec<String>>,
response_id: Option<String>,
retry: Option<LlmRetryInfo>,
) -> Self
pub fn success_with_retry( messages: Vec<Message>, tools: Vec<ToolDefinitionSummary>, text: Option<String>, tool_calls: Vec<ToolCall>, model: String, provider: Option<String>, usage: Option<TokenUsage>, duration_ms: Option<u64>, time_to_first_token_ms: Option<u64>, finish_reasons: Option<Vec<String>>, response_id: Option<String>, retry: Option<LlmRetryInfo>, ) -> Self
Create a successful generation event with retry information
Sourcepub fn failure(
messages: Vec<Message>,
tools: Vec<ToolDefinitionSummary>,
model: String,
provider: Option<String>,
error: String,
duration_ms: Option<u64>,
time_to_first_token_ms: Option<u64>,
) -> Self
pub fn failure( messages: Vec<Message>, tools: Vec<ToolDefinitionSummary>, model: String, provider: Option<String>, error: String, duration_ms: Option<u64>, time_to_first_token_ms: Option<u64>, ) -> Self
Create a failed generation event
Sourcepub fn with_compaction(self, compaction: LlmCompactionInfo) -> Self
pub fn with_compaction(self, compaction: LlmCompactionInfo) -> Self
Set compaction info on this generation event
Call this when context was compacted before a successful retry.
Sourcepub fn with_retry(self, retry: LlmRetryInfo) -> Self
pub fn with_retry(self, retry: LlmRetryInfo) -> Self
Set retry info on this generation event
Sourcepub fn with_request_options(self, request_options: LlmRequestOptions) -> Self
pub fn with_request_options(self, request_options: LlmRequestOptions) -> Self
Set request-side options on this generation event.
Trait Implementations§
Source§impl Clone for LlmGenerationData
impl Clone for LlmGenerationData
Source§fn clone(&self) -> LlmGenerationData
fn clone(&self) -> LlmGenerationData
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LlmGenerationData
impl Debug for LlmGenerationData
Source§impl<'de> Deserialize<'de> for LlmGenerationData
impl<'de> Deserialize<'de> for LlmGenerationData
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<LlmGenerationData> for EventData
impl From<LlmGenerationData> for EventData
Source§fn from(data: LlmGenerationData) -> Self
fn from(data: LlmGenerationData) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for LlmGenerationData
impl RefUnwindSafe for LlmGenerationData
impl Send for LlmGenerationData
impl Sync for LlmGenerationData
impl Unpin for LlmGenerationData
impl UnsafeUnpin for LlmGenerationData
impl UnwindSafe for LlmGenerationData
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
Mutably borrows from an owned value. Read more
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<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> 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>
Converts
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>
Converts
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 moreSource§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>
Wrap the input message
T in a tonic::Request