decision

package
v0.40.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package decision compiles typed decision requests into candidate-scoring prompts and converts the resulting logits into /v1/systemone responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Concentration added in v0.40.12

func Concentration(p []float64) float64

Concentration is System One's default confidence: 1 - H(p)/ln N for N candidates, zero for uniform probabilities and one when a single candidate holds all the mass, or when there is only one.

func Content added in v0.40.12

func Content(raw json.RawMessage) (string, error)

Content renders a System One state or instructions value: a string as is, an object or array as Python-style JSON text.

func ValidateLimits added in v0.40.4

func ValidateLimits(req Request, decisionType string) error

ValidateLimits checks request limits for the selected decision backend.

Types

type Answers

type Answers = orderedmap.Map[string, any]

type Choice

type Choice struct {
	Code        string `json:"code"`
	Value       any    `json:"value"`
	Description any    `json:"description,omitempty"`
}

Choice maps a single-token answer code to a value in the question's schema.

type ChoiceAnswer

type ChoiceAnswer struct {
	Type          string         `json:"type"`
	Choice        string         `json:"choice"`
	Probabilities *Probabilities `json:"probabilities"`
	Confidence    float64        `json:"confidence"`
}

type Compiled

type Compiled struct {
	Request llm.ScoreRequest
	// contains filtered or unexported fields
}

func Compile

func Compile(req Request, encoding string) (*Compiled, error)

func (*Compiled) Answer

func (c *Compiled) Answer(model string, result llm.ScoreResponse) (Response, error)

func (*Compiled) Render

func (c *Compiled) Render(render func([]api.Message) (string, error)) error

Render prepares scoring prompts using the model's system prompt and chat template. The caller must set Request.MaxTokens to the loaded context size before scoring.

type Field

type Field struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Choices     []Choice `json:"choices"`
}

Field is a question's schema as presented to the model.

type Legend

type Legend = orderedmap.Map[string, any]

type NoulAnswer

type NoulAnswer struct {
	Type string  `json:"type"`
	Noul float64 `json:"noul"`
}

type Probabilities

type Probabilities = orderedmap.Map[string, float64]

type Question

type Question = api.SystemOneQuestion

type Questions

type Questions = api.SystemOneQuestions

Questions preserves request order, which determines the order of scored fields. Its zero value is ready to use with Set.

type Request

type Request = api.SystemOneRequest

type Response

type Response struct {
	Model                 string   `json:"model"`
	Answers               *Answers `json:"answers"`
	Usage                 Usage    `json:"usage"`
	PromptEvalCachedCount *int     `json:"prompt_eval_cached_count,omitempty"`
}

type ScoreAnswer

type ScoreAnswer struct {
	Type          string         `json:"type"`
	Score         float64        `json:"score"`
	Legend        *Legend        `json:"legend"`
	Probabilities *Probabilities `json:"probabilities"`
	Confidence    float64        `json:"confidence"`
}

type Usage

type Usage = api.SystemOneUsage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL