summaryrefslogtreecommitdiffhomepage
path: root/internal/config
diff options
context:
space:
mode:
authorJay V <[email protected]>2025-05-21 15:01:25 -0400
committerJay V <[email protected]>2025-05-21 15:01:25 -0400
commit9049295cc961b250be6144585dde322e778534d7 (patch)
treec8a2f09ed6cea54eb9587243eb7dbe298fef1b20 /internal/config
parent4526b14b17dc49f3ef4f3b1a1d02eff5c6b6b59f (diff)
parentdff8e77eb6d1709fa1ddeb52d0d9c19afd13d385 (diff)
downloadopencode-9049295cc961b250be6144585dde322e778534d7.tar.gz
opencode-9049295cc961b250be6144585dde322e778534d7.zip
Merge branch 'dev' into docs
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index f9aba238d..70c05ac02 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -73,6 +73,12 @@ type TUIConfig struct {
CustomTheme map[string]any `json:"customTheme,omitempty"`
}
+// ShellConfig defines the configuration for the shell used by the bash tool.
+type ShellConfig struct {
+ Path string `json:"path,omitempty"`
+ Args []string `json:"args,omitempty"`
+}
+
// Config is the main configuration structure for the application.
type Config struct {
Data Data `json:"data"`
@@ -85,6 +91,7 @@ type Config struct {
DebugLSP bool `json:"debugLSP,omitempty"`
ContextPaths []string `json:"contextPaths,omitempty"`
TUI TUIConfig `json:"tui"`
+ Shell ShellConfig `json:"shell,omitempty"`
}
// Application constants
@@ -235,6 +242,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 +307,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 +344,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 +579,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 +703,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
}