ollama

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ollama provides a clikit Act backend that talks to a local ollama daemon over HTTP. Importing it is the opt-in: the clikit core never pulls in a model runner on its own, and nothing here installs or launches a daemon — consumers bring their own ollama (and pull their own weights).

Index

Constants

View Source
const DefaultEndpoint = "http://127.0.0.1:11434"

DefaultEndpoint is the local ollama HTTP API. Loopback by design — nothing here reaches the network.

View Source
const DefaultModel = "qwen2.5:3b"

DefaultModel is the model a Commander uses unless overridden. A 3B instruct model is the sweet spot for facet classification: 0.5–1.5B models are too weak (they return uniform, undifferentiated picks), while 3B differentiates well and stays small enough for a resident daemon to hold cheaply. Warm latency on a short prompt is ~1–2s CPU-only, sub-second on a GPU; keep the classifier's output terse, since on CPU each generated token costs ~60ms. Configure per host via Commander.Model.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commander

type Commander struct {
	Endpoint string           // ollama base URL; defaults to DefaultEndpoint
	Model    string           // local model tag; defaults to DefaultModel
	System   clikit.DocCorpus // system prompt: the classifier's role/identity
	// KeepAlive controls how long ollama holds the model resident after this
	// call (e.g. "30m", or "-1" to never unload). Empty uses the daemon default.
	KeepAlive string
	// Wrap, if set, turns the raw user prompt into the message actually sent —
	// hosts use it to frame the task as classification and embed the prompt as
	// inert data (see the omp backend's Commander.Wrap).
	Wrap func(prompt string) string
	// Client, if set, is used for the HTTP call (tests inject a stub); otherwise
	// http.DefaultClient. The request carries the Propose context, so cancelling
	// it aborts the call.
	Client *http.Client
	// contains filtered or unexported fields
}

Commander is a local-model Act backend: it POSTs to a resident ollama daemon and streams the model's output so the box shows it working, then Parse turns the completed output into a validated Action set. Unlike the omp backend it makes no subprocess and needs no auth — the model runs locally and stays warm, so there is no process-spawn or auth latency per call. It depends only on net/http.

The classification prompt is neutral by design: it scopes a task to what the task objectively needs, never to any one operator's habits. Deliberate over-provisioning ("max everything for this one") stays a manual pick in the host tool, so the model's suggestion is always a sensible baseline.

func NewCommander

func NewCommander(system clikit.DocCorpus) Commander

NewCommander builds a Commander with the default endpoint, local model, and the given system prompt (which must instruct the model to answer with a JSON object of settings). The model starts unloaded — the user loads it explicitly (see clikit.Loadable).

func (Commander) Load

func (o Commander) Load(ctx context.Context) error

Load pins the model resident (keep_alive -1) so subsequent suggestions are warm; the first load pulls the weights into RAM and can take a while on CPU.

func (Commander) Loaded

func (o Commander) Loaded(ctx context.Context) (bool, error)

Loaded reports whether the model is resident right now, per the daemon's live process list (/api/ps) — the source of truth, independent of the intent flag.

func (Commander) Parse

func (o Commander) Parse(output string) ([]clikit.Action, error)

Parse turns the model's completed output into proposed changes, reusing the same tolerant JSON extraction as the omp backend.

func (Commander) Propose

func (o Commander) Propose(ctx context.Context, prompt string) (<-chan string, error)

Propose POSTs the (wrapped) prompt to ollama and streams the model's output as it arrives. The channel closes when the model is done or the context is cancelled (which aborts the HTTP request).

func (Commander) Unload

func (o Commander) Unload(ctx context.Context) error

Unload evicts the model from memory (keep_alive 0), freeing its RAM.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL