File tree 2 files changed +19
-3
lines changed 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ AIScript supports the following AI models:
119
119
120
120
- [x] OpenAI ((uses ` OPENAI_API_KEY ` environment variable by default))
121
121
- [x] DeepSeek
122
- - [ ] Anthropic
122
+ - [x ] Anthropic
123
123
124
124
Configuration by ` project.toml ` :
125
125
@@ -133,6 +133,11 @@ model = "gpt-3.5-turbo"
133
133
[ai .deepseek ]
134
134
api_key = " YOUR_API_KEY"
135
135
model = " deepseek-chat"
136
+
137
+ # or use Anthropic
138
+ [ai .anthropic ]
139
+ api_key = " YOUR_API_KEY"
140
+ model = " claude-3-5-sonnet-latest"
136
141
```
137
142
138
143
## Roadmap
Original file line number Diff line number Diff line change @@ -9,9 +9,14 @@ pub use prompt::{PromptConfig, prompt_with_config};
9
9
10
10
use serde:: Deserialize ;
11
11
12
+ // Deepseek
12
13
const DEEPSEEK_API_ENDPOINT : & str = "https://api.deepseek.com/v1" ;
13
14
const DEEPSEEK_V3 : & str = "deepseek-chat" ;
14
15
16
+ // Anthropic
17
+ const ANTHROPIC_API_ENDPOINT : & str = "https://api.anthropic.com/v1" ;
18
+ const CLAUDE_3_5_SONNET : & str = "claude-3-5-sonnet-latest" ;
19
+
15
20
#[ derive( Debug , Clone , Deserialize ) ]
16
21
pub enum AiConfig {
17
22
#[ serde( rename = "openai" ) ]
@@ -69,7 +74,11 @@ pub(crate) fn openai_client(config: Option<&AiConfig>) -> OpenAIClient {
69
74
. with_api_key ( api_key)
70
75
. build ( )
71
76
. unwrap ( ) ,
72
- Some ( AiConfig :: Anthropic ( _) ) => unimplemented ! ( "Anthropic API not yet supported" ) ,
77
+ Some ( AiConfig :: Anthropic ( ModelConfig { api_key, .. } ) ) => OpenAIClient :: builder ( )
78
+ . with_endpoint ( ANTHROPIC_API_ENDPOINT )
79
+ . with_api_key ( api_key)
80
+ . build ( )
81
+ . unwrap ( ) ,
73
82
}
74
83
}
75
84
@@ -82,6 +91,8 @@ pub(crate) fn default_model(config: Option<&AiConfig>) -> String {
82
91
Some ( AiConfig :: DeepSeek ( ModelConfig { model, .. } ) ) => {
83
92
model. clone ( ) . unwrap_or ( DEEPSEEK_V3 . to_string ( ) )
84
93
}
85
- Some ( AiConfig :: Anthropic ( _) ) => unimplemented ! ( "Anthropic API not yet supported" ) ,
94
+ Some ( AiConfig :: Anthropic ( ModelConfig { model, .. } ) ) => {
95
+ model. clone ( ) . unwrap_or ( CLAUDE_3_5_SONNET . to_string ( ) )
96
+ }
86
97
}
87
98
}
You can’t perform that action at this time.
0 commit comments