From 3bd295d60ecbb30852e8bcf672b1befd93eb9bff Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 2 Mar 2026 13:33:08 +0200 Subject: llm: add provider registry and self-registration factories (task 410) --- internal/llm/anthropic.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'internal/llm/anthropic.go') diff --git a/internal/llm/anthropic.go b/internal/llm/anthropic.go index 0d87424..82d8b8a 100644 --- a/internal/llm/anthropic.go +++ b/internal/llm/anthropic.go @@ -86,6 +86,23 @@ var ( _ Streamer = (*anthropicClient)(nil) ) +func init() { + RegisterProvider("anthropic", anthropicProviderFactory) +} + +func anthropicProviderFactory(cfg Config, keys ProviderKeys) (Client, error) { + if strings.TrimSpace(keys.AnthropicAPIKey) == "" { + return nil, errors.New("missing ANTHROPIC_API_KEY for provider anthropic") + } + return newAnthropicWithTimeout( + cfg.AnthropicBaseURL, + cfg.AnthropicModel, + keys.AnthropicAPIKey, + withDefaultTemperature(cfg.AnthropicTemperature, 0.2), + cfg.RequestTimeout, + ), nil +} + // Constructor // newAnthropic constructs an Anthropic client using explicit configuration values. // The apiKey may be empty; calls will fail until a valid key is supplied. -- cgit v1.2.3