feat: Support VertexAI for Claude (#1138)

This commit is contained in:
Yuku Kotani
2025-02-13 02:17:15 +09:00
committed by GitHub
parent 724e5ac9a9
commit 58c9eeb6d6
10 changed files with 293 additions and 0 deletions
+14
View File
@@ -6,6 +6,7 @@ use goose::agents::AgentFactory;
use goose::message::Message;
use goose::model::ModelConfig;
use goose::providers::base::Provider;
use goose::providers::vertexai::VertexAIProvider;
use goose::providers::{anthropic::AnthropicProvider, databricks::DatabricksProvider};
use goose::providers::{
azure::AzureProvider, bedrock::BedrockProvider, ollama::OllamaProvider, openai::OpenAiProvider,
@@ -24,6 +25,7 @@ enum ProviderType {
Groq,
Ollama,
OpenRouter,
VertexAI,
}
impl ProviderType {
@@ -42,6 +44,7 @@ impl ProviderType {
ProviderType::Groq => &["GROQ_API_KEY"],
ProviderType::Ollama => &[],
ProviderType::OpenRouter => &["OPENROUTER_API_KEY"],
ProviderType::VertexAI => &["VERTEXAI_PROJECT_ID", "VERTEXAI_REGION"],
}
}
@@ -74,6 +77,7 @@ impl ProviderType {
ProviderType::Groq => Box::new(GroqProvider::from_env(model_config)?),
ProviderType::Ollama => Box::new(OllamaProvider::from_env(model_config)?),
ProviderType::OpenRouter => Box::new(OpenRouterProvider::from_env(model_config)?),
ProviderType::VertexAI => Box::new(VertexAIProvider::from_env(model_config)?),
})
}
}
@@ -290,4 +294,14 @@ mod tests {
})
.await
}
#[tokio::test]
async fn test_truncate_agent_with_vertexai() -> Result<()> {
run_test_with_config(TestConfig {
provider_type: ProviderType::VertexAI,
model: "claude-3-5-sonnet-v2@20241022",
context_window: 200_000,
})
.await
}
}