curated_feed.openai_compat ========================== .. py:module:: curated_feed.openai_compat .. autoapi-nested-parse:: The scorer for any endpoint that speaks OpenAI's Chat Completions API. OpenAI itself, OpenRouter, Ollama, vLLM, a confidential-computing proxy: the same class, pointed at a different `base_url`. That is why it is written to what these servers have in common rather than to OpenAI's own API, and four choices follow from it. **Chat Completions, not Responses.** It is the API the other servers copy. **Plain string message content.** The policy documents are the system message and come first, so a server that caches prompt prefixes can reuse them; nothing is marked for caching, because there is no portable way to ask. **The stream is read chunk by chunk** rather than through the SDK's stream helper, which assumes OpenAI's exact chunk shape. Reasoning that a server returns in a field of its own (`reasoning_content`) is ignored; reasoning it returns inline is stripped by `score.parse_response`. **`max_completion_tokens`, not `max_tokens`.** OpenAI's reasoning models refuse the older name; a server that predates the newer one may ignore it, in which case its own default ceiling applies and truncation is still caught by the finish reason. Attributes ---------- .. autoapisummary:: curated_feed.openai_compat.TRUNCATED curated_feed.openai_compat.FILTERED Classes ------- .. autoapisummary:: curated_feed.openai_compat.OpenAICompatibleScorer Functions --------- .. autoapisummary:: curated_feed.openai_compat.build_client Module Contents --------------- .. py:data:: TRUNCATED :value: 'length' .. py:data:: FILTERED :value: 'content_filter' .. py:class:: OpenAICompatibleScorer(*, model: str, max_tokens: int, effort: str = '', base_url: str = '', timeout_seconds: float | None = None, client: openai.OpenAI | None = None) Scores a day of candidates through an OpenAI-compatible endpoint. .. py:attribute:: name :value: 'openai' .. py:attribute:: model .. py:attribute:: max_tokens .. py:attribute:: effort :value: '' .. py:attribute:: usage .. py:method:: generate(candidates: collections.abc.Sequence[curated_feed.models.Candidate], prompt: curated_feed.policy.Prompt, *, feedback: str | None = None) -> str One call: the day's prompt in, the raw response text out. .. py:function:: build_client(*, base_url: str, timeout_seconds: float | None) -> openai.OpenAI A client for `base_url`, or for OpenAI when it is empty. The key is the SDK's to find, in `OPENAI_API_KEY`. Unlike the Anthropic SDK it refuses to build a client without one, so a missing key is reported here rather than on the first call. A local server that needs no key still needs the variable set, to anything. Public because it is the seam a test substitutes, as `claude.build_client`.