feat(v2/ollama): scaffold native /api/chat provider
Adds wire types and a Provider struct that will replace the openaicompat-based Ollama shim with a native /api/chat implementation. Complete and Stream methods are stubs; subsequent commits implement them. Adjusts the existing ollama.go to drop the type alias on openaicompat.Provider (renaming the legacy shim to a temporary internal helper) so the new native Provider type does not collide. Public New() still returns the openaicompat-backed provider until Task 4 swaps it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+18
-7
@@ -9,17 +9,28 @@ import (
|
||||
"gitea.stevedudenhoeffer.com/steve/go-llm/v2/openaicompat"
|
||||
)
|
||||
|
||||
// DefaultBaseURL points at a local Ollama instance with default port.
|
||||
// DefaultBaseURL points at a local Ollama instance with default port. Kept
|
||||
// for the openaicompat-based shim; callers should migrate to
|
||||
// DefaultLocalBaseURL (no /v1 suffix) which targets the native /api/chat
|
||||
// endpoint.
|
||||
const DefaultBaseURL = "http://localhost:11434/v1"
|
||||
|
||||
// Provider is a type alias over openaicompat.Provider.
|
||||
type Provider = openaicompat.Provider
|
||||
|
||||
// New creates a new Ollama provider. An empty baseURL uses DefaultBaseURL.
|
||||
// Ollama ignores the API key; callers may pass "".
|
||||
func New(apiKey, baseURL string) *Provider {
|
||||
// shimNew is the legacy openaicompat-based constructor, retained until the
|
||||
// native provider's Complete/Stream are fully implemented (Task 4 replaces
|
||||
// the public New() with a native-backed constructor).
|
||||
func shimNew(apiKey, baseURL string) *openaicompat.Provider {
|
||||
if baseURL == "" {
|
||||
baseURL = DefaultBaseURL
|
||||
}
|
||||
return openaicompat.New(apiKey, baseURL, openaicompat.Rules{})
|
||||
}
|
||||
|
||||
// New creates a new Ollama provider. An empty baseURL uses DefaultBaseURL.
|
||||
// Ollama ignores the API key; callers may pass "".
|
||||
//
|
||||
// Note: this constructor currently still routes through the openaicompat
|
||||
// shim. Subsequent commits replace the body with a native /api/chat
|
||||
// implementation backed by the Provider type in native.go.
|
||||
func New(apiKey, baseURL string) *openaicompat.Provider {
|
||||
return shimNew(apiKey, baseURL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user