diff options
| author | paul@buetow.org <paul@buetow.org> | 2026-02-06 16:15:29 +0200 |
|---|---|---|
| committer | paul@buetow.org <paul@buetow.org> | 2026-02-06 16:15:29 +0200 |
| commit | ed1f11f5e48adb35a3727571ca4154ef5be6d281 (patch) | |
| tree | 8b1dd63e4d1d1112b1ef28b71b61a27df16d9f68 | |
| parent | c8dd76141098a66767883c6eb21dd47ebcf10269 (diff) | |
fix: add missing Anthropic and OpenRouter provider support in config and LSP
- Add Anthropic field merging in config.mergeProviderFields() to properly load AnthropicModel/BaseURL/Temperature from config.toml
- Add anthropic and openrouter cases in lsp.resolveDefaultModel() to prevent fallback to OpenAI defaults
- Update default Anthropic model to valid claude-3-5-sonnet-20240620 (previous 20241022 doesn't exist)
- Update test expectation to match new default model
This fixes the issue where Anthropic provider configuration was ignored, causing LSP to return dummy completions instead of real LLM responses.
Co-authored-by: Cursor <cursoragent@cursor.com>
| -rw-r--r-- | internal/appconfig/config.go | 9 | ||||
| -rw-r--r-- | internal/llm/anthropic.go | 2 | ||||
| -rw-r--r-- | internal/llm/anthropic_test.go | 2 | ||||
| -rw-r--r-- | internal/lsp/handlers_utils.go | 5 |
4 files changed, 15 insertions, 3 deletions
diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index b17c5d4..c9af85e 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -1112,6 +1112,15 @@ func (a *App) mergeProviderFields(other *App) { if other.CopilotTemperature != nil { // allow explicit 0.0 a.CopilotTemperature = other.CopilotTemperature } + if s := strings.TrimSpace(other.AnthropicBaseURL); s != "" { + a.AnthropicBaseURL = s + } + if s := strings.TrimSpace(other.AnthropicModel); s != "" { + a.AnthropicModel = s + } + if other.AnthropicTemperature != nil { // allow explicit 0.0 + a.AnthropicTemperature = other.AnthropicTemperature + } } func getConfigPath() (string, error) { diff --git a/internal/llm/anthropic.go b/internal/llm/anthropic.go index a6c1454..0d87424 100644 --- a/internal/llm/anthropic.go +++ b/internal/llm/anthropic.go @@ -98,7 +98,7 @@ func newAnthropicWithTimeout(baseURL, model, apiKey string, defaultTemp *float64 baseURL = "https://api.anthropic.com/v1" } if strings.TrimSpace(model) == "" { - model = "claude-3-5-sonnet-20241022" + model = "claude-3-5-sonnet-20240620" } if timeoutSec <= 0 { timeoutSec = 30 diff --git a/internal/llm/anthropic_test.go b/internal/llm/anthropic_test.go index 578b536..ffc5021 100644 --- a/internal/llm/anthropic_test.go +++ b/internal/llm/anthropic_test.go @@ -253,7 +253,7 @@ func TestAnthropicClient_DefaultBaseURL(t *testing.T) { func TestAnthropicClient_DefaultModel_Empty(t *testing.T) { c := newAnthropic("https://api.anthropic.com/v1", "", "test-key", nil).(anthropicClient) - if c.defaultModel != "claude-3-5-sonnet-20241022" { + if c.defaultModel != "claude-3-5-sonnet-20240620" { t.Fatalf("expected default model, got '%s'", c.defaultModel) } } diff --git a/internal/lsp/handlers_utils.go b/internal/lsp/handlers_utils.go index 10cc739..6260acd 100644 --- a/internal/lsp/handlers_utils.go +++ b/internal/lsp/handlers_utils.go @@ -31,7 +31,6 @@ type requestSpec struct { index int } - func (r requestSpec) effectiveModel(defaultModel string) string { if m := strings.TrimSpace(r.entry.Model); m != "" { return m @@ -113,6 +112,10 @@ func resolveDefaultModel(cfg appconfig.App, provider string) string { return strings.TrimSpace(cfg.OllamaModel) case "copilot": return strings.TrimSpace(cfg.CopilotModel) + case "anthropic": + return strings.TrimSpace(cfg.AnthropicModel) + case "openrouter": + return strings.TrimSpace(cfg.OpenRouterModel) default: return strings.TrimSpace(cfg.OpenAIModel) } |
