standin

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 5 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 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.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP answers one call.

type ToolCall

type ToolCall struct {
	ID, Name, Args string
}

A ToolCall is one tool the model calls, with its arguments as JSON.

Jump to

Keyboard shortcuts

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