/* systemone.h -- POST /v1/systemone: LiquidAI d1's decisions, a distribution read off one position. * * d1 is a decision model. It is given a state (text, any JSON value, pictures, or a mix) and named * questions; each answer is a softmax over a few tokens at the position right after the assistant * header: `yes` / `no` for a noul, one code per option for a choice, one digit per level for a * score. Nothing is generated. The API and prompt are the model's own (prompt.py and api.py on the * Hub). The engine sees only Request::token_scores: read these ids' raw logits at the prompt's last * position. * * Served only when the container declares d1 (`decision.type` = `d1`, set at convert with * `--set decision.type=d1`); the HF config does not declare it. */ #pragma once #include "oai.h" #include #include #include namespace rad { namespace server { struct DecisionQuestion { std::string name, type; /* type: noul | choice | score */ /* One entry per answer, in response order: "true"/"false", the option names, or the levels * "0".."n-1". */ std::vector labels; std::vector legend; /* score: each level's description */ /* The ids read at the answer slot, and per answer the indices of its spellings among them; * an answer scores as its best spelling. */ std::vector candidates; std::vector> groups; std::vector tokens; /* the whole prompt */ }; struct DecisionRequest { std::vector questions; /* The pictures, placed in the shared head of every question's prompt. */ std::shared_ptr media; /* How many leading tokens every question's prompt shares: the state, tokenised once. 0 for * a single question, which d1 tokenises as one text. */ int32_t trunk = 0; /* Input tokens as d1 counts them: the shared head once plus each question's tail. */ int64_t input_tokens = 0; }; /* Parse and render. `max_ctx` bounds every question's prompt (one position stays free for the * token the request samples and discards). */ int parse_decision_request(const std::string& body, const OaiDeps& d, const OaiLimits& lim, const std::string& model_id, DecisionRequest* out, ApiError* err); /* One question's answer from its candidates' raw logits: each answer scores its best spelling and * a softmax over the answers is the distribution. A non-finite logit is an error. */ int decision_answer(const DecisionQuestion& q, const std::vector& logits, json* out, ApiError* err); } /* namespace server */ } /* namespace rad */