Documentation
¶
Overview ¶
Package decision holds virtual models for the decisions endpoint (POST {base}/decisions, see .design/decision-protocol.md): typed questions about a piece of state in, calibrated answers out.
The wire shape follows Jev, the only published decisions API (OpenAI's is unpublished): a request carries "model", "state" and "questions" keyed by caller-chosen ids; each question has a "type" and "criteria":
choice criteria: {"option": "description", ...} -> choice + probabilities + confidence
score criteria: ["lowest level", ..., "highest"] -> score + legend + probabilities + confidence
noul (instructions only) -> noul (probability the statement is true)
The response is {"model", "answers": {id: {"type", ...}}, "usage"}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func First ¶
First always picks index 0: the first choice option, the lowest score level, and "true" for noul. Predictable for routing demos and dry-runs.
func RegisterDefaults ¶
func RegisterDefaults(r *Registry)
RegisterDefaults registers the user-facing decision demo models:
decision-first always the first option (confidence 1) decision-stable input-hashed choice, reproducible (confidence 0.8)
Types ¶
type Chooser ¶
Chooser picks an index in [0, n) for one question. input is the request's state and id the question id, so a chooser can be input-stable but independent of the model name.
type MockModel ¶
type MockModel struct {
vmodel.BaseMockModel
// contains filtered or unexported fields
}
MockModel is a deterministic, in-memory decision model.
func NewMockModel ¶
func NewMockModel(cfg *MockModelConfig) *MockModel
NewMockModel builds a MockModel from cfg.
type MockModelConfig ¶
type MockModelConfig struct {
ID string
Name string
Description string
Choose Chooser
// Confidence is the probability mass on the picked option/level (and the
// noul probability when it picks "true"); the rest is split evenly. Zero
// means 1 (certain).
Confidence float64
}
MockModelConfig configures a MockModel.
type Registry ¶
type Registry = vmodel.GenericRegistry[VirtualModel]
Registry holds decision virtual models.
type RequestError ¶
type RequestError struct{ Message string }
RequestError marks a client-side problem (HTTP 400) as opposed to a model failure.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
type VirtualModel ¶
type VirtualModel interface {
vmodel.VirtualModel
// HandleDecision answers one decisions request body (already known to be
// valid JSON) with a JSON response body. An unanswerable request returns
// *RequestError.
HandleDecision(body []byte) ([]byte, error)
}
VirtualModel is the decisions sub-interface: the base identity plus one request/response method over JSON.