Decider
def Decider(
base_url:Optional[str]=None, # Base URL of a decision server (e.g., "http://localhost:11434" for Ollama, "https://api.typesafe.ai" for Jev, "https://api.openai.com" for OpenAI). Falls back to the `TYPESAFE_BASE_URL` environment variable.
model:Optional[str]=None, # Model name/route (e.g., "nimble", "jev-latest", "gpt-6-luna"). Falls back to the `TYPESAFE_DEFAULT_MODEL` environment variable.
api_key:Optional[str]=None, # Bearer API key. Falls back to the `TYPESAFE_API_KEY` environment variable. Use "ollama" (or any placeholder) for a local Ollama server.
protocol:str='systemone', # Wire protocol: "systemone" (legacy TypeSafe/Ollama `/v1/systemone`, the default) or "decisions" (OpenAI `/v1/decisions`). Falls back to the `DECIDER_PROTOCOL` environment variable.
timeout:int=120, # Per-request timeout in seconds.
max_retries:int=3, # Number of retries for retryable statuses (429/5xx) using exponential backoff with jitter.
**kwargs
):Decider sends application state* plus one or more typed questions to a decision model and returns typed, calibrated answers*.
It speaks two interchangeable HTTP contracts, selected via protocol:
"systemone"(default): the legacy TypeSafe/Ollama/v1/systemoneformat. Use this for Ollama (which is/v1/systemone-only) and existing TypeSafe/Jev deployments."decisions": OpenAI’s/v1/decisionsformat (e.g.,gpt-6-luna).
Requests are built for the chosen protocol and responses are normalized to the same SystemOneResponse/_Answer shape, so downstream code (.noul, .choice, .score, .probabilities) is identical either way.