Skip to main content

wesichain_core/callbacks/
llm.rs

1//! Structured types for LLM observability.
2//!
3//! These types capture LLM-specific inputs and outputs for cost tracking,
4//! prompt debugging, and performance analysis.
5
6/// Token consumption for cost tracking and optimization.
7#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
8pub struct TokenUsage {
9    pub prompt_tokens: u32,
10    pub completion_tokens: u32,
11    pub total_tokens: u32,
12}
13
14/// LLM call parameters captured at start time.
15#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
16pub struct LlmInput {
17    pub model: String,
18    /// Rendered prompt (after template expansion), not the template itself
19    pub prompt: String,
20    pub temperature: Option<f32>,
21    pub max_tokens: Option<u32>,
22    pub stop_sequences: Vec<String>,
23}
24
25/// LLM call results captured at end time.
26#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
27pub struct LlmResult {
28    pub token_usage: Option<TokenUsage>,
29    pub model: String,
30    pub finish_reason: Option<String>,
31    /// Rendered output strings (one per generation)
32    pub generations: Vec<String>,
33}