Documentation
¶
Overview ¶
Package intent is the vocabulary of a Slack reply's second reading (spec SI3, SI4): the closed nine intents, the schema check that turns a model's answer into one of them or into unknown, and the span rule that lets the model choose what to quote but never write it. It does no I/O: the one model call is model.go's, and who may be classified is the broker's.
Index ¶
- Variables
- func MentionReview(text string) (repo string, pr int, ok bool)
- func Parse(raw []byte, reply string, minConfidence float64) (Result, Outcome)
- func Span(reply, text string) string
- func TextHash(text string) string
- func ValidPhase(p string) bool
- type Intent
- type Model
- type Outcome
- type Result
- type Usage
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalid is a gateway reply that is not the shape the call asks for, or too large. ErrInvalid = errors.New("classifier_invalid") ErrUnavailable = errors.New("classifier_unavailable") // ErrTimeout is the call outliving its deadline. ErrTimeout = errors.New("classifier_timeout") )
The sentinels the caller maps to its closed outcomes: ErrTimeout to `timeout`, ErrInvalid to `invalid_output`, ErrUnavailable to `error`. Each carries its detail after the colon; the detail never holds the reply.
var All = []Intent{Status, Needs, Changes, PR, Steer, Amend, Stop, Retry, RetryDeeper, Unknown}
All is the ten intents, in the order the schema lists them.
var Phases = []string{"queued", "running", "waiting-you", "waiting-other", "waiting-pr", "waiting", "done", "failed", "stopped", "unknown"}
Phases is the closed list of words a thread's phase may be sent as (SI3): the kinds of summary.StatusLine, which the App reads from the one room_summary it makes, and "unknown" for a room whose status that summary cannot name. The classifier reads no room; the broker refuses any other word, so a caller cannot smuggle text in through the phase.
Functions ¶
func MentionReview ¶ added in v0.54.0
MentionReview reports whether a mention carries a GitHub pull request URL (raw or Slack-wrapped) and asks for a review, returning the repository and pull request number (phase F4/F6).
func Parse ¶
Parse reads the model's raw answer against reply. Anything that is not the closed shape, names an intent outside the nine or carries a confidence outside 0 to 1 is Unknown with OutcomeInvalidOutput; a confidence under minConfidence is Unknown with OutcomeLowConfidence. Steer and amend keep the span of reply the model quoted (Span), every other intent drops its text.
func Span ¶
Span is what a steer or an amend acts on: text if it is a contiguous span of reply once case and whitespace are folded, returned as the reply spelled it; otherwise, an empty text included, the whole reply. The model chooses what to quote and never writes it (SI4).
Types ¶
type Intent ¶
type Intent string
Intent is one of the nine labels a reply can carry.
const ( Status Intent = "status" Needs Intent = "needs" Changes Intent = "changes" PR Intent = "pr" Steer Intent = "steer" Amend Intent = "amend" Stop Intent = "stop" Retry Intent = "retry" RetryDeeper Intent = "retry_deeper" Unknown Intent = "unknown" )
The closed vocabulary. A model answer outside it is Unknown with OutcomeInvalidOutput.
type Model ¶
type Model struct {
// URL is the gateway's base route (`human.slackIntents.url`); the call is appended to it.
URL string
// Alias is the one model alias the classifier may name.
Alias string
// KeyFile holds the `classifier` client's key, read at use so a rotation needs no restart.
KeyFile string
// Deadline bounds the call. Zero means five seconds.
Deadline time.Duration
// HC is the audited egress client (`httpx.New`). A nil client makes no call.
HC *http.Client
}
Model is the one bounded `chat/completions` call: the gateway's route, the pinned alias, the key file read at use, the audited egress client and a deadline. It holds no state and shares nothing with the planner's client but httpx: a planner change must not move the classifier.
func (Model) Classify ¶
Classify makes the one call: the reply and the thread's phase as one JSON user message, no history, one attempt. It returns the model's answer as raw bytes for Parse, which decides what it means; an answer outside the closed shape is Parse's `invalid_output`, not an error here.
type Outcome ¶
type Outcome string
Outcome is how a classification ended, as maku_intent_classify_total{outcome} counts it.
const ( OutcomeOK Outcome = "ok" OutcomeLowConfidence Outcome = "low_confidence" OutcomeInvalidOutput Outcome = "invalid_output" OutcomeTimeout Outcome = "timeout" OutcomeCapped Outcome = "capped" OutcomeError Outcome = "error" )
The outcomes Parse decides; the caller adds timeout, capped and error.