Documentation
¶
Index ¶
- Constants
- Variables
- func BuildRequestMap(provider string, canonical jmap, stream bool, apiKey, baseURL string) (jmap, error)
- func DefaultParameters() jmap
- func ErrTypeName(err error) string
- func MarshalPart(p Part) ([]byte, error)
- func NormalizedErrorMap(err LM15Error) jmap
- func ParseResponseMap(provider string, canonical jmap, status int, bodyB64 string) (jmap, error)
- func PartToMap(p Part) jmap
- func ReplayStream(provider string, req Request, body []byte) ([]StreamEvent, Response, error)
- func ReplayStreamMap(provider string, canonical jmap, bodyB64 string) (jmap, error)
- func SerdeRoundtrip(kind string, value jmap) (jmap, error)
- func SurfaceDump() jmap
- type AnthropicLM
- func (c *AnthropicLM) CollectResponse(ctx context.Context, req Request) (Response, error)
- func (c *AnthropicLM) Complete(ctx context.Context, req Request) (Response, error)
- func (c *AnthropicLM) Provider() string
- func (c *AnthropicLM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]
- type AudioDelta
- type AudioFormat
- type AudioGenerationRequest
- type AudioGenerationResponse
- type AudioPart
- type AuthError
- type BatchRequest
- type BatchResponse
- type BillingError
- type BinaryPart
- type BuiltinTool
- type CacheConfig
- type CapabilityError
- type ChatCompat
- type CitationDelta
- type CitationPart
- type Config
- type ConfigurationError
- type ContextLengthError
- type ContinuationDelta
- type ContinuationState
- type Delta
- type DocumentPart
- type EmbeddingRequest
- type EmbeddingResponse
- type ErrorDetail
- type ErrorMeta
- type FileUploadRequest
- type FileUploadResponse
- type FunctionTool
- type GeminiLM
- type ImageDelta
- type ImageGenerationRequest
- type ImageGenerationResponse
- type ImagePart
- type InferenceModelInfo
- type InferencePricing
- type InvalidRequestError
- type LM15Error
- type LiveClientAudioEvent
- type LiveClientEndAudioEvent
- type LiveClientEvent
- type LiveClientImageEvent
- type LiveClientInterruptEvent
- type LiveClientTextEvent
- type LiveClientToolResultEvent
- type LiveClientTurnEvent
- type LiveConfig
- type LiveServerAudioEvent
- type LiveServerErrorEvent
- type LiveServerEvent
- type LiveServerInterruptedEvent
- type LiveServerTextEvent
- type LiveServerToolCallDeltaEvent
- type LiveServerToolCallEvent
- type LiveServerTurnEndEvent
- type Message
- type ModelInfo
- type ModelOrigin
- type NotConfiguredError
- type OpenAIChatLM
- func (c *OpenAIChatLM) CollectResponse(ctx context.Context, req Request) (Response, error)
- func (c *OpenAIChatLM) Complete(ctx context.Context, req Request) (Response, error)
- func (c *OpenAIChatLM) Provider() string
- func (c *OpenAIChatLM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]
- type OpenAILM
- type Option
- type Part
- type ProviderError
- type RateLimitError
- type Reasoning
- type RefusalPart
- type Request
- type Response
- type SSEEvent
- type ServerError
- type StreamDeltaEvent
- type StreamEndEvent
- type StreamErrorEvent
- type StreamEvent
- type StreamStartEvent
- type TextDelta
- type TextPart
- type ThinkingDelta
- type ThinkingPart
- type TimeoutError
- type Tool
- type ToolCallDelta
- type ToolCallInfo
- type ToolCallPart
- type ToolChoice
- type ToolResultPart
- type TrainingModelInfo
- type TrainingPricing
- type TransportError
- type TransportRequest
- type UnsupportedFeatureError
- type UnsupportedModelError
- type Usage
- type VideoPart
Constants ¶
const ( CompatOpenAI = "openai" CompatOllama = "ollama" CompatGroq = "groq" CompatOpenRouter = "openrouter" CompatVLLM = "vllm" CompatSGLang = "sglang" CompatLMStudio = "lmstudio" )
Compat preset names for WithCompat (see ChatCompatPreset).
const ImplVersion = "2.0.0-dev"
ImplVersion is the lm15-go implementation version reported by the shim.
Variables ¶
var AudioEncodings = []string{"pcm16", "opus", "mp3", "aac"}
var BatchStatuses = []string{"submitted", "queued", "running", "completed", "failed", "cancelled"}
var CacheModes = []string{"auto", "off"}
var CacheRetentions = []string{"short", "long"}
var ChatPresetBaseURLs = map[string]string{
"openai": "https://api.openai.com/v1",
"ollama": "http://localhost:11434/v1",
"groq": "https://api.groq.com/openai/v1",
"openrouter": "https://openrouter.ai/api/v1",
"vllm": "http://localhost:8000/v1",
"sglang": "http://localhost:30000/v1",
}
ChatPresetBaseURLs gives each preset's default server base URL.
var DefaultBaseURLs = map[string]string{
"openai": "https://api.openai.com/v1",
"openai_chat": "https://api.openai.com/v1",
"anthropic": "https://api.anthropic.com/v1",
"gemini": "https://generativelanguage.googleapis.com/v1beta",
}
DefaultBaseURLs per provider.
var DeltaTypes = []string{
"text", "thinking", "audio", "image", "tool_call", "citation", "continuation",
}
var ErrorCodes = []string{
"auth", "billing", "rate_limit", "invalid_request", "context_length",
"timeout", "server", "unsupported_model", "unsupported_feature",
"not_configured", "transport", "provider",
}
var FinishReasons = []string{"stop", "length", "tool_call", "content_filter", "error"}
var LiveClientEventTypes = []string{"turn", "audio", "image", "text", "tool_result", "interrupt", "end_audio"}
var LiveServerEventTypes = []string{"audio", "text", "tool_call", "tool_call_delta", "interrupted", "turn_end", "error"}
var PartTypes = []string{
"text", "image", "audio", "video", "document", "binary",
"tool_call", "tool_result", "thinking", "refusal", "citation",
}
var ReasoningEfforts = []string{"off", "adaptive", "minimal", "low", "medium", "high", "xhigh"}
var ReasoningSummaries = []string{"auto", "concise", "detailed"}
var RoleValues = []string{"user", "assistant", "tool", "developer"}
var StreamEventTypes = []string{"start", "delta", "end", "error"}
var ToolChoiceModes = []string{"auto", "required", "none"}
Functions ¶
func BuildRequestMap ¶
func BuildRequestMap(provider string, canonical jmap, stream bool, apiKey, baseURL string) (jmap, error)
BuildRequestMap is the vet-protocol entry: canonical request JSON in, protocol-shaped transport request out.
func DefaultParameters ¶
func DefaultParameters() jmap
DefaultParameters returns the default FunctionTool JSON-Schema payload.
func ErrTypeName ¶
ErrTypeName reports the vet-protocol error type name for an error: the recorded native-exception-style name for serde errors, the canonical class name for lm15-typed errors, else "ValueError".
func MarshalPart ¶
MarshalPart serializes any Part to canonical JSON bytes.
func NormalizedErrorMap ¶
func NormalizedErrorMap(err LM15Error) jmap
NormalizedErrorMap renders an LM15Error in the normalize_error vet output shape.
func ParseResponseMap ¶
ParseResponseMap is the vet-shim entry: canonical Response JSON plus the unmapped canary per harness/PROTOCOL.md.
func PartToMap ¶
func PartToMap(p Part) jmap
PartToMap serializes a Part to its canonical JSON object form.
func ReplayStream ¶
ReplayStream parses a captured SSE body for the given provider into the POST-coalesce canonical event trace plus the materialized Response.
func ReplayStreamMap ¶
ReplayStreamMap is the vet-shim entry for the replay_stream op.
func SerdeRoundtrip ¶
SerdeRoundtrip implements the vet protocol's serde_roundtrip op: to_dict(from_dict(value)) for the given kind, no cleaning beyond the canonical serializers themselves.
func SurfaceDump ¶
func SurfaceDump() jmap
SurfaceDump returns the type/enum surface for the vet protocol.
Types ¶
type AnthropicLM ¶
type AnthropicLM struct {
// contains filtered or unexported fields
}
AnthropicLM talks to the Anthropic Messages API.
func NewAnthropicLM ¶
func NewAnthropicLM(apiKey string, opts ...Option) (*AnthropicLM, error)
NewAnthropicLM builds an Anthropic Messages API client.
func (*AnthropicLM) CollectResponse ¶
CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).
func (*AnthropicLM) Complete ¶
Complete sends the canonical Request and returns the canonical Response.
func (*AnthropicLM) Provider ¶
func (c *AnthropicLM) Provider() string
Provider reports the adapter name ("openai", "openai_chat", ...).
type AudioDelta ¶
type AudioDelta struct {
Data *string `json:"data"`
URL *string `json:"url"`
FileID *string `json:"file_id"`
PartIndex int64 `json:"part_index"`
MediaType *string `json:"media_type"`
}
func (AudioDelta) DeltaType ¶
func (d AudioDelta) DeltaType() string
func (AudioDelta) MarshalJSON ¶
func (d AudioDelta) MarshalJSON() ([]byte, error)
type AudioFormat ¶
type AudioFormat struct {
Encoding string `json:"encoding"`
SampleRate int64 `json:"sample_rate"`
Channels int64 `json:"channels"`
}
func (AudioFormat) MarshalJSON ¶
func (af AudioFormat) MarshalJSON() ([]byte, error)
func (*AudioFormat) UnmarshalJSON ¶
func (af *AudioFormat) UnmarshalJSON(data []byte) error
type AudioGenerationRequest ¶
type AudioGenerationResponse ¶
type AudioPart ¶
type AudioPart struct {
// contains filtered or unexported fields
}
func (AudioPart) Continuations ¶
func (p AudioPart) Continuations() []ContinuationState
func (AudioPart) MarshalJSON ¶
type AuthError ¶
type AuthError struct{ ProviderError }
type BatchRequest ¶
type BatchResponse ¶
type BillingError ¶
type BillingError struct{ ProviderError }
func (BillingError) ClassName ¶
func (BillingError) ClassName() string
func (BillingError) Code ¶
func (BillingError) Code() string
func (BillingError) Unwrap ¶
func (e BillingError) Unwrap() error
type BinaryPart ¶
type BinaryPart struct {
// contains filtered or unexported fields
}
func (BinaryPart) Continuations ¶
func (p BinaryPart) Continuations() []ContinuationState
func (BinaryPart) MarshalJSON ¶
func (p BinaryPart) MarshalJSON() ([]byte, error)
func (BinaryPart) PartType ¶
func (p BinaryPart) PartType() string
type BuiltinTool ¶
type BuiltinTool struct {
Name string `json:"name"`
Config jmap `json:"config"`
}
func (BuiltinTool) MarshalJSON ¶
func (t BuiltinTool) MarshalJSON() ([]byte, error)
func (BuiltinTool) ToolName ¶
func (t BuiltinTool) ToolName() string
func (BuiltinTool) ToolType ¶
func (t BuiltinTool) ToolType() string
type CacheConfig ¶
type CapabilityError ¶
type CapabilityError struct{ ErrorMeta }
func (CapabilityError) ClassName ¶
func (CapabilityError) ClassName() string
func (CapabilityError) Code ¶
func (CapabilityError) Code() string
func (CapabilityError) Retryable ¶
func (CapabilityError) Retryable() bool
type ChatCompat ¶
type ChatCompat struct {
InstructionRole string // "system" | "developer"
MaxTokensField string // "max_completion_tokens" | "max_tokens"
StreamUsage string // "include" | "omit"
ThinkingFormat string // "none" | "reasoning_effort" | "openrouter" | ...
ToolResultName string // "include" | "omit"
StrictTools string // "include" | "omit"
CacheControl string // "none" | "openai"
Routing jmap
}
ChatCompat is the resolved OpenAI Chat Completions compatibility policy.
func ChatCompatPreset ¶
func ChatCompatPreset(name string) (ChatCompat, error)
ChatCompatPreset resolves a named OpenAI-compatible server preset (ollama, groq, openrouter, vllm, sglang, openai, ...).
type CitationDelta ¶
type CitationDelta struct {
Text *string `json:"text"`
URL *string `json:"url"`
Title *string `json:"title"`
PartIndex int64 `json:"part_index"`
}
func (CitationDelta) DeltaType ¶
func (d CitationDelta) DeltaType() string
func (CitationDelta) MarshalJSON ¶
func (d CitationDelta) MarshalJSON() ([]byte, error)
type CitationPart ¶
type CitationPart struct {
URL *string `json:"url"`
Title *string `json:"title"`
Text *string `json:"text"`
Continuation []ContinuationState `json:"continuation"`
}
func (CitationPart) Continuations ¶
func (p CitationPart) Continuations() []ContinuationState
func (CitationPart) MarshalJSON ¶
func (p CitationPart) MarshalJSON() ([]byte, error)
func (CitationPart) PartType ¶
func (p CitationPart) PartType() string
type Config ¶
type Config struct {
MaxTokens *int64 `json:"max_tokens"`
Temperature *float64 `json:"temperature"`
TopP *float64 `json:"top_p"`
TopK *int64 `json:"top_k"`
Stop []string `json:"stop"`
ResponseFormat jmap `json:"response_format"`
ToolChoice *ToolChoice `json:"tool_choice"`
Reasoning *Reasoning `json:"reasoning"`
Cache *CacheConfig `json:"cache"`
Extensions jmap `json:"extensions"`
}
func (Config) MarshalJSON ¶
func (*Config) UnmarshalJSON ¶
type ConfigurationError ¶
type ConfigurationError struct{ ErrorMeta }
func (ConfigurationError) ClassName ¶
func (ConfigurationError) ClassName() string
func (ConfigurationError) Code ¶
func (ConfigurationError) Code() string
func (ConfigurationError) Retryable ¶
func (ConfigurationError) Retryable() bool
type ContextLengthError ¶
type ContextLengthError struct{ InvalidRequestError }
func (ContextLengthError) ClassName ¶
func (ContextLengthError) ClassName() string
func (ContextLengthError) Code ¶
func (ContextLengthError) Code() string
func (ContextLengthError) Unwrap ¶
func (e ContextLengthError) Unwrap() error
type ContinuationDelta ¶
type ContinuationDelta struct {
Provider string `json:"provider"`
Kind string `json:"kind"`
Data jmap `json:"data"`
PartIndex *int64 `json:"part_index"`
}
func (ContinuationDelta) DeltaType ¶
func (d ContinuationDelta) DeltaType() string
func (ContinuationDelta) MarshalJSON ¶
func (d ContinuationDelta) MarshalJSON() ([]byte, error)
func (ContinuationDelta) ToState ¶
func (d ContinuationDelta) ToState() ContinuationState
ToState converts a ContinuationDelta to its ContinuationState.
type ContinuationState ¶
type ContinuationState struct {
Provider string `json:"provider"`
Kind string `json:"kind"`
Data jmap `json:"data"`
}
func (ContinuationState) MarshalJSON ¶
func (c ContinuationState) MarshalJSON() ([]byte, error)
func (*ContinuationState) UnmarshalJSON ¶
func (c *ContinuationState) UnmarshalJSON(data []byte) error
type Delta ¶
type Delta interface {
DeltaType() string
// contains filtered or unexported methods
}
Delta is the tagged union of streaming deltas, dispatching on "type".
func DeltaFromMap ¶
DeltaFromMap deserializes a Delta, dispatching on "type".
type DocumentPart ¶
type DocumentPart struct {
// contains filtered or unexported fields
}
func (DocumentPart) Continuations ¶
func (p DocumentPart) Continuations() []ContinuationState
func (DocumentPart) MarshalJSON ¶
func (p DocumentPart) MarshalJSON() ([]byte, error)
func (DocumentPart) PartType ¶
func (p DocumentPart) PartType() string
type EmbeddingRequest ¶
type EmbeddingResponse ¶
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
ProviderCode *string `json:"provider_code"`
}
func (ErrorDetail) MarshalJSON ¶
func (e ErrorDetail) MarshalJSON() ([]byte, error)
func (*ErrorDetail) UnmarshalJSON ¶
func (e *ErrorDetail) UnmarshalJSON(data []byte) error
type ErrorMeta ¶
type ErrorMeta struct {
Message string
Provider string
ProviderCode string
Status int
RequestID string
RetryAfter *float64
}
ErrorMeta is the shared metadata of every canonical lm15 error.
type FileUploadRequest ¶
type FileUploadRequest struct {
Filename string `json:"filename"`
BytesData []byte `json:"bytes_data"`
MediaType string `json:"media_type"`
Model string `json:"model"`
Extensions jmap `json:"extensions"`
Path string `json:"path"`
}
FileUploadRequest is in-memory only (no canonical JSON serializer).
type FileUploadResponse ¶
type FileUploadResponse struct {
ID string `json:"id"`
ProviderData jmap `json:"provider_data"`
}
type FunctionTool ¶
type FunctionTool struct {
Name string `json:"name"`
Description *string `json:"description"`
Parameters jmap `json:"parameters"`
}
func (FunctionTool) MarshalJSON ¶
func (t FunctionTool) MarshalJSON() ([]byte, error)
func (FunctionTool) ToolName ¶
func (t FunctionTool) ToolName() string
func (FunctionTool) ToolType ¶
func (t FunctionTool) ToolType() string
type GeminiLM ¶
type GeminiLM struct {
// contains filtered or unexported fields
}
GeminiLM talks to the Google Gemini generateContent API.
func NewGeminiLM ¶
NewGeminiLM builds a Gemini client.
func (*GeminiLM) CollectResponse ¶
CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).
func (*GeminiLM) Complete ¶
Complete sends the canonical Request and returns the canonical Response.
func (*GeminiLM) Provider ¶
func (c *GeminiLM) Provider() string
Provider reports the adapter name ("openai", "openai_chat", ...).
type ImageDelta ¶
type ImageDelta struct {
Data *string `json:"data"`
URL *string `json:"url"`
FileID *string `json:"file_id"`
PartIndex int64 `json:"part_index"`
MediaType *string `json:"media_type"`
}
func (ImageDelta) DeltaType ¶
func (d ImageDelta) DeltaType() string
func (ImageDelta) MarshalJSON ¶
func (d ImageDelta) MarshalJSON() ([]byte, error)
type ImageGenerationRequest ¶
type ImageGenerationResponse ¶
type ImagePart ¶
type ImagePart struct {
Detail *string `json:"detail"`
// contains filtered or unexported fields
}
func (ImagePart) Continuations ¶
func (p ImagePart) Continuations() []ContinuationState
func (ImagePart) MarshalJSON ¶
type InferenceModelInfo ¶
type InferenceModelInfo struct {
InputModalities []string `json:"input_modalities"`
OutputModalities []string `json:"output_modalities"`
ContextWindow *int64 `json:"context_window"`
MaxOutputTokens *int64 `json:"max_output_tokens"`
SupportsReasoning bool `json:"supports_reasoning"`
ReasoningEfforts []string `json:"reasoning_efforts"`
Pricing *InferencePricing `json:"pricing"`
Extensions jmap `json:"extensions"`
}
type InferencePricing ¶
type InferencePricing struct {
InputPerMillion *float64 `json:"input_per_million"`
OutputPerMillion *float64 `json:"output_per_million"`
CacheReadPerMillion *float64 `json:"cache_read_per_million"`
CacheWritePerMillion *float64 `json:"cache_write_per_million"`
Currency string `json:"currency"`
Dimensions jmap `json:"dimensions"`
}
type InvalidRequestError ¶
type InvalidRequestError struct{ ProviderError }
func (InvalidRequestError) ClassName ¶
func (InvalidRequestError) ClassName() string
func (InvalidRequestError) Code ¶
func (InvalidRequestError) Code() string
func (InvalidRequestError) Unwrap ¶
func (e InvalidRequestError) Unwrap() error
type LM15Error ¶
LM15Error is implemented by every canonical lm15 error type.
func ErrorForCode ¶
ErrorForCode maps a canonical ErrorCode to a fresh error value of the most specific canonical class; unknown codes map to ProviderError.
func MapHTTPError ¶
MapHTTPError maps an HTTP status + message to a typed canonical error, per the spec's HTTP mapping table (unmatched status -> ProviderError).
type LiveClientAudioEvent ¶
func (LiveClientAudioEvent) LiveClientEventType ¶
func (e LiveClientAudioEvent) LiveClientEventType() string
type LiveClientEndAudioEvent ¶
type LiveClientEndAudioEvent struct{}
func (LiveClientEndAudioEvent) LiveClientEventType ¶
func (e LiveClientEndAudioEvent) LiveClientEventType() string
type LiveClientEvent ¶
type LiveClientEvent interface {
LiveClientEventType() string
// contains filtered or unexported methods
}
LiveClientEvent is the tagged union of client→server live events.
func LiveClientEventFromMap ¶
func LiveClientEventFromMap(m jmap) (LiveClientEvent, error)
LiveClientEventFromMap dispatches on "type".
type LiveClientImageEvent ¶
func (LiveClientImageEvent) LiveClientEventType ¶
func (e LiveClientImageEvent) LiveClientEventType() string
type LiveClientInterruptEvent ¶
type LiveClientInterruptEvent struct{}
func (LiveClientInterruptEvent) LiveClientEventType ¶
func (e LiveClientInterruptEvent) LiveClientEventType() string
type LiveClientTextEvent ¶
type LiveClientTextEvent struct {
Text string `json:"text"`
}
func (LiveClientTextEvent) LiveClientEventType ¶
func (e LiveClientTextEvent) LiveClientEventType() string
type LiveClientToolResultEvent ¶
func (LiveClientToolResultEvent) LiveClientEventType ¶
func (e LiveClientToolResultEvent) LiveClientEventType() string
type LiveClientTurnEvent ¶
type LiveClientTurnEvent struct {
Parts []Part `json:"parts"`
TurnComplete bool `json:"turn_complete"`
}
func (LiveClientTurnEvent) LiveClientEventType ¶
func (e LiveClientTurnEvent) LiveClientEventType() string
type LiveConfig ¶
type LiveConfig struct {
Model string `json:"model"`
System any `json:"system"` // string or []Part
Tools []Tool `json:"tools"`
Voice *string `json:"voice"`
InputFormat *AudioFormat `json:"input_format"`
OutputFormat *AudioFormat `json:"output_format"`
Extensions jmap `json:"extensions"`
}
func (LiveConfig) MarshalJSON ¶
func (lc LiveConfig) MarshalJSON() ([]byte, error)
func (*LiveConfig) UnmarshalJSON ¶
func (lc *LiveConfig) UnmarshalJSON(data []byte) error
type LiveServerAudioEvent ¶
type LiveServerAudioEvent struct {
Data string `json:"data"`
MediaType *string `json:"media_type"`
}
func (LiveServerAudioEvent) LiveServerEventType ¶
func (e LiveServerAudioEvent) LiveServerEventType() string
type LiveServerErrorEvent ¶
type LiveServerErrorEvent struct {
Error ErrorDetail `json:"error"`
}
func (LiveServerErrorEvent) LiveServerEventType ¶
func (e LiveServerErrorEvent) LiveServerEventType() string
type LiveServerEvent ¶
type LiveServerEvent interface {
LiveServerEventType() string
// contains filtered or unexported methods
}
LiveServerEvent is the tagged union of server→client live events.
func LiveServerEventFromMap ¶
func LiveServerEventFromMap(m jmap) (LiveServerEvent, error)
LiveServerEventFromMap dispatches on "type".
type LiveServerInterruptedEvent ¶
type LiveServerInterruptedEvent struct{}
func (LiveServerInterruptedEvent) LiveServerEventType ¶
func (e LiveServerInterruptedEvent) LiveServerEventType() string
type LiveServerTextEvent ¶
type LiveServerTextEvent struct {
Text string `json:"text"`
}
func (LiveServerTextEvent) LiveServerEventType ¶
func (e LiveServerTextEvent) LiveServerEventType() string
type LiveServerToolCallDeltaEvent ¶
type LiveServerToolCallDeltaEvent struct {
InputDelta string `json:"input_delta"`
ID *string `json:"id"`
Name *string `json:"name"`
}
func (LiveServerToolCallDeltaEvent) LiveServerEventType ¶
func (e LiveServerToolCallDeltaEvent) LiveServerEventType() string
type LiveServerToolCallEvent ¶
type LiveServerToolCallEvent struct {
ID string `json:"id"`
Name string `json:"name"`
Input jmap `json:"input"`
}
func (LiveServerToolCallEvent) LiveServerEventType ¶
func (e LiveServerToolCallEvent) LiveServerEventType() string
type LiveServerTurnEndEvent ¶
type LiveServerTurnEndEvent struct {
Usage Usage `json:"usage"`
}
func (LiveServerTurnEndEvent) LiveServerEventType ¶
func (e LiveServerTurnEndEvent) LiveServerEventType() string
type Message ¶
type Message struct {
Role string `json:"role"`
Parts []Part `json:"parts"`
Continuation []ContinuationState `json:"continuation"`
}
func AssistantMessage ¶
AssistantMessage creates an assistant message from text.
func AssistantMessageParts ¶
AssistantMessageParts creates an assistant message from explicit parts (e.g. replaying the model's ToolCallParts in a tools round-trip).
func ToolResults ¶
func ToolResults(results ...ToolResultPart) Message
ToolResults creates a tool message carrying one or more tool results.
func UserMessage ¶
UserMessage creates a user message from text.
func UserMessageParts ¶
UserMessageParts creates a user message from explicit parts.
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type ModelInfo ¶
type ModelInfo struct {
ID string `json:"id"`
Provider string `json:"provider"`
APIFamily string `json:"api_family"`
Aliases []string `json:"aliases"`
Origin ModelOrigin `json:"origin"`
Inference *InferenceModelInfo `json:"inference"`
Training *TrainingModelInfo `json:"training"`
Extensions jmap `json:"extensions"`
}
func (ModelInfo) MarshalJSON ¶
func (*ModelInfo) UnmarshalJSON ¶
type ModelOrigin ¶
type NotConfiguredError ¶
type NotConfiguredError struct{ ConfigurationError }
func (NotConfiguredError) ClassName ¶
func (NotConfiguredError) ClassName() string
func (NotConfiguredError) Unwrap ¶
func (e NotConfiguredError) Unwrap() error
Unwrap methods expose the class hierarchy to errors.As/errors.Is: each subclass unwraps to its embedded parent class.
type OpenAIChatLM ¶
type OpenAIChatLM struct {
// contains filtered or unexported fields
}
OpenAIChatLM talks to the OpenAI Chat Completions dialect — OpenAI itself or any compatible server via WithCompat / WithBaseURL.
func NewOpenAIChatLM ¶
func NewOpenAIChatLM(apiKey string, opts ...Option) (*OpenAIChatLM, error)
NewOpenAIChatLM builds a Chat Completions client (OpenAI-compatible servers).
func (*OpenAIChatLM) CollectResponse ¶
CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).
func (*OpenAIChatLM) Complete ¶
Complete sends the canonical Request and returns the canonical Response.
func (*OpenAIChatLM) Provider ¶
func (c *OpenAIChatLM) Provider() string
Provider reports the adapter name ("openai", "openai_chat", ...).
type OpenAILM ¶
type OpenAILM struct {
// contains filtered or unexported fields
}
OpenAILM talks to the OpenAI Responses API.
func NewOpenAILM ¶
NewOpenAILM builds an OpenAI Responses API client.
func (*OpenAILM) CollectResponse ¶
CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).
func (*OpenAILM) Complete ¶
Complete sends the canonical Request and returns the canonical Response.
func (*OpenAILM) Provider ¶
func (c *OpenAILM) Provider() string
Provider reports the adapter name ("openai", "openai_chat", ...).
type Option ¶
type Option func(*providerClient) error
Option configures an LM constructor.
func WithBaseURL ¶
WithBaseURL overrides the provider's default base URL.
func WithCompat ¶
WithCompat selects an OpenAI Chat Completions compat preset by name (CompatOllama, CompatGroq, ...). The preset bundles the server's wire quirks and its default base URL; an explicit WithBaseURL still wins. Only meaningful for NewOpenAIChatLM.
func WithHTTPClient ¶
WithHTTPClient substitutes the shared http.Client.
type Part ¶
type Part interface {
PartType() string
Continuations() []ContinuationState
// contains filtered or unexported methods
}
Part is the canonical tagged union of message content. Concrete structs carry custom JSON marshalling dispatching on the "type" discriminator.
func PartFromMap ¶
PartFromMap deserializes a Part from canonical JSON, dispatching on "type".
func UnmarshalPart ¶
UnmarshalPart deserializes canonical JSON bytes into a Part.
type ProviderError ¶
type ProviderError struct{ ErrorMeta }
func (ProviderError) ClassName ¶
func (ProviderError) ClassName() string
func (ProviderError) Code ¶
func (ProviderError) Code() string
func (ProviderError) Retryable ¶
func (ProviderError) Retryable() bool
type RateLimitError ¶
type RateLimitError struct{ ProviderError }
func (RateLimitError) ClassName ¶
func (RateLimitError) ClassName() string
func (RateLimitError) Code ¶
func (RateLimitError) Code() string
func (RateLimitError) Retryable ¶
func (RateLimitError) Retryable() bool
func (RateLimitError) Unwrap ¶
func (e RateLimitError) Unwrap() error
type Reasoning ¶
type RefusalPart ¶
type RefusalPart struct {
Text string `json:"text"`
Continuation []ContinuationState `json:"continuation"`
}
func (RefusalPart) Continuations ¶
func (p RefusalPart) Continuations() []ContinuationState
func (RefusalPart) MarshalJSON ¶
func (p RefusalPart) MarshalJSON() ([]byte, error)
func (RefusalPart) PartType ¶
func (p RefusalPart) PartType() string
type Request ¶
type Request struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
System any `json:"system"` // string or []Part
Tools []Tool `json:"tools"`
Config *Config `json:"config"`
}
func (Request) MarshalJSON ¶
func (*Request) UnmarshalJSON ¶
type Response ¶
type Response struct {
ID *string `json:"id"`
Model string `json:"model"`
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`
Usage Usage `json:"usage"`
ProviderData jmap `json:"provider_data"`
}
func MaterializeResponse ¶
func MaterializeResponse(events []StreamEvent, req Request) Response
MaterializeResponse consumes a canonical event trace and builds the complete Response.
func ParseResponse ¶
ParseResponse maps a provider HTTP response body into the canonical Response. The returned recorder entries are the _lm15_unmapped canary.
func (Response) MarshalJSON ¶
func (Response) Text ¶
Text returns the concatenated assistant text, or "" when the response carries no text. Citation and thinking parts are metadata around the visible answer and don't block extraction; any other part type does.
func (Response) ToolCalls ¶
func (r Response) ToolCalls() []ToolCallPart
ToolCalls returns the response's tool-call parts, in order.
func (*Response) UnmarshalJSON ¶
type ServerError ¶
type ServerError struct{ ProviderError }
func (ServerError) ClassName ¶
func (ServerError) ClassName() string
func (ServerError) Code ¶
func (ServerError) Code() string
func (ServerError) Retryable ¶
func (ServerError) Retryable() bool
func (ServerError) Unwrap ¶
func (e ServerError) Unwrap() error
type StreamDeltaEvent ¶
type StreamDeltaEvent struct {
Delta Delta `json:"delta"`
}
func (StreamDeltaEvent) MarshalJSON ¶
func (e StreamDeltaEvent) MarshalJSON() ([]byte, error)
func (StreamDeltaEvent) StreamEventType ¶
func (e StreamDeltaEvent) StreamEventType() string
type StreamEndEvent ¶
type StreamEndEvent struct {
FinishReason *string `json:"finish_reason"`
Usage *Usage `json:"usage"`
ProviderData jmap `json:"provider_data"`
}
func (StreamEndEvent) MarshalJSON ¶
func (e StreamEndEvent) MarshalJSON() ([]byte, error)
func (StreamEndEvent) StreamEventType ¶
func (e StreamEndEvent) StreamEventType() string
type StreamErrorEvent ¶
type StreamErrorEvent struct {
Error ErrorDetail `json:"error"`
}
func (StreamErrorEvent) MarshalJSON ¶
func (e StreamErrorEvent) MarshalJSON() ([]byte, error)
func (StreamErrorEvent) StreamEventType ¶
func (e StreamErrorEvent) StreamEventType() string
type StreamEvent ¶
type StreamEvent interface {
StreamEventType() string
// contains filtered or unexported methods
}
StreamEvent is the tagged union of stream events, dispatching on "type".
func CoalesceStream ¶
func CoalesceStream(events []StreamEvent) []StreamEvent
CoalesceStream enforces MAP-3 (docs/mapping-rules.md): a stream yields exactly one StreamEndEvent, as the final event. Adapters are stateless and may emit one end event per provider terminal frame (finish_reason chunk, post-finish usage-only chunk, [DONE], message_delta + message_stop). This pass absorbs every end event's fields — a later non-nil field replaces the accumulated value, a nil field never erases one — and appends the single merged end event. If no end event was seen, none is fabricated.
func ParseStreamEvents ¶
func ParseStreamEvents(provider string, req Request, raw SSEEvent) ([]StreamEvent, error)
ParseStreamEvents maps one SSE frame to canonical stream events.
func StreamEventFromMap ¶
func StreamEventFromMap(m jmap) (StreamEvent, error)
StreamEventFromMap deserializes a StreamEvent, dispatching on "type".
type StreamStartEvent ¶
func (StreamStartEvent) MarshalJSON ¶
func (e StreamStartEvent) MarshalJSON() ([]byte, error)
func (StreamStartEvent) StreamEventType ¶
func (e StreamStartEvent) StreamEventType() string
type TextDelta ¶
func (TextDelta) MarshalJSON ¶
type TextPart ¶
type TextPart struct {
Text string `json:"text"`
Continuation []ContinuationState `json:"continuation"`
}
func (TextPart) Continuations ¶
func (p TextPart) Continuations() []ContinuationState
func (TextPart) MarshalJSON ¶
type ThinkingDelta ¶
func (ThinkingDelta) DeltaType ¶
func (d ThinkingDelta) DeltaType() string
func (ThinkingDelta) MarshalJSON ¶
func (d ThinkingDelta) MarshalJSON() ([]byte, error)
type ThinkingPart ¶
type ThinkingPart struct {
Text string `json:"text"`
Redacted bool `json:"redacted"`
Continuation []ContinuationState `json:"continuation"`
}
func (ThinkingPart) Continuations ¶
func (p ThinkingPart) Continuations() []ContinuationState
func (ThinkingPart) MarshalJSON ¶
func (p ThinkingPart) MarshalJSON() ([]byte, error)
func (ThinkingPart) PartType ¶
func (p ThinkingPart) PartType() string
type TimeoutError ¶
type TimeoutError struct{ ProviderError }
func (TimeoutError) ClassName ¶
func (TimeoutError) ClassName() string
func (TimeoutError) Code ¶
func (TimeoutError) Code() string
func (TimeoutError) Retryable ¶
func (TimeoutError) Retryable() bool
func (TimeoutError) Unwrap ¶
func (e TimeoutError) Unwrap() error
type Tool ¶
type Tool interface {
ToolType() string
ToolName() string
// contains filtered or unexported methods
}
Tool is the tagged union of FunctionTool and BuiltinTool.
func ToolFromMap ¶
ToolFromMap dispatches on "type": "builtin" → BuiltinTool; anything else (including absent) → FunctionTool (INV-034).
type ToolCallDelta ¶
type ToolCallDelta struct {
Input string `json:"input"`
PartIndex int64 `json:"part_index"`
ID *string `json:"id"`
Name *string `json:"name"`
}
func (ToolCallDelta) DeltaType ¶
func (d ToolCallDelta) DeltaType() string
func (ToolCallDelta) MarshalJSON ¶
func (d ToolCallDelta) MarshalJSON() ([]byte, error)
type ToolCallInfo ¶
type ToolCallInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Input jmap `json:"input"`
}
ToolCallInfo is the in-memory callback view of a ToolCallPart.
func ToolCallInfoFromPart ¶
func ToolCallInfoFromPart(p ToolCallPart) ToolCallInfo
FromPart builds a ToolCallInfo from a ToolCallPart.
func (ToolCallInfo) ToPart ¶
func (i ToolCallInfo) ToPart() ToolCallPart
ToPart converts back to a ToolCallPart.
type ToolCallPart ¶
type ToolCallPart struct {
ID string `json:"id"`
Name string `json:"name"`
Input jmap `json:"input"`
Continuation []ContinuationState `json:"continuation"`
}
func (ToolCallPart) Continuations ¶
func (p ToolCallPart) Continuations() []ContinuationState
func (ToolCallPart) MarshalJSON ¶
func (p ToolCallPart) MarshalJSON() ([]byte, error)
func (ToolCallPart) PartType ¶
func (p ToolCallPart) PartType() string
type ToolChoice ¶
type ToolResultPart ¶
type ToolResultPart struct {
ID string `json:"id"`
Content []Part `json:"content"`
Name *string `json:"name"`
IsError bool `json:"is_error"`
Continuation []ContinuationState `json:"continuation"`
}
func ToolResult ¶
func ToolResult(callID, content string) ToolResultPart
ToolResult builds a text tool result answering the tool call with this ID.
func (ToolResultPart) Continuations ¶
func (p ToolResultPart) Continuations() []ContinuationState
func (ToolResultPart) MarshalJSON ¶
func (p ToolResultPart) MarshalJSON() ([]byte, error)
func (ToolResultPart) PartType ¶
func (p ToolResultPart) PartType() string
type TrainingModelInfo ¶
type TrainingModelInfo struct {
SupportsLora bool `json:"supports_lora"`
SupportsFullFinetune bool `json:"supports_full_finetune"`
TrainableModalities []string `json:"trainable_modalities"`
Pricing *TrainingPricing `json:"pricing"`
Extensions jmap `json:"extensions"`
}
type TrainingPricing ¶
type TransportError ¶
type TransportError struct{ ErrorMeta }
func (TransportError) ClassName ¶
func (TransportError) ClassName() string
func (TransportError) Code ¶
func (TransportError) Code() string
func (TransportError) Retryable ¶
func (TransportError) Retryable() bool
type TransportRequest ¶
type TransportRequest struct {
Method string
URL string
Params map[string]string
Headers map[string]string
Body jmap
}
TransportRequest is the pure build_request output: the wire request the transport would send. Params are decoded query parameters (PROTOCOL.md: encoding is the transport's responsibility); header names are lowercase.
func BuildRequest ¶
func BuildRequest(provider string, req Request, stream bool, apiKey, baseURL string) (TransportRequest, error)
BuildRequest builds the provider wire request for a canonical Request. baseURL == "" means the provider default.
type UnsupportedFeatureError ¶
type UnsupportedFeatureError struct{ CapabilityError }
func (UnsupportedFeatureError) ClassName ¶
func (UnsupportedFeatureError) ClassName() string
func (UnsupportedFeatureError) Unwrap ¶
func (e UnsupportedFeatureError) Unwrap() error
type UnsupportedModelError ¶
type UnsupportedModelError struct{ InvalidRequestError }
func (UnsupportedModelError) ClassName ¶
func (UnsupportedModelError) ClassName() string
func (UnsupportedModelError) Code ¶
func (UnsupportedModelError) Code() string
func (UnsupportedModelError) Unwrap ¶
func (e UnsupportedModelError) Unwrap() error
type Usage ¶
type Usage struct {
InputTokens *int64 `json:"input_tokens"`
OutputTokens *int64 `json:"output_tokens"`
TotalTokens *int64 `json:"total_tokens"`
CacheReadTokens *int64 `json:"cache_read_tokens"`
CacheWriteTokens *int64 `json:"cache_write_tokens"`
ReasoningTokens *int64 `json:"reasoning_tokens"`
InputAudioTokens *int64 `json:"input_audio_tokens"`
OutputAudioTokens *int64 `json:"output_audio_tokens"`
}
Usage counters are *int64: nil means "not reported by the provider", distinct from a reported 0.
func (Usage) MarshalJSON ¶
func (*Usage) UnmarshalJSON ¶
type VideoPart ¶
type VideoPart struct {
// contains filtered or unexported fields
}
func (VideoPart) Continuations ¶
func (p VideoPart) Continuations() []ContinuationState