summaryrefslogtreecommitdiff
path: root/internal/llm/ollama.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-11 00:21:50 +0300
committerPaul Buetow <paul@buetow.org>2026-06-11 00:21:50 +0300
commit2b2f4110da53a03742faff89cdec17c55e091a90 (patch)
treeb0c355f2470dbf984f373e0dcc45f12d00960a98 /internal/llm/ollama.go
parent1f3ae20a9830fd776f6ef3c11b4c198154b8205f (diff)
llm: return concrete client types from provider constructors
Follow the Go idiom "return concrete types, accept interfaces": the provider constructors newOpenAI, newAnthropic, newOpenRouter, newOllama and their *WithTimeout variants now return their concrete *Client value types instead of the Client interface. The provider factories registered in the registry still return Client, so NewFromConfig and the registry keep working unchanged. Updated comments to explain the reasoning, dropped the now-redundant type assertions in tests, and switched the anthropic Streamer-capability tests to assert via an explicit Client interface value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/llm/ollama.go')
-rw-r--r--internal/llm/ollama.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/llm/ollama.go b/internal/llm/ollama.go
index 98e5dce..d8f911f 100644
--- a/internal/llm/ollama.go
+++ b/internal/llm/ollama.go
@@ -61,11 +61,14 @@ func ollamaProviderFactory(cfg Config, keys ProviderKeys) (Client, error) {
// Constructor (kept among the first functions by convention).
// apiKey may be empty for local Ollama; pass a non-empty key for Ollama Cloud.
-func newOllama(baseURL, model string, defaultTemp *float64, apiKey string) Client {
+// Following the Go idiom "return concrete types, accept interfaces", this
+// returns ollamaClient directly; the provider registry wraps it back into a
+// Client at registration time.
+func newOllama(baseURL, model string, defaultTemp *float64, apiKey string) ollamaClient {
return newOllamaWithTimeout(baseURL, model, apiKey, defaultTemp, 0)
}
-func newOllamaWithTimeout(baseURL, model, apiKey string, defaultTemp *float64, timeoutSec int) Client {
+func newOllamaWithTimeout(baseURL, model, apiKey string, defaultTemp *float64, timeoutSec int) ollamaClient {
// Defaults target Ollama Cloud (ollama.ai); a local server is opted into
// by setting base_url = "http://localhost:11434" (or HEXAI_OLLAMA_BASE_URL)
// and an appropriate model.