Documentation
¶
Overview ¶
Package wirefake has fakes of the model APIs Blitz speaks (Anthropic's Messages API, the Gemini API and OpenAI's Responses API) that are as strict as the real ones (spec_056_conversation_adapters CA-150): each refuses, with the real API's status and words, what its documentation says it refuses. They answer from a script, sign their own reasoning as the real APIs do, and refuse a signature they didn't give, so a test that switches a conversation between them shows what a real switch would break.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is one API's fake: a server, its script, and what it was sent.
func Anthropic ¶
Anthropic fakes the Messages API (POST /v1/messages), streamed when asked ("stream": true) as the API streams: each block started, its deltas, stopped, then the message's stop reason and usage.
func Gemini ¶
Gemini fakes the Gemini API's generateContent and streamGenerateContent (POST /v1beta/models/<model>:…; the stream as server-sent events, the whole answer in one chunk). Point the genai client at it with GOOGLE_GEMINI_BASE_URL.
func OpenAI ¶
OpenAI fakes the Responses API (POST <base>/responses), streamed when asked ("stream": true) as the API streams: the response created, each output item added and done, then the response completed.
type Reply ¶
type Reply struct {
// Thought is the model's reasoning, returned (and signed) only when
// the request asks for reasoning, as the real APIs do.
Thought string
// Text is the answer's text.
Text string
// Calls are the tool calls the answer makes.
Calls []Call
// Files are files the answer makes (an image model's pictures), which
// only the Gemini fake returns, as Gemini does: inline data in the
// model's turn.
Files []File
// Usage is what the answer reports; zero gives a small default.
Usage Usage
// Status, when set, refuses the request with this HTTP status (a 503:
// the model is overloaded) instead of answering.
Status int
// Search is a web search the model runs with its provider's own tool,
// before its Text, which cites the results; only when the request
// offers that tool, as a real model can search only then.
Search *Search
// Finish, when set, is why the answer ended, in the API's own words:
// Anthropic's stop_reason ("refusal"), Gemini's finishReason ("SAFETY",
// "RECITATION", "MALFORMED_FUNCTION_CALL"), OpenAI's incomplete reason
// ("content_filter").
Finish string
// Extra are parts of the answer Blitz has no form for, as the API
// sends them: an Anthropic content block (a server_tool_use), an
// OpenAI output item (a web_search_call).
Extra []map[string]any
// TooLong refuses the request as longer than the model's context
// window, in the API's words.
TooLong bool
// Refusal is the refusal's message, in the API's error shape (its
// status's text when empty): a model refusing what it can't do, in
// the words its server uses ("… does not support tools").
Refusal string
}
Reply is one scripted answer, given in each API's own form.