Documentation
¶
Overview ¶
Package standin is a model service for tests: it speaks Anthropic's Messages API, streams each reply as server-sent events, and keeps every call it is sent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
Turn int // 1 for the first call the server is sent
Key string // the x-api-key header
System string
Messages []any // without the marks that ask for the request's start to be kept
Tools []any
Body []byte `json:"-"` // the request's body, as it was sent
Beta string // the anthropic-beta header
}
A Call is what one call sent: the system text, and the messages and tools as they were given.
type Reply ¶
type Reply struct {
Text string
Calls []ToolCall
// Cut says the reply was cut short at its length limit.
Cut bool
// Error, where set, is sent with status 500 in place of a reply.
Error string
// Hold, where set, holds the reply after the first half of its text
// has been sent, until something is sent on it, it is closed or the
// caller gives up. A held reply needs a text of two characters or
// more, and one with less is answered with status 500.
Hold <-chan struct{}
}
A Reply is the model's answer: its text, then the tools it calls. Each reply uses 10 tokens in and 5 out.
type Server ¶
type Server struct {
Answer func(Call) Reply
// Key, where set, is the x-api-key a call must carry; a call without
// it is refused with 401.
Key string
// Calls are the calls the server was sent, in order. A test reads
// them once the server is no longer being called.
Calls []Call
// contains filtered or unexported fields
}
A Server answers each call to /v1/messages with the reply Answer gives.