"""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}." )