engine: add the ollama System One provider

A third decision-engine provider alongside the local SemIf GGUF and the
remote Winnow server: `engine.provider == "ollama"` talks to ollama's
native `/v1/systemone` route via `semif_agent/ollama_systemone.py`.

It reuses the Winnow DecisionRequest -> choice mapping and the same strict
distribution validation over exactly the requested option ids, and adds
the edges only ollama has:

- no `/health`: `warm()` probes `GET /api/version` + `POST /api/show`,
  which also proves the model is pulled and advertises the `decision`
  capability;
- `engine.ollama.context_tokens: 0` follows the model's real `num_ctx`
  from `/api/show`;
- `keep_alive` rides on the request, criteria descriptions use the ollama
  subset `string | null`, and a choice question needs >= 2 options;
- decision models do not generate text, so `generate()` raises
  `EngineUnavailable` (use `llm.provider == "ollama"` for chat).

Every failure is an `EngineUnavailable` (fatal, like the local engine) and
the engine lock still serializes on the single-slot server.

`cli.build_engine` selects it, the setup interview and `--answers` accept
it, and the install plan skips the engine clone/GGUF/tokenizer for it.
Docs, config.example.json, and tests updated.
This commit is contained in:
gabby committed 2026-11-11 02:57:53 +00:00
1 parent 894a85ec2d
commit addbe53392
12 files changed
+903 -41

No files matched your search

+17
View File
@@ -152,6 +152,23 @@ def test_maximum_config_enables_everything():
assert "llm_api_key" not in secrets
def test_ollama_engine_answers_emit_the_ollama_block():
answers = Answers(
engine_provider="ollama",
ollama_base_url="http://10.0.0.9:11434",
ollama_model="clef-flash",
ollama_api_key="ok",
)
config = build_config(answers, _packs())
assert config["engine"]["provider"] == "ollama"
assert config["engine"]["ollama"]["base_url"] == "http://10.0.0.9:11434"
assert config["engine"]["ollama"]["model"] == "clef-flash"
assert config["engine"]["ollama"]["api_key"] == "!secret engine_ollama_api_key"
assert validate_config(config, _packs()) == []
assert build_plan(answers, _packs())["install_engine"] is False
assert build_secrets(answers)["engine_ollama_api_key"] == "ok"
def test_simplex_gateway_without_pack_still_needs_the_binary():
answers = Answers(gateways=["simplex"])
plan = build_plan(answers, _packs())