Documentation
¶
Overview ¶
Package dialect defines the pure wire-codec boundary for model APIs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
DecodeJSON decodes exactly one JSON value while retaining integer precision in interface-backed fields. Dialects must not round tool arguments or tool results before the canonical request digest is bound.
func DecodeJSONStrict ¶
DecodeJSONStrict decodes exactly one JSON value, retains integer precision, and rejects fields which are not represented by destination. Wire dialects use this at their top-level envelope so a newly introduced provider control cannot silently become an accidental no-op.
Types ¶
type Codec ¶
type Codec interface {
Dialect() canonical.Dialect
Decode([]byte) (canonical.Request, error)
NewStream(responseID, model string, seed ...StreamSeed) Stream
NewAggregate(responseID, model string, seed ...StreamSeed) Aggregate
AdmissionError(status int, code, message string) []byte
OverloadedStatus() int
}
type Encoder ¶
type Encoder interface {
Start() ([][]byte, error)
Heartbeat() []byte
Encode(completion.Event, ...EventSeed) (frames [][]byte, done bool, err error)
}
Encoder is the durable, dialect-specific projection of canonical worker events. Streaming encoders return observable frames as work progresses; aggregate encoders retain that state internally and return exactly one JSON body at the terminal event. The gateway persists every event and its encoded bytes, so either implementation can be reconstructed after a crash without parsing its own wire format.
type EventSeed ¶
type EventSeed struct {
EncodedAtUnix int64
}
EventSeed is persisted with each worker-event checkpoint. It makes any event-local clock fields reproducible when recovery replays the codec state.
type StreamSeed ¶
type StreamSeed struct {
CreatedAtUnix int64
ToolCallPolicy canonical.ToolCallPolicy
}
StreamSeed contains the wall-clock input that affects stable wire fields. The gateway persists it before exposing the response so a restarted codec can reproduce the exact same stream rather than sampling a new clock.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package anthropic implements the Anthropic Messages wire dialect.
|
Package anthropic implements the Anthropic Messages wire dialect. |
|
Package openai implements the OpenAI Chat Completions wire dialect.
|
Package openai implements the OpenAI Chat Completions wire dialect. |
|
Package responses implements the OpenAI Responses API wire dialect.
|
Package responses implements the OpenAI Responses API wire dialect. |