Skip to main content

walrus_daemon/config/
model.rs

1//! Agent configuration.
2
3use compact_str::CompactString;
4use model::ProviderConfig;
5use serde::{Deserialize, Serialize};
6use std::collections::BTreeMap;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ModelConfig {
10    /// Default models
11    pub default: DefaultModels,
12    /// Providers
13    pub providers: BTreeMap<CompactString, ProviderConfig>,
14}
15
16#[cfg(not(feature = "local"))]
17impl Default for ModelConfig {
18    fn default() -> Self {
19        Self {
20            default: DefaultModels::default(),
21            providers: [(
22                "deepseek-chat".into(),
23                ProviderConfig {
24                    model: "deepseek-chat".into(),
25                    api_key: None,
26                    base_url: None,
27                    loader: None,
28                    quantization: None,
29                    chat_template: None,
30                },
31            )]
32            .into(),
33        }
34    }
35}
36
37#[cfg(feature = "local")]
38impl Default for ModelConfig {
39    fn default() -> Self {
40        Self {
41            default: DefaultModels::default(),
42            providers: [(
43                "local".into(),
44                ProviderConfig {
45                    model: "Qwen/Qwen3-4B".into(),
46                    api_key: None,
47                    base_url: None,
48                    loader: None,
49                    quantization: None,
50                    chat_template: None,
51                },
52            )]
53            .into(),
54        }
55    }
56}
57
58/// Agent configuration.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct DefaultModels {
61    /// Model used for the general text process
62    pub text: CompactString,
63
64    /// Model used for vision tasks
65    pub vision: Option<CompactString>,
66
67    /// Model used for embedding tasks
68    pub embedding: Option<CompactString>,
69}
70
71#[cfg(not(feature = "local"))]
72impl Default for DefaultModels {
73    fn default() -> Self {
74        Self {
75            text: "deepseek-chat".into(),
76            vision: None,
77            embedding: None,
78        }
79    }
80}
81
82#[cfg(feature = "local")]
83impl Default for DefaultModels {
84    fn default() -> Self {
85        Self {
86            text: "Qwen/Qwen3-4B".into(),
87            vision: None,
88            embedding: None,
89        }
90    }
91}