claude_code_switcher/templates/
deepseek.rs1use crate::{
4 settings::{
5 ClaudeSettings, EndpointConfig, HTTPConfig, ModelConfig, Permissions, ProviderConfig,
6 },
7 snapshots::SnapshotScope,
8 templates::Template,
9};
10use std::collections::HashMap;
11
12#[derive(Debug, Clone)]
14pub struct DeepSeekTemplate;
15
16impl Template for DeepSeekTemplate {
17 fn template_type(&self) -> crate::templates::TemplateType {
18 crate::templates::TemplateType::DeepSeek
19 }
20
21 fn env_var_name(&self) -> &'static str {
22 "DEEPSEEK_API_KEY"
23 }
24
25 fn display_name(&self) -> &'static str {
26 "DeepSeek"
27 }
28
29 fn description(&self) -> &'static str {
30 "DeepSeek Chat API - High-performance conversational AI"
31 }
32
33 fn create_settings(&self, api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
34 let mut settings = ClaudeSettings::new();
35
36 if matches!(scope, SnapshotScope::Common | SnapshotScope::All) {
37 settings.provider = Some(ProviderConfig {
38 id: "deepseek".to_string(),
39 metadata: None,
40 });
41
42 settings.model = Some(ModelConfig {
43 name: "deepseek-chat".to_string(),
44 metadata: None,
45 });
46
47 settings.endpoint = Some(EndpointConfig {
48 id: "deepseek".to_string(),
49 api_base: "https://api.deepseek.com".to_string(),
50 api_key: None, endpoint_id: None,
52 metadata: None,
53 });
54
55 settings.http = Some(HTTPConfig {
56 timeout_ms: Some(30000),
57 max_retries: Some(3),
58 retry_backoff_factor: Some(2.0),
59 });
60
61 settings.permissions = Some(Permissions {
62 allow_network_access: Some(true),
63 allow_filesystem_access: Some(true),
64 allow_command_execution: Some(false),
65 });
66 }
67
68 if matches!(scope, SnapshotScope::Env | SnapshotScope::All) {
69 let mut env = HashMap::new();
70 env.insert(
71 "ANTHROPIC_BASE_URL".to_string(),
72 "https://api.deepseek.com/anthropic".to_string(),
73 );
74 env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
75 env.insert("API_TIMEOUT_MS".to_string(), "600000".to_string());
76 env.insert("ANTHROPIC_MODEL".to_string(), "deepseek-chat".to_string());
77 env.insert(
78 "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
79 "deepseek-chat".to_string(),
80 );
81 env.insert(
82 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
83 "1".to_string(),
84 );
85 settings.environment = Some(env);
86 }
87
88 settings
89 }
90}
91
92pub fn create_deepseek_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
94 let template = DeepSeekTemplate;
95 template.create_settings(api_key, scope)
96}