Files
Dolon (Agent)andClaude Fable 5.1 c37e54c5c2 0.2.1: native Ollama dialect on both modes; Home Assistant proven end-to-end
/{mode}/api/{tags,chat,generate,version,show,ps} beside the OpenAI surface.
forge path is a raw proxy (forge is Ollama); the cloud fallback is translated
both ways — NDJSON frames byte-compatible with Ollama's, tool calls round-trip
with synthesised ids, format mapped, think→reasoning_effort (forced to none
with tools: OpenAI rejects the combination on gpt-5.4-mini). Tags never wait
on a model load (HA's list() has a 5 s timeout). local-strict still 503s in
Ollama's error shape; the OpenAI dialect is untouched.

Home Assistant (Lounge, 2026.9.2) configured through its REST config flow and
proven with a real conversation. HA's VLAN cannot reach the k8s ingress, so
it uses forgeway.dmz.lounge.falkvinge.net through the entrance HAProxy
(RFC1918-fenced vhost); the .services. alias needs a pfSense rule from Rick.

22/22 in-cluster checks on both sites. scripts/ha_setup_ollama.py is
idempotent and ends with a real answer; local-smoke-ollama.sh uses the exact
client HA pins.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-18 18:39:31 +00:00

30 lines
852 B
Python

"""Bits shared by the OpenAI and the native-Ollama dialects."""
from __future__ import annotations
from .config import CONFIG
MODE_STRICT = "local-strict"
MODE_OPTIMISTIC = "local-optimistic"
MODES = (MODE_OPTIMISTIC, MODE_STRICT)
def base_headers(mode: str, backend: str, upstream: str | None) -> dict[str, str]:
headers = {
"x-forgeway-service": CONFIG.name,
"x-forgeway-site": CONFIG.site,
"x-forgeway-mode": mode,
"x-forgeway-backend": backend,
}
if upstream:
headers["x-forgeway-upstream"] = upstream
return headers
def strict_unavailable_message() -> str:
return (
f"the local model '{CONFIG.local_model}' is unavailable at this site "
f"({CONFIG.site}). {MODE_STRICT} does not fall back by design; "
f"handle this error or use /{MODE_OPTIMISTIC}."
)