modelclient

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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 modelclient is the agent under test as the eval harnesses reach it: an OpenAI-compatible chat-completions endpoint, temperature 0, read as a stream so tool arguments arrive as the model wrote them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL   string // full chat-completions endpoint
	Model string
	HTTP  *http.Client
	// ToolChoice, when set, replaces "auto": the benefit benchmark's forced
	// arm names the one function the model must call.
	ToolChoice any
	// ReportUsage asks the server to close the stream with token counts.
	ReportUsage bool
}

Client is one model behind a chat-completions endpoint.

func (*Client) Chat

func (m *Client) Chat(ctx context.Context, messages []Message, tools []map[string]any) (Message, error)

Chat sends the transcript plus the tool definitions, temperature 0, and reads the answer as a stream. Streaming is for fidelity, not speed: asked for a whole message, a server has to parse the model's tool arguments, and ds4 hands unparseable ones over as {} — erasing what the model wrote and earning it a rejection about a call it never made. The stream carries the arguments as written. Transient transport failures and 429/5xx responses are retried with backoff: a gate run makes hundreds of calls against a local model server over roughly an hour, and one blip must not abort the whole run. Per-turn deadlines and an outer cancel are never retried.

type Message

type Message struct {
	Role       string     `json:"role"`
	Content    *string    `json:"content,omitempty"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string     `json:"tool_call_id,omitempty"`

	// Usage is what the turn cost; never sent back to the model.
	Usage *Usage `json:"-"`
}

type ToolCall

type ToolCall struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Function struct {
		Name      string `json:"name"`
		Arguments string `json:"arguments"`
	} `json:"function"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
}

Usage is the server's own count for one turn, when it reports one.

Jump to

Keyboard shortcuts

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