File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 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:
119119
120120- [x] OpenAI ((uses ` OPENAI_API_KEY ` environment variable by default))
121121- [x] DeepSeek
122- - [ ] Anthropic
122+ - [x ] Anthropic
123123
124124Configuration by ` project.toml ` :
125125
@@ -133,6 +133,11 @@ model = "gpt-3.5-turbo"
133133[ai .deepseek ]
134134api_key = " YOUR_API_KEY"
135135model = " deepseek-chat"
136+
137+ # or use Anthropic
138+ [ai .anthropic ]
139+ api_key = " YOUR_API_KEY"
140+ model = " claude-3-5-sonnet-latest"
136141```
137142
138143## Roadmap
Original file line number Diff line number Diff line change @@ -9,9 +9,14 @@ pub use prompt::{PromptConfig, prompt_with_config};
99
1010use serde:: Deserialize ;
1111
12+ // Deepseek
1213const DEEPSEEK_API_ENDPOINT : & str = "https://api.deepseek.com/v1" ;
1314const DEEPSEEK_V3 : & str = "deepseek-chat" ;
1415
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+
1520#[ derive( Debug , Clone , Deserialize ) ]
1621pub enum AiConfig {
1722 #[ serde( rename = "openai" ) ]
@@ -69,7 +74,11 @@ pub(crate) fn openai_client(config: Option<&AiConfig>) -> OpenAIClient {
6974 . with_api_key ( api_key)
7075 . build ( )
7176 . 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 ( ) ,
7382 }
7483}
7584
@@ -82,6 +91,8 @@ pub(crate) fn default_model(config: Option<&AiConfig>) -> String {
8291 Some ( AiConfig :: DeepSeek ( ModelConfig { model, .. } ) ) => {
8392 model. clone ( ) . unwrap_or ( DEEPSEEK_V3 . to_string ( ) )
8493 }
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+ }
8697 }
8798}
You can’t perform that action at this time.
0 commit comments