From 87237b6462b9dfd379b22e69712e8dc516afad9d Mon Sep 17 00:00:00 2001 From: mineo Date: Fri, 16 May 2025 03:25:21 +0900 Subject: feat: support VertexAI provider (#153) * support: vertexai fix fix set default for vertexai added comment fix fix * create schema * fix README.md * fix order * added pupularity * set tools if tools is exists restore commentout * fix comment * set summarizer model --- internal/config/config.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'internal/config') diff --git a/internal/config/config.go b/internal/config/config.go index f9aba238d..1d741bc91 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -235,6 +235,7 @@ func setProviderDefaults() { // 5. OpenRouter // 6. AWS Bedrock // 7. Azure + // 8. Google Cloud VertexAI // Anthropic configuration if key := viper.GetString("providers.anthropic.apiKey"); strings.TrimSpace(key) != "" { @@ -299,6 +300,15 @@ func setProviderDefaults() { viper.SetDefault("agents.title.model", models.AzureGPT41Mini) return } + + // Google Cloud VertexAI configuration + if hasVertexAICredentials() { + viper.SetDefault("agents.coder.model", models.VertexAIGemini25) + viper.SetDefault("agents.summarizer.model", models.VertexAIGemini25) + viper.SetDefault("agents.task.model", models.VertexAIGemini25Flash) + viper.SetDefault("agents.title.model", models.VertexAIGemini25Flash) + return + } } // hasAWSCredentials checks if AWS credentials are available in the environment. @@ -327,6 +337,19 @@ func hasAWSCredentials() bool { return false } +// hasVertexAICredentials checks if VertexAI credentials are available in the environment. +func hasVertexAICredentials() bool { + // Check for explicit VertexAI parameters + if os.Getenv("VERTEXAI_PROJECT") != "" && os.Getenv("VERTEXAI_LOCATION") != "" { + return true + } + // Check for Google Cloud project and location + if os.Getenv("GOOGLE_CLOUD_PROJECT") != "" && (os.Getenv("GOOGLE_CLOUD_REGION") != "" || os.Getenv("GOOGLE_CLOUD_LOCATION") != "") { + return true + } + return false +} + // readConfig handles the result of reading a configuration file. func readConfig(err error) error { if err == nil { @@ -549,6 +572,10 @@ func getProviderAPIKey(provider models.ModelProvider) string { if hasAWSCredentials() { return "aws-credentials-available" } + case models.ProviderVertexAI: + if hasVertexAICredentials() { + return "vertex-ai-credentials-available" + } } return "" } @@ -669,6 +696,24 @@ func setDefaultModelForAgent(agent AgentName) bool { return true } + if hasVertexAICredentials() { + var model models.ModelID + maxTokens := int64(5000) + + if agent == AgentTitle { + model = models.VertexAIGemini25Flash + maxTokens = 80 + } else { + model = models.VertexAIGemini25 + } + + cfg.Agents[agent] = Agent{ + Model: model, + MaxTokens: maxTokens, + } + return true + } + return false } -- cgit v1.2.3