Documentation
¶
Overview ¶
Package qualitygate is the model stage that reads an item's title and opening, before anyone reads it whole, and answers its genre, domains, themes, a 1 to 10 quality estimate, a one-line idea, a verdict and a guess at its side. Its prompt and answer schema are prompts.Quality.
The service queues an item's quality task in the write that ends its scan, where no tag or rule places it, so a rule placed before the model always wins. A worker holding a model port runs the task. It stores the dispatch in the write that ends its lease, and follows the dispatch on each later claim until the run answers, so the task holds no worker slot while the run waits. That dispatch-once protocol is modelstage's. When the task ends done, the service appends the gate's decision: pass, drop where the model dropped the item at or above DropFloor, or review. The side gate then reads that decision and the side guess.
The arm asks the same prompt of another model, over items a person placed from review, and keeps each answer at its own stage. It decides nothing, so `ingestion gates agreement` can set two models' answers side by side.
Index ¶
- Constants
- func ArmReplayable(st *store.Store) server.Replayable
- func DecideAfterAnswer(ctx context.Context, tx *store.Tx, task store.Task) error
- func Decision(a Answer, run string) store.Decision
- func NewArmHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, ...) worker.Handler
- func NewHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, ...) worker.Handler
- func QueueAfterScan(ctx context.Context, tx *store.Tx, task store.Task) error
- func Replayable(st *store.Store) server.Replayable
- type Answer
Constants ¶
const ( // DefaultModel and DefaultEffort are what the gate's run is asked for // where config names neither. The gate reads an opening and answers a // short schema, so the smallest model does it. DefaultModel = "haiku" DefaultEffort = "medium" )
const ( // Capability is the capability of every quality task. Capability = store.StageQuality // ArmCapability is the capability of every arm task: the gate's prompt // asked of the model that the task names, as a measurement. ArmCapability = store.StageQualityArm // Producer names the quality gate's outputs, whose version is the // prompt's. Producer = "quality-gate" // DropFloor is the confidence at or above which the model's drop drops // an item. Below it, the item waits in review. DropFloor = 0.8 )
const ( AnswerPass = "pass" AnswerDrop = "drop" AnswerUnsure = "unsure" )
The verdicts the model answers.
const ( CausePass = "pass" CauseDrop = "drop" CauseUnsure = "unsure" CauseBelowDropFloor = "below-drop-floor" )
Causes of the gate's decision.
const VerdictPass = "pass"
VerdictPass is the gate's decision that an item earns a full read. Its drop and review are the side gate's verdicts of the same names.
Variables ¶
This section is empty.
Functions ¶
func ArmReplayable ¶
func ArmReplayable(st *store.Store) server.Replayable
ArmReplayable is the arm as a replay runs it: the gate's prompt, asked of the model that the replay names, over each labeled item that the gate answered under that prompt. Each answer is kept at the arm's own stage beside the gate's, and appends no decision, so the item's phase, placement and delivery stay as they are. One arm answers an item under each prompt.
func DecideAfterAnswer ¶
DecideAfterAnswer appends the gate's decision in the write that ends the item's quality task done, from the answer of its newest done output. It appends nothing where the newest decision already came from that run.
func Decision ¶
Decision is the gate's decision on an answer that run gave: pass, drop where the model dropped the item at or above DropFloor, and review where it was unsure or its drop fell below the floor.
func NewArmHandler ¶
func NewArmHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, log *slog.Logger) worker.Handler
NewArmHandler is the worker handler that runs the arm's tasks the same way. Each asks for the model that its task names, at the gate's effort.
func NewHandler ¶
func NewHandler(port modelport.Port, client *worker.Client, settings modelstage.Settings, log *slog.Logger) worker.Handler
NewHandler is the worker handler that runs the gate through port under modelstage's dispatch-once protocol, reading each task's parse through client.
func QueueAfterScan ¶
QueueAfterScan queues the item's quality task in the write that ends its scan done, where the scan read the newest parse, no tag or rule places the item, and the item never held a quality task. A connector's first fill holds it past the first item. A later scan queues none. The gate runs again only through a replay that a person confirms, or through `tasks retry` on a failed task.
func Replayable ¶
func Replayable(st *store.Store) server.Replayable
Replayable is the gate as a replay runs it again, such as with a new prompt, over the items it judges. The replay first answers how many items it would run on and the median tokens by kind of the stage's newest stored runs, times that count, and queues only once a person confirms.
Its PlacedByPerson runs the gate over the labeled items, which the gate otherwise never judges again. Its answer and its decision are kept, and the side gate leaves the placement, its delivery and its model read as they are, because a person's placement is final.
Types ¶
type Answer ¶
type Answer struct {
Genre string `json:"genre"`
Domains []string `json:"domains"`
Themes []string `json:"themes"`
Quality int `json:"quality"`
Idea string `json:"idea"`
Verdict string `json:"verdict"`
VerdictConfidence float64 `json:"verdict_confidence"`
Side string `json:"side"`
SideConfidence float64 `json:"side_confidence"`
}
Answer is the model's answer, as prompts/quality/answer.schema.json holds it. ReadAnswer decodes it.
func DecodeAnswer ¶ added in v0.25.0
func DecodeAnswer(raw json.RawMessage) (Answer, error)
DecodeAnswer decodes a stored answer without checking it against this build's schema, so a CLI reads a service of another release. The schema counts 7.0 as an integer, so quality decodes as a number and is kept whole.
func ReadAnswer ¶
func ReadAnswer(raw json.RawMessage) (Answer, error)
ReadAnswer checks raw against the answer's schema and decodes it.