summaryrefslogtreecommitdiffhomepage
path: root/internal/config
diff options
context:
space:
mode:
authormineo <[email protected]>2025-05-16 03:25:21 +0900
committeradamdottv <[email protected]>2025-05-15 13:35:06 -0500
commit87237b6462b9dfd379b22e69712e8dc516afad9d (patch)
treeffce4fab0e86ad05684738834c52de2f7f1f7a76 /internal/config
parent5f5f9dad877300bab3fe5442ea141551ba89421b (diff)
downloadopencode-87237b6462b9dfd379b22e69712e8dc516afad9d.tar.gz
opencode-87237b6462b9dfd379b22e69712e8dc516afad9d.zip
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
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go45
1 files changed, 45 insertions, 0 deletions
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
}