llm_link/apps/
claude.rs

1use crate::settings::{
2    Settings, ServerSettings, LlmBackendSettings, ApiSettings,
3    OpenAiApiSettings, OllamaApiSettings, AnthropicApiSettings,
4    ClientAdapterSettings, ZedAdapterSettings,
5};
6use super::AppConfigGenerator;
7
8/// Claude Code 应用配置
9pub struct ClaudeApp;
10
11impl ClaudeApp {
12    /// 生成 Claude Code 配置
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: 8089,
18                log_level: "info".to_string(),
19            },
20            llm_backend: LlmBackendSettings::Anthropic {
21                api_key: AppConfigGenerator::resolve_env_var("${ANTHROPIC_API_KEY}", cli_api_key),
22                model: "claude-3-5-sonnet-20241022".to_string(),
23            },
24            apis: ApiSettings {
25                openai: Some(OpenAiApiSettings {
26                    enabled: false,
27                    path: "/v1".to_string(),
28                    api_key_header: None,
29                    api_key: None,
30                }),
31                ollama: Some(OllamaApiSettings {
32                    enabled: false,
33                    path: "/ollama".to_string(),
34                    api_key_header: None,
35                    api_key: None,
36                }),
37                anthropic: Some(AnthropicApiSettings {
38                    enabled: true,
39                    path: "".to_string(),
40                    api_key_header: Some("x-api-key".to_string()),
41                }),
42            },
43            client_adapters: Some(ClientAdapterSettings {
44                default_adapter: Some("standard".to_string()),
45                force_adapter: None,
46                zed: Some(ZedAdapterSettings {
47                    enabled: false,
48                    force_images_field: Some(false),
49                    preferred_format: Some("json".to_string()),
50                }),
51            }),
52        }
53    }
54}
55