defect_core/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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum ProtocolId {
23 AnthropicMessages,
24 OpenAiChat,
25}
26
27/// Metadata for a single model.
28///
29/// `context_window` and `max_output_tokens` are `Option` because some providers do not
30/// expose these fields; callers should treat them as unknown (no forced truncation).
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32pub struct ModelInfo {
33 pub id: String,
34 pub display_name: Option<String>,
35 pub context_window: Option<u64>,
36 pub max_output_tokens: Option<u64>,
37 pub deprecated: bool,
38 /// Differences from the provider-wide [`super::Capabilities`] for this model.
39 pub capabilities_overrides: ModelCapabilityOverrides,
40}