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:
1 parent
894a85ec2d
commit
addbe53392
12 files changed
+903
-41
No files matched your search
+51
-5
@@ -46,7 +46,7 @@ from .packs import SkillPack, pack_enabled
|
||||
#: ``llm``/``codegen`` providers the wizard can emit.
|
||||
PROVIDERS = ("semif", "ollama", "opencode", "openai")
|
||||
#: ``engine`` providers.
|
||||
ENGINE_PROVIDERS = ("semif", "winnow")
|
||||
ENGINE_PROVIDERS = ("semif", "winnow", "ollama")
|
||||
#: New-skill creation modes.
|
||||
AUTHORING_MODES = ("deny", "ask", "allow")
|
||||
|
||||
@@ -71,10 +71,14 @@ class Answers:
|
||||
"""The wizard's answers, and the source of truth for the generated config."""
|
||||
|
||||
# Decision engine.
|
||||
engine_provider: str = "semif" # semif | winnow
|
||||
engine_provider: str = "semif" # semif | winnow | ollama
|
||||
winnow_base_url: str = ""
|
||||
winnow_model: str = ""
|
||||
winnow_api_key: str = ""
|
||||
#: Ollama's native System One route (`engine.ollama`).
|
||||
ollama_base_url: str = ""
|
||||
ollama_model: str = ""
|
||||
ollama_api_key: str = ""
|
||||
|
||||
# New-skill authoring: deny | ask | allow.
|
||||
new_skill_creation: str = "deny"
|
||||
@@ -351,7 +355,7 @@ def run_interview(
|
||||
output(
|
||||
" The decision engine routes every request. It runs locally on the\n"
|
||||
" pinned SemIf 4B GGUF by default (no network), or against a remote\n"
|
||||
" Winnow /v1/systemone server."
|
||||
" Winnow /v1/systemone server or an Ollama System One decision model."
|
||||
)
|
||||
answers.engine_provider = _ask_choice(
|
||||
input_fn,
|
||||
@@ -360,6 +364,7 @@ def run_interview(
|
||||
[
|
||||
("semif", "local SemIf 4B (llama.cpp, pinned GGUF)"),
|
||||
("winnow", "remote Winnow decision server"),
|
||||
("ollama", "remote Ollama System One model (/v1/systemone)"),
|
||||
],
|
||||
1,
|
||||
)
|
||||
@@ -376,6 +381,25 @@ def run_interview(
|
||||
answers.winnow_api_key = _ask_text(
|
||||
input_fn, output, " winnow API key (blank for none)", "", secret=True
|
||||
)
|
||||
elif answers.engine_provider == "ollama":
|
||||
answers.ollama_base_url = _ask_text(
|
||||
input_fn, output, " ollama base URL", "http://127.0.0.1:11434"
|
||||
)
|
||||
model = ""
|
||||
while not model:
|
||||
model = _ask_text(
|
||||
input_fn, output, " ollama System One model (required)"
|
||||
)
|
||||
if not model:
|
||||
output(" engine.ollama.model is required.")
|
||||
answers.ollama_model = model
|
||||
answers.ollama_api_key = _ask_text(
|
||||
input_fn,
|
||||
output,
|
||||
" ollama API key (blank for a local server)",
|
||||
"",
|
||||
secret=True,
|
||||
)
|
||||
|
||||
# 2. Skill authoring.
|
||||
output("")
|
||||
@@ -399,7 +423,15 @@ def run_interview(
|
||||
answers.new_skill_creation = mode
|
||||
if mode != "deny":
|
||||
output("")
|
||||
_collect_llm(input_fn, output, answers, label="llm", allow_semif=True)
|
||||
# The Ollama System One decision model does not generate text, so it
|
||||
# cannot back the small `llm` task; only a real endpoint can.
|
||||
_collect_llm(
|
||||
input_fn,
|
||||
output,
|
||||
answers,
|
||||
label="llm",
|
||||
allow_semif=answers.engine_provider != "ollama",
|
||||
)
|
||||
output("")
|
||||
_collect_llm(input_fn, output, answers, label="codegen", allow_semif=False)
|
||||
|
||||
@@ -529,6 +561,14 @@ def build_config(answers: Answers, packs: Sequence[SkillPack]) -> dict:
|
||||
_set_secret_or_literal(
|
||||
winnow, "api_key", answers.winnow_api_key, "engine_winnow_api_key"
|
||||
)
|
||||
elif answers.engine_provider == "ollama":
|
||||
ollama = engine.setdefault("ollama", {})
|
||||
if answers.ollama_base_url:
|
||||
ollama["base_url"] = answers.ollama_base_url
|
||||
ollama["model"] = answers.ollama_model
|
||||
_set_secret_or_literal(
|
||||
ollama, "api_key", answers.ollama_api_key, "engine_ollama_api_key"
|
||||
)
|
||||
|
||||
# Authoring mode.
|
||||
config["new_skill_creation"] = answers.new_skill_creation
|
||||
@@ -613,6 +653,8 @@ def build_secrets(answers: Answers) -> dict:
|
||||
secrets: dict[str, str] = {}
|
||||
if answers.engine_provider == "winnow" and answers.winnow_api_key:
|
||||
secrets["engine_winnow_api_key"] = answers.winnow_api_key
|
||||
if answers.engine_provider == "ollama" and answers.ollama_api_key:
|
||||
secrets["engine_ollama_api_key"] = answers.ollama_api_key
|
||||
if answers.llm_provider != "semif" and answers.llm_api_key:
|
||||
secrets["llm_api_key"] = answers.llm_api_key
|
||||
if answers.codegen_api_key:
|
||||
@@ -834,7 +876,11 @@ def _print_summary(answers: Answers, output: Callable[[str], None]) -> None:
|
||||
+ (
|
||||
"local SemIf 4B"
|
||||
if answers.engine_provider == "semif"
|
||||
else f"remote Winnow ({answers.winnow_model or '?'})"
|
||||
else (
|
||||
f"remote Winnow ({answers.winnow_model or '?'})"
|
||||
if answers.engine_provider == "winnow"
|
||||
else f"remote Ollama System One ({answers.ollama_model or '?'})"
|
||||
)
|
||||
)
|
||||
)
|
||||
output(f" authoring: {answers.new_skill_creation}")
|
||||
|
||||
Reference in new issue
Block a user