refactor(v2/ollama): drop openaicompat shim, use native provider

The Ollama provider now targets /api/chat directly via the native provider
introduced in the previous commits. Public API is unchanged for callers
that go through llm.Ollama() (and is extended by Task 5's OllamaCloud()
constructor).

DefaultBaseURL was renamed to DefaultLocalBaseURL (without the trailing
/v1 segment used by the OpenAI-compat path). registry.go is updated
correspondingly; no other callers referenced the old name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 18:29:59 +00:00
parent f70c7c0842
commit a3e9982d49
3 changed files with 50 additions and 42 deletions
+31 -9
View File
@@ -1,13 +1,35 @@
package ollama_test
package ollama
import (
"testing"
import "testing"
"gitea.stevedudenhoeffer.com/steve/go-llm/v2/ollama"
)
func TestNew(t *testing.T) {
t.Run("local mode picks default local URL", func(t *testing.T) {
p := New("", "")
if p == nil {
t.Fatal("New returned nil")
}
if p.baseURL != DefaultLocalBaseURL {
t.Errorf("baseURL: want %q, got %q", DefaultLocalBaseURL, p.baseURL)
}
if p.apiKey != "" {
t.Errorf("apiKey: want empty, got %q", p.apiKey)
}
})
func TestNew_NoKeyNeeded(t *testing.T) {
if p := ollama.New("", ""); p == nil {
t.Fatal("New returned nil")
}
t.Run("cloud mode (apiKey set) picks cloud URL", func(t *testing.T) {
p := New("test-key", "")
if p.baseURL != DefaultCloudBaseURL {
t.Errorf("baseURL: want %q, got %q", DefaultCloudBaseURL, p.baseURL)
}
if p.apiKey != "test-key" {
t.Errorf("apiKey: want %q, got %q", "test-key", p.apiKey)
}
})
t.Run("explicit baseURL is preserved", func(t *testing.T) {
p := New("k", "http://example.test:9999")
if p.baseURL != "http://example.test:9999" {
t.Errorf("baseURL not preserved, got %q", p.baseURL)
}
})
}