modelread

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelread is the model stage that reads an item whole under its read decision's lens, and answers the item's note with a summary, a suggestion sentence, or both. Its prompt and answer schema are prompts.ModelRead, one prompt for each lens.

The read gate queues an item's model read in the write that appends a read decision whose verdict is model, unless the item holds a read that answers the decision's note. It withdraws a queued one where a later decision reads the item otherwise. The task carries that decision's lens and note. A worker holding a model port and the scanner runs it through modelstage's dispatch-once protocol. Before the answer is kept, the scanner reads its suggestion sentence. The output holds the findings and their spans beside the answer, so the sentence never travels without them. The summary is kept on the output, and no delivery carries it.

Index

Constants

View Source
const (
	// Capability is the capability of every model read's task.
	Capability = store.StageModelRead
	// Producer names the model read's outputs, whose version is the prompt's
	// under the output's lens.
	Producer = "model-read"
	// DefaultModel and DefaultEffort are what the read's run is asked for
	// where config names neither.
	DefaultModel  = "haiku"
	DefaultEffort = "medium"
)

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(port modelport.Port, client *worker.Client, contexts lens.Readers, scanner Scanner, settings modelstage.Settings,
	log *slog.Logger,
) worker.Handler

NewHandler is the worker handler that runs the model read through port under modelstage's dispatch-once protocol. It reads each task's parse through client and its lens's context through contexts, and scans each suggestion with scanner.

func Replayable

func Replayable(st *store.Store) server.Replayable

Replayable is the read as a replay runs it again, such as with a new prompt or lens, over each item that route.ModelReadDue names. 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.

Types

type Answer

type Answer struct {
	Summary    *string `json:"summary"`
	Suggestion *string `json:"suggestion"`
}

Answer is the model's answer, as prompts/model-read/answer.schema.json holds it. Either may be nil, and never both.

func ReadAnswer

func ReadAnswer(p prompts.Prompt, raw json.RawMessage) (Answer, error)

ReadAnswer checks raw against the schema of p, the prompt it answered, and decodes it. An answer holding neither a summary nor a suggestion fails as one that breaks the schema does.

type Scanner

type Scanner interface {
	// Version is the rules' version, which the output records beside the
	// findings.
	Version() string
	Scan(ctx context.Context, text string) ([]store.Finding, []store.Span, error)
}

Scanner reads a suggestion sentence before it is kept. *scan.Scanner is one.

Jump to

Keyboard shortcuts

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