Skip to main content

llm_trait/
capabilities.rs

1//! Provider capabilities and info types.
2
3/// Provider capability description.
4#[derive(Clone, Debug, Default)]
5pub struct Capabilities {
6    /// Supports streaming responses
7    pub supports_streaming: bool,
8    /// Supports tool calling
9    pub supports_tools: bool,
10    /// Supports vision (images)
11    pub supports_vision: bool,
12    /// Supports thinking/reasoning
13    pub supports_thinking: bool,
14    /// Maximum context token count
15    pub max_context_tokens: Option<u32>,
16    /// Maximum output token count
17    pub max_output_tokens: Option<u32>,
18}
19
20/// Provider information.
21#[derive(Clone, Debug)]
22pub struct ProviderInfo {
23    /// Provider name (e.g. "openai", "anthropic", "mimo", "deepseek")
24    pub name: String,
25    /// Model name (e.g. "gpt-4o", "claude-sonnet")
26    pub model: String,
27    /// Version info (optional)
28    pub version: Option<String>,
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34
35    #[test]
36    fn capabilities_default() {
37        let caps = Capabilities::default();
38        assert!(!caps.supports_streaming);
39        assert!(!caps.supports_tools);
40        assert!(!caps.supports_vision);
41        assert!(!caps.supports_thinking);
42        assert!(caps.max_context_tokens.is_none());
43        assert!(caps.max_output_tokens.is_none());
44    }
45
46    #[test]
47    fn capabilities_clone() {
48        let caps = Capabilities {
49            supports_streaming: true,
50            supports_tools: true,
51            supports_vision: false,
52            supports_thinking: true,
53            max_context_tokens: Some(128_000),
54            max_output_tokens: Some(16_384),
55        };
56        let cloned = caps.clone();
57        assert!(cloned.supports_streaming);
58        assert!(cloned.supports_tools);
59        assert!(!cloned.supports_vision);
60        assert!(cloned.supports_thinking);
61        assert_eq!(cloned.max_context_tokens, Some(128_000));
62        assert_eq!(cloned.max_output_tokens, Some(16_384));
63    }
64
65    #[test]
66    fn provider_info_debug() {
67        let info = ProviderInfo {
68            name: "openai".to_string(),
69            model: "gpt-4o".to_string(),
70            version: None,
71        };
72        let debug = format!("{:?}", info);
73        assert!(debug.contains("openai"));
74        assert!(debug.contains("gpt-4o"));
75    }
76}