Documentation
¶
Overview ¶
Package shadow runs a request a second time on the local model, after the real answer has gone out, and records how the two compare. It is how a class of request is judged before a rule is trusted to send it local.
Nothing here can affect a client. A shadow starts only once the real exchange is finished, runs on its own goroutine, and its answer goes to the ledger and nowhere else.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Input ¶
type Input struct {
// ID names the run in its capture.
ID string
// Body is the request as the client originally sent it.
Body []byte
AnthropicVersion string
// Model is the local model's id in LM Studio; ContextTokens the largest
// prompt to send it, or zero to use what it is loaded with.
Model string
ContextTokens int
Timeout time.Duration
// Reason is recorded as why the run happened.
Reason string
}
Input is one request to run on the local model for comparison.
type Output ¶
type Output struct {
Skipped string
Err error
// Exchange is what was sent to the local model and what came back. Nil
// when Skipped. It carries no credentials, because none are sent.
Exchange *proxy.Exchange
}
Output is what came of one run. Exactly one of these describes it: Skipped (it was never sent), Err (it was sent and the connection failed), or neither (an answer came back, which may itself be an error or cut short; Exchange.Summary says).
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner runs shadows one at a time.
func New ¶
func New(local *backend.Local, led *ledger.Ledger, captures *capture.Writer, logf func(string, ...any)) *Runner
New starts a Runner. Close it to stop.