llm_link/apps/
zed.rs

1use crate::settings::{
2    Settings, ServerSettings, LlmBackendSettings, ApiSettings,
3    OpenAiApiSettings, OllamaApiSettings, AnthropicApiSettings,
4    ClientAdapterSettings, ZedAdapterSettings,
5};
6use super::AppConfigGenerator;
7
8/// Zed.dev 应用配置
9pub struct ZedApp;
10
11impl ZedApp {
12    /// 生成 Zed.dev 配置
13    pub fn generate_config(cli_api_key: Option<&str>) -> Settings {
14        Settings {
15            server: ServerSettings {
16                host: "0.0.0.0".to_string(),
17                port: 11434,
18                log_level: "info".to_string(),
19            },
20            llm_backend: LlmBackendSettings::Zhipu {
21                api_key: AppConfigGenerator::resolve_env_var("${ZHIPU_API_KEY}", cli_api_key),
22                base_url: Some("https://open.bigmodel.cn/api/paas/v4".to_string()),
23                model: "glm-4-flash".to_string(),
24            },
25            apis: ApiSettings {
26                openai: Some(OpenAiApiSettings {
27                    enabled: false,
28                    path: "/v1".to_string(),
29                    api_key_header: None,
30                    api_key: None,
31                }),
32                ollama: Some(OllamaApiSettings {
33                    enabled: true,
34                    path: "".to_string(),  // Empty path so routes become /api/tags directly
35                    api_key_header: None,
36                    api_key: None,
37                }),
38                anthropic: Some(AnthropicApiSettings {
39                    enabled: false,
40                    path: "/anthropic".to_string(),
41                    api_key_header: None,
42                }),
43            },
44            client_adapters: Some(ClientAdapterSettings {
45                default_adapter: Some("zed".to_string()),
46                force_adapter: Some("zed".to_string()),
47                zed: Some(ZedAdapterSettings {
48                    enabled: true,
49                    force_images_field: Some(true),
50                    preferred_format: Some("ndjson".to_string()),
51                }),
52            }),
53        }
54    }
55}
56