pub const SYSTEM: &str = "gen_ai.system";
pub const OPERATION_NAME: &str = "gen_ai.operation.name";
pub const REQUEST_MODEL: &str = "gen_ai.request.model";
pub const REQUEST_MODEL_VERSION: &str = "gen_ai.request.model.version";
pub const USAGE_INPUT_TOKENS: &str = "gen_ai.usage.input_tokens";
pub const USAGE_OUTPUT_TOKENS: &str = "gen_ai.usage.output_tokens";
pub const USAGE_CACHED_TOKENS: &str = "gen_ai.usage.cached_tokens";
pub const USAGE_REASONING_TOKENS: &str = "gen_ai.usage.reasoning_tokens";
pub const RESPONSE_FINISH_REASON: &str = "gen_ai.response.finish_reason";
pub const REQUEST_MAX_TOKENS: &str = "gen_ai.request.max_tokens";
pub const REQUEST_TEMPERATURE: &str = "gen_ai.request.temperature";
pub const RESPONSE_MODEL: &str = "gen_ai.response.model";
pub const TOOL_NAME: &str = "gen_ai.tool.name";
pub const REQUEST_ID: &str = "gen_ai.request.id";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Operation {
Chat,
TextCompletion,
Embedding,
AgentRun,
AgentTurn,
LlmCall,
ToolCall,
McpRequest,
Stream,
InferenceRequest,
}
impl Operation {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Chat => "chat",
Self::TextCompletion => "text_completion",
Self::Embedding => "embeddings",
Self::AgentRun => "agent.run",
Self::AgentTurn => "agent.turn",
Self::LlmCall => "llm.call",
Self::ToolCall => "tool.call",
Self::McpRequest => "mcp.request",
Self::Stream => "stream",
Self::InferenceRequest => "inference.request",
}
}
#[must_use]
pub fn from_operation_name(value: &str) -> Option<Self> {
match value {
"chat" => Some(Self::Chat),
"text_completion" => Some(Self::TextCompletion),
"embeddings" | "embedding" => Some(Self::Embedding),
"agent.run" => Some(Self::AgentRun),
"agent.turn" => Some(Self::AgentTurn),
"llm.call" => Some(Self::LlmCall),
"tool.call" => Some(Self::ToolCall),
"mcp.request" => Some(Self::McpRequest),
"stream" => Some(Self::Stream),
"inference.request" => Some(Self::InferenceRequest),
_ => None,
}
}
}