feat: add GCP Vertex AI platform as provider (#1364)

Signed-off-by: Uddhav Kambli <uddhav@kambli.net>
This commit is contained in:
Uddhav Kambli
2025-03-03 11:46:11 -05:00
committed by GitHub
parent d1a365789e
commit 68b8c5d19d
13 changed files with 2269 additions and 24 deletions
+16 -3
View File
@@ -6,12 +6,12 @@ use goose::agents::AgentFactory;
use goose::message::Message;
use goose::model::ModelConfig;
use goose::providers::base::Provider;
use goose::providers::{anthropic::AnthropicProvider, databricks::DatabricksProvider};
use goose::providers::{
azure::AzureProvider, bedrock::BedrockProvider, ollama::OllamaProvider, openai::OpenAiProvider,
anthropic::AnthropicProvider, azure::AzureProvider, bedrock::BedrockProvider,
databricks::DatabricksProvider, gcpvertexai::GcpVertexAIProvider, google::GoogleProvider,
groq::GroqProvider, ollama::OllamaProvider, openai::OpenAiProvider,
openrouter::OpenRouterProvider,
};
use goose::providers::{google::GoogleProvider, groq::GroqProvider};
#[derive(Debug, PartialEq)]
enum ProviderType {
@@ -20,6 +20,7 @@ enum ProviderType {
Anthropic,
Bedrock,
Databricks,
GcpVertexAI,
Google,
Groq,
Ollama,
@@ -42,6 +43,7 @@ impl ProviderType {
ProviderType::Groq => &["GROQ_API_KEY"],
ProviderType::Ollama => &[],
ProviderType::OpenRouter => &["OPENROUTER_API_KEY"],
ProviderType::GcpVertexAI => &["GCP_PROJECT_ID", "GCP_LOCATION"],
}
}
@@ -70,6 +72,7 @@ impl ProviderType {
ProviderType::Anthropic => Box::new(AnthropicProvider::from_env(model_config)?),
ProviderType::Bedrock => Box::new(BedrockProvider::from_env(model_config)?),
ProviderType::Databricks => Box::new(DatabricksProvider::from_env(model_config)?),
ProviderType::GcpVertexAI => Box::new(GcpVertexAIProvider::from_env(model_config)?),
ProviderType::Google => Box::new(GoogleProvider::from_env(model_config)?),
ProviderType::Groq => Box::new(GroqProvider::from_env(model_config)?),
ProviderType::Ollama => Box::new(OllamaProvider::from_env(model_config)?),
@@ -290,4 +293,14 @@ mod tests {
})
.await
}
#[tokio::test]
async fn test_truncate_agent_with_gcpvertexai() -> Result<()> {
run_test_with_config(TestConfig {
provider_type: ProviderType::GcpVertexAI,
model: "claude-3-5-sonnet-v2@20241022",
context_window: 200_000,
})
.await
}
}