feat(config): 为 anthropic、kimi、deepseek 添加 list_models 支持
This commit is contained in:
@@ -70,10 +70,16 @@ impl AnthropicClient {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// List available models
|
||||
pub async fn list_models(&self) -> Result<Vec<String>> {
|
||||
// Anthropic doesn't have a models API endpoint, return predefined list
|
||||
Ok(ANTHROPIC_MODELS.iter().map(|&m| m.to_string()).collect())
|
||||
}
|
||||
|
||||
/// Validate API key
|
||||
pub async fn validate_key(&self) -> Result<bool> {
|
||||
let url = "https://api.anthropic.com/v1/messages";
|
||||
|
||||
|
||||
let request = MessagesRequest {
|
||||
model: self.model.clone(),
|
||||
max_tokens: 5,
|
||||
@@ -84,7 +90,7 @@ impl AnthropicClient {
|
||||
}],
|
||||
system: None,
|
||||
};
|
||||
|
||||
|
||||
let response = self.client
|
||||
.post(url)
|
||||
.header("x-api-key", &self.api_key)
|
||||
@@ -93,7 +99,7 @@ impl AnthropicClient {
|
||||
.json(&request)
|
||||
.send()
|
||||
.await;
|
||||
|
||||
|
||||
match response {
|
||||
Ok(resp) => {
|
||||
if resp.status().is_success() {
|
||||
|
||||
Reference in New Issue
Block a user