Skip to content

fix: tweak the logic to fix config merging #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025

Conversation

rekram1-node
Copy link
Contributor

Should fix: #71

This fixes issues with merging configurations. Previously, If I didn't set an environment variable for say anthropic, but I had in my configuration file the following:

{
  "providers": {
      "anthropic": {
        "apiKey": "***",
        "disabled": false
      }
  }
}

The I would get "Error: model not supported"

These changes ensure that we read in the file configuration before setting defaults so a user won't have to explicitly configure every agent in their configuration file.

Also, setProviderDefaults will NOT override settings already configured because viper will check if the values have been set or not.

// Anthropic configuration
if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey != "" {
if viper.Get("providers.anthropic.apiKey") != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set these values right at the beginning of setProviderDefaults

@kujtimiihoxha
Copy link
Collaborator

@rekram1-node I just merged another provider maybe we can update this to include all providers correctly now ?

@rekram1-node
Copy link
Contributor Author

@kujtimiihoxha added openrouter

@kujtimiihoxha
Copy link
Collaborator

@rekram1-node thanks

@kujtimiihoxha kujtimiihoxha merged commit e14de7a into opencode-ai:main May 1, 2025
kujtimiihoxha pushed a commit to PhantomReactor/opencode that referenced this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

won't launch with default configs
2 participants