compat

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StringContent = compat.StringContent
	PartsContent  = compat.PartsContent
	TextPart      = compat.TextPart
)

Constructors re-exported for the translation layer + tests.

Functions

func EffortFrom

func EffortFrom(s string) wire.Effort

EffortFrom maps the standard reasoning_effort vocabulary onto the abstract Effort. Unknown values degrade to off rather than erroring (reasoning controls are an OPTIONAL capability, never a request-killer).

func FinishReasonFrom

func FinishReasonFrom(stop string) string

FinishReasonFrom maps internal stop reasons onto the standard vocabulary.

func OpaqueFrom

func OpaqueFrom(blocks []wire.Block) []json.RawMessage

OpaqueFrom extracts the response's reasoning blocks as the memcode_opaque array (each element the block's wire JSON, re-expandable verbatim).

Types

type ChatChunk

type ChatChunk = compat.ChatChunk

func ChunkFrom

func ChunkFrom(id string, created int64, model string, choices []ChunkChoice) ChatChunk

ChunkFrom wraps one streamed delta in the standard chunk shape (the wire constants live here, not at the send sites).

type ChatMessage

type ChatMessage = compat.ChatMessage

type ChatRequest

type ChatRequest = compat.ChatRequest

type ChatResponse

type ChatResponse = compat.ChatResponse

func ResponseFrom

func ResponseFrom(resp wire.Response, id string, created int64) ChatResponse

ResponseFrom renders a (sanitized) internal response as a chat completion.

type Choice

type Choice = compat.Choice

type ChunkChoice

type ChunkChoice = compat.ChunkChoice

type ContentPart

type ContentPart = compat.ContentPart

type Delta

type Delta = compat.Delta

type ErrorBody

type ErrorBody = compat.ErrorBody

type ErrorResponse

type ErrorResponse = compat.ErrorResponse

func ErrorFrom

func ErrorFrom(msg, typ, code string) ErrorResponse

ErrorFrom wraps a message in the standard {"error":{message,type,code}} envelope — the one shape both the HTTP error writer and the mid-stream error event emit.

type FilePart

type FilePart = compat.FilePart

type FunctionCall

type FunctionCall = compat.FunctionCall

type FunctionDef

type FunctionDef = compat.FunctionDef

type ImageURLPart

type ImageURLPart = compat.ImageURLPart

type MemcodeExt

type MemcodeExt = compat.MemcodeExt

func ExtFrom

func ExtFrom(resp wire.Response) *MemcodeExt

ExtFrom builds the memcode extension object from a (sanitized) response.

type MessageContent

type MessageContent = compat.MessageContent

type ModelEntry

type ModelEntry = compat.ModelEntry

func ModelEntryFrom

func ModelEntryFrom(label string, meta ModelMeta) ModelEntry

ModelEntryFrom wraps one catalog label + its selection facts in the standard model-list entry shape.

type ModelList

type ModelList = compat.ModelList

func ModelListFrom

func ModelListFrom(entries []ModelEntry, ext *ModelsExt) ModelList

ModelListFrom wraps entries + the list-level extension in the standard list shape. Data is never null on the wire (clients range over it).

type ModelMeta

type ModelMeta = compat.ModelMeta

type ModelsExt

type ModelsExt = compat.ModelsExt

type PromptTokensDetails

type PromptTokensDetails = compat.PromptTokensDetails

type ResponseMessage

type ResponseMessage = compat.ResponseMessage

type RoleEntry

type RoleEntry = compat.RoleEntry

type StreamOptions

type StreamOptions = compat.StreamOptions

type Tool

type Tool = compat.Tool

type ToolCall

type ToolCall = compat.ToolCall

func ToolCallsFrom

func ToolCallsFrom(uses []wire.Block) []ToolCall

ToolCallsFrom renders tool_use blocks as standard tool calls. Empty inputs become "{}" so clients can always json-parse arguments.

type ToolCallDelta

type ToolCallDelta = compat.ToolCallDelta

type Turn

type Turn struct {
	System         string // first system message → the cacheable stable prefix
	SystemVolatile string // second system message (3+ concatenate) → the volatile suffix
	Messages       []wire.Message
	Tools          []wire.ToolDef
	ToolChoice     string
	Effort         wire.Effort
	MaxTokens      int
}

Turn is the translated body of one inbound chat-completions request — the pieces that slot straight into wire.Request. The caller stamps Model, BillingLane, Session, and the ops SystemPrefix.

func ToTurn

func ToTurn(req ChatRequest) (Turn, error)

ToTurn translates one inbound ChatRequest body into a Turn. Errors are client errors (400): unsupported roles/parts, malformed data URLs, a forced tool_choice naming an undefined tool, and so on.

type Usage

type Usage = compat.Usage

func UsageFrom

func UsageFrom(resp wire.Response) Usage

UsageFrom converts internal (Anthropic-style, cache-exclusive) counts to the standard shape (prompt_tokens cache-INCLUSIVE, cached subset in details).

Directories

Path Synopsis
Package conformance is the Phase A0 compat-subset contract, executable: a test suite that exercises ANY OpenAI-compatible base URL and reports where it sits against the two-tier contract (plans/flickering-soaring-falcon).
Package conformance is the Phase A0 compat-subset contract, executable: a test suite that exercises ANY OpenAI-compatible base URL and reports where it sits against the two-tier contract (plans/flickering-soaring-falcon).

Jump to

Keyboard shortcuts

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