fix(ai): use configured provider's default model when no model set
When a user configures only Ollama (or any single provider) via the multi-provider UI without explicitly selecting a model, GetModel() now returns that provider's default model instead of falling back to the legacy Provider field which defaults to "anthropic". This fixes "API key is required for anthropic" errors when enabling AI with only Ollama configured. Related to #847
This commit is contained in:
parent
609aa98030
commit
b6cc57590a
1 changed files with 18 additions and 0 deletions
|
|
@ -286,6 +286,24 @@ func (c *AIConfig) GetModel() string {
|
|||
if c.Model != "" {
|
||||
return c.Model
|
||||
}
|
||||
|
||||
// If only one provider is configured, use its default model
|
||||
// This handles the case where user configures Ollama but doesn't explicitly select a model
|
||||
configured := c.GetConfiguredProviders()
|
||||
if len(configured) == 1 {
|
||||
switch configured[0] {
|
||||
case AIProviderAnthropic:
|
||||
return DefaultAIModelAnthropic
|
||||
case AIProviderOpenAI:
|
||||
return DefaultAIModelOpenAI
|
||||
case AIProviderOllama:
|
||||
return DefaultAIModelOllama
|
||||
case AIProviderDeepSeek:
|
||||
return DefaultAIModelDeepSeek
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to legacy Provider field for backwards compatibility
|
||||
switch c.Provider {
|
||||
case AIProviderAnthropic:
|
||||
return DefaultAIModelAnthropic
|
||||
|
|
|
|||
Loading…
Reference in a new issue