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.
verify:Union[bool, str, NoneType]=None, # TLS verification passed to `requests`. A path to a custom CA bundle (e.g., a corporate root CA behind a TLS-intercepting firewall), or `True`/`False`. When `None` (default), verification is left to `requests` (which honors the `REQUESTS_CA_BUNDLE`/`CURL_CA_BUNDLE` env vars, then `certifi`). Also falls back to the `TYPESAFE_CA_BUNDLE` environment variable.
cert:Union[str, Tuple[str, str], NoneType]=None, # Optional client-side certificate for mutual TLS, passed to `requests` as `cert`: either a path to a combined cert+key PEM, or a `(cert_path, key_path)` tuple. Required by some corporate proxies.
**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.