Documentation
¶
Overview ¶
Package testllm is a fake model service for tests: the model-list endpoint and a scripted, streaming chat endpoint for each protocol (openai, openai-responses, anthropic). Requests a real service would reject get a 400 and are marked.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
System, Messages, Tools json.RawMessage
Header http.Header
Model, Path, Invalid string
Body json.RawMessage
}
Request is the raw JSON of one chat request. For openai-responses System is the instructions and Messages the input. Invalid says why the fake rejected it with a 400; empty means it was answered from the script.
type Server ¶
type Server struct {
URL string // base URL, as a user would enter it
Mux *http.ServeMux
// contains filtered or unexported fields
}
func (*Server) Advance ¶
func (s *Server) Advance()
Advance drops the current turn, e.g. a Status turn that keeps answering.
func (*Server) Release ¶
func (s *Server) Release()
Release lets hanging turns finish. It is safe to call more than once.
func (*Server) RequireKey ¶
func (*Server) SetListStatus ¶
SetListStatus makes the model list answer with that HTTP status; 0 restores it.
type Turn ¶
type Turn struct {
Text []string
Calls []Call
Hang bool
Status int
Finish string
Reasoning string
Fail string
Incomplete bool
Truncate bool
Refusal string // openai-responses: the reply is this refusal, not text
}
Turn is one scripted model response. Status != 0 answers with that HTTP error (its body echoes the key the request carried). Hang streams the text, then waits for Release or the client to go away. Finish, if set, is the raw finish reason sent (OpenAI finish_reason, Anthropic stop_reason).
openai-responses only: Reasoning adds a reasoning item with that encrypted_content; Fail ends with response.failed carrying that message, Incomplete with response.incomplete, Truncate with no terminal event. A Status turn keeps answering (the SDK's retries) until Advance or the next Script call.