Rename providers/ollama to providers/local

Ollama is one local-model server among several (LM Studio, llama.cpp's
server, vLLM, ...) that all speak the same OpenAI-compatible shape —
naming the package (and provider name downstream) after one of them
was misleading. Same constructor, same default endpoint (Ollama's,
being the most common), just generically named: NewLocalProvider.

This renames a package published minutes ago in v0.3.8 with no other
known consumers yet, so no compatibility shim is kept.
This commit is contained in:
sausheong committed 2026-09-07 13:27:58 +08:00
1 parent 3b5aadb31f
commit 50b791d3b6
5 files changed
+45 -43

No files matched your search

+8 -8
View File
@@ -87,8 +87,8 @@ a lot. The package is optimized for the use cases above, not these.
hardened in 1.25. Older toolchains will fail at `go build`.
- **An LLM API key**, depending on which provider(s) you wire in:
`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, Google ADC for Gemini, or a
LiteLLM/OpenRouter key for those aggregators. For local models,
`ollama.NewOllamaProvider` needs no key at all.
LiteLLM/OpenRouter key for those aggregators. For local models
(Ollama, LM Studio, etc.), `local.NewLocalProvider` needs no key at all.
- **Optional: an MCP server** for `tools/mcp` integrations (any
binary that speaks the Model Context Protocol — `npx
@modelcontextprotocol/server-filesystem`, etc.).
@@ -119,11 +119,11 @@ github.com/sausheong/harness/
│ # MemoryProvider/SkillProvider/KnowledgeGraph interfaces
├── providers/
│ ├── anthropic/ # Anthropic LLMProvider (with prompt caching)
│ ├── openai/ # OpenAI / OpenAI-compatible / local Ollama
│ ├── openai/ # OpenAI / OpenAI-compatible
│ ├── gemini/ # Google Gemini via google.golang.org/genai
│ ├── litellm/ # Self-hosted LiteLLM proxy (OpenAI-compatible)
│ ├── openrouter/ # OpenRouter aggregator (OpenAI-compatible)
│ └── ollama/ # Local Ollama server (OpenAI-compatible, no API key)
│ └── local/ # Local model server — Ollama, LM Studio, etc. (OpenAI-compatible, no API key)
└── tools/ # Batteries-included concrete tools (each importable separately)
├── file/ # read_file (with vision), write_file, edit_file
├── bash/ # bash (with ExecPolicy: deny | allowlist | full)
@@ -316,10 +316,10 @@ Deliberately not in scope (numbers from the same conceptual list):
auto-refresh comes for free. Call `Runtime.Close()` to release
sessions.
- **Six providers, one interface.** Anthropic, OpenAI, Gemini, LiteLLM,
OpenRouter, and Ollama ship built-in — LiteLLM, OpenRouter, and Ollama
cost none of that ~300 LOC each, since all three are thin constructors
over the existing OpenAI-compatible path. Adding a genuinely new wire
format is implementing `llm.Provider` (~300 LOC).
OpenRouter, and local (Ollama, LM Studio, etc.) ship built-in — LiteLLM,
OpenRouter, and local cost none of that ~300 LOC each, since all three
are thin constructors over the existing OpenAI-compatible path. Adding
a genuinely new wire format is implementing `llm.Provider` (~300 LOC).
See [`developer.md`](./developer.md) for a step-by-step guide to
building agents on top of Harness, including diagrams of the
+2 -2
View File
@@ -60,7 +60,7 @@ The four mandatory pieces:
* **`llm.LLMProvider`** (in `RuntimeInputs.Provider`) — a streaming
chat client (Anthropic / OpenAI / Gemini / LiteLLM / OpenRouter /
Ollama, or your own).
local (Ollama, LM Studio, etc.), or your own).
* **`tool.Registry`** (in `RuntimeInputs.Tools`) — the tools the LLM
may invoke. Each tool implements `tool.Tool`.
* **`session.Session`** (in `RuntimeInputs.Session`) — append-only
@@ -392,7 +392,7 @@ Each provider has its own constructor. All return an `llm.LLMProvider`.
| Gemini | `gemini.NewGeminiProvider(ctx, apiKey)` | takes `context.Context` |
| LiteLLM | `litellm.NewLiteLLMProvider(apiKey, baseURL)` | `baseURL` required (self-hosted) |
| OpenRouter | `openrouter.NewOpenRouterProvider(apiKey, baseURL)` | `baseURL == ""` → OpenRouter's public endpoint |
| Ollama | `ollama.NewOllamaProvider(baseURL)` | `baseURL == ""` → `http://localhost:11434/v1`; no API key |
| Local | `local.NewLocalProvider(baseURL)` | `baseURL == ""` → `http://localhost:11434/v1` (Ollama's default; override for LM Studio, llama.cpp, vLLM, etc.); no API key |
The provider you pass on `RuntimeInputs.Provider` only needs to match the
provider prefix in `AgentSpec.Model` — `runtime.BuildRuntime` parses
+28
View File
@@ -0,0 +1,28 @@
// Package local provides an llm.LLMProvider for a locally-served model —
// Ollama, LM Studio, llama.cpp's server, vLLM, or anything else exposing
// an OpenAI-compatible endpoint on the caller's own machine or network.
// Like providers/litellm and providers/openrouter, this adds no new
// request/stream-translation code of its own — it's a thin constructor
// around harness's existing OpenAI-compatible support.
package local
import "github.com/sausheong/harness/providers/openai"
// DefaultBaseURL is used when NewLocalProvider is called with an empty
// baseURL. It's Ollama's endpoint specifically — the most common local
// server — but any other one works the same way via an explicit baseURL.
const DefaultBaseURL = "http://localhost:11434/v1"
// NewLocalProvider returns an OpenAI-compatible provider pointed at
// baseURL, or DefaultBaseURL when baseURL is empty. No API key is
// needed — local servers generally don't authenticate requests.
// kind="local" suppresses reasoning_effort, since locally-served models
// don't uniformly support it, and keeps retryable-error classification
// from treating a down local server the way it would a hosted API
// outage (see llm/retry.go).
func NewLocalProvider(baseURL string) *openai.OpenAIProvider {
if baseURL == "" {
baseURL = DefaultBaseURL
}
return openai.NewOpenAIProviderWithKind("", baseURL, "local")
}
@@ -1,4 +1,4 @@
package ollama
package local
import (
"context"
@@ -15,9 +15,9 @@ func TestDefaultBaseURL(t *testing.T) {
require.Equal(t, "http://localhost:11434/v1", DefaultBaseURL)
}
// TestNewOllamaProvider_HitsGivenBaseURL confirms a custom baseURL
// TestNewLocalProvider_HitsGivenBaseURL confirms a custom baseURL
// overrides the default and is actually what the provider talks to.
func TestNewOllamaProvider_HitsGivenBaseURL(t *testing.T) {
func TestNewLocalProvider_HitsGivenBaseURL(t *testing.T) {
var hit bool
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hit = true
@@ -26,7 +26,7 @@ func TestNewOllamaProvider_HitsGivenBaseURL(t *testing.T) {
}))
t.Cleanup(srv.Close)
p := NewOllamaProvider(srv.URL + "/v1")
p := NewLocalProvider(srv.URL + "/v1")
stream, err := p.ChatStream(context.Background(), llm.ChatRequest{SystemPrompt: "hi"})
require.NoError(t, err)
for range stream {
@@ -34,13 +34,13 @@ func TestNewOllamaProvider_HitsGivenBaseURL(t *testing.T) {
require.True(t, hit, "provider did not hit the configured baseURL")
}
// TestNewOllamaProvider_EmptyBaseURLDoesNotPanic confirms the empty ->
// TestNewLocalProvider_EmptyBaseURLDoesNotPanic confirms the empty ->
// DefaultBaseURL fallback path constructs a usable provider (the actual
// outbound host isn't inspectable from outside the openai package —
// OpenAIProvider's client config is unexported — so this checks the
// fallback doesn't panic or return nil, and DefaultBaseURL's own value
// is asserted separately above).
func TestNewOllamaProvider_EmptyBaseURLDoesNotPanic(t *testing.T) {
p := NewOllamaProvider("")
func TestNewLocalProvider_EmptyBaseURLDoesNotPanic(t *testing.T) {
p := NewLocalProvider("")
require.NotNil(t, p)
}
-26
View File
@@ -1,26 +0,0 @@
// Package ollama provides an llm.LLMProvider for a local Ollama server
// (or any other local server sharing Ollama's OpenAI-compatible endpoint
// shape — LM Studio, llama.cpp's server, vLLM). Like providers/litellm
// and providers/openrouter, this adds no new request/stream-translation
// code of its own — it's a thin constructor around harness's existing
// OpenAI-compatible support.
package ollama
import "github.com/sausheong/harness/providers/openai"
// DefaultBaseURL is Ollama's local OpenAI-compatible endpoint, used when
// NewOllamaProvider is called with an empty baseURL.
const DefaultBaseURL = "http://localhost:11434/v1"
// NewOllamaProvider returns an OpenAI-compatible provider pointed at
// baseURL, or DefaultBaseURL when baseURL is empty. No API key is
// needed — Ollama doesn't authenticate requests. kind="local" suppresses
// reasoning_effort, since locally-served models don't uniformly support
// it, and keeps retryable-error classification from treating a down
// local server the way it would a hosted API outage (see llm/retry.go).
func NewOllamaProvider(baseURL string) *openai.OpenAIProvider {
if baseURL == "" {
baseURL = DefaultBaseURL
}
return openai.NewOpenAIProviderWithKind("", baseURL, "local")
}