Skip to main content

defect_agent/llm/
model.rs

1//! Metadata for providers and models.
2
3use serde::{Deserialize, Serialize};
4
5use super::capability::ModelCapabilityOverrides;
6
7/// Provider metadata (vendor name, API style, tracing labels, etc.).
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub struct ProviderInfo {
10    /// Vendor identifier (e.g. "anthropic", "openai", "bedrock", …).
11    pub vendor: String,
12    /// Underlying protocol.
13    pub protocol: ProtocolId,
14    /// Human-readable name for tracing (e.g. "Anthropic Claude").
15    pub display_name: String,
16}
17
18/// Protocol identifier. Each variant corresponds one-to-one with a codec in
19/// `defect-llm::protocol`.
20#[non_exhaustive]
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
22#[serde(rename_all = "snake_case")]
23pub enum ProtocolId {
24    AnthropicMessages,
25    OpenAiChat,
26}
27
28/// Metadata for a single model.
29///
30/// `context_window` and `max_output_tokens` are `Option` because some providers do not
31/// expose these fields; callers should treat them as unknown (no forced truncation).
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33pub struct ModelInfo {
34    pub id: String,
35    pub display_name: Option<String>,
36    pub context_window: Option<u64>,
37    pub max_output_tokens: Option<u64>,
38    pub deprecated: bool,
39    /// Differences from the provider-wide [`super::Capabilities`] for this model.
40    pub capabilities_overrides: ModelCapabilityOverrides,
41}