Documentation
¶
Overview ¶
Package inference owns provider-neutral inference values and stream events.
Index ¶
- type ChatRequest
- type ChatResponse
- type Choice
- type ChoiceDelta
- type ContentKind
- type ContentPart
- type Embedding
- type EmbeddingInput
- type EmbeddingRequest
- type EmbeddingResponse
- type Image
- type LogProb
- type Message
- type OutputFormat
- type Reasoning
- type ReasoningEffort
- type Role
- type Sampling
- type StreamEvent
- type StreamEventKind
- type StreamOptions
- type StructuredOutput
- type Tool
- type ToolCall
- type ToolChoice
- type ToolChoiceMode
- type TopLogProb
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string
FallbackModels []string
Messages []Message
Sampling Sampling
Tools []Tool
ToolChoice ToolChoice
Output StructuredOutput
Reasoning Reasoning
Stream bool
StreamOptions StreamOptions
User string
Extensions map[string]json.RawMessage
}
ChatRequest is the canonical chat inference request.
func (ChatRequest) Clone ¶
func (r ChatRequest) Clone() ChatRequest
Clone returns an independent request copy.
type ChatResponse ¶
type ChatResponse struct {
ID string
CreatedUnix int64
Model string
ModelUsed string
Choices []Choice
Usage Usage
SystemFingerprint string
}
ChatResponse is the canonical completed chat response.
func (ChatResponse) Clone ¶
func (r ChatResponse) Clone() ChatResponse
Clone returns an independent response copy.
type ChoiceDelta ¶
type ChoiceDelta struct {
Index int
Role Role
Text string
Reasoning string
ToolCalls []ToolCall
LogProbs []LogProb
FinishReason string
}
ChoiceDelta contains one streamed choice update.
type ContentKind ¶
type ContentKind string
ContentKind identifies one message content modality.
const ( // ContentText identifies plain text content. ContentText ContentKind = "text" // ContentImage identifies image content. ContentImage ContentKind = "image" )
type ContentPart ¶
type ContentPart struct {
Kind ContentKind
Text string
Image *Image
CacheControl string
}
ContentPart is one typed part of a message.
type EmbeddingInput ¶
EmbeddingInput is a normalized text or token input batch.
type EmbeddingRequest ¶
type EmbeddingRequest struct {
Model string
Input EmbeddingInput
EncodingFormat string
Dimensions *int
User string
}
EmbeddingRequest is the canonical embedding request.
func (EmbeddingRequest) Clone ¶
func (r EmbeddingRequest) Clone() EmbeddingRequest
Clone returns an independent embedding request copy.
type EmbeddingResponse ¶
EmbeddingResponse is the canonical embedding response.
func (EmbeddingResponse) Clone ¶
func (r EmbeddingResponse) Clone() EmbeddingResponse
Clone returns an independent embedding response copy.
type LogProb ¶
type LogProb struct {
Token string
Value float64
Bytes []int
Top []TopLogProb
}
LogProb reports one token probability and its alternatives.
type Message ¶
type Message struct {
Role Role
Content []ContentPart
Reasoning string
Name string
ToolCalls []ToolCall
ToolCallID string
}
Message is one provider-neutral conversation message.
type OutputFormat ¶
type OutputFormat string
OutputFormat identifies the required model output shape.
const ( // OutputText requests unstructured text output. OutputText OutputFormat = "text" // OutputJSONObject requests one JSON object. OutputJSONObject OutputFormat = "json_object" // OutputJSONSchema requests output that matches a JSON Schema. OutputJSONSchema OutputFormat = "json_schema" )
type Reasoning ¶
type Reasoning struct {
Effort ReasoningEffort
MaxTokens *int
Exclude bool
}
Reasoning configures reasoning-token behavior.
type ReasoningEffort ¶
type ReasoningEffort string
ReasoningEffort identifies the requested reasoning depth.
const ( // ReasoningLow requests the lowest supported reasoning effort. ReasoningLow ReasoningEffort = "low" // ReasoningMedium requests medium reasoning effort. ReasoningMedium ReasoningEffort = "medium" // ReasoningHigh requests high reasoning effort. ReasoningHigh ReasoningEffort = "high" )
type Role ¶
type Role string
Role identifies a message participant.
const ( // RoleSystem identifies a system instruction message. RoleSystem Role = "system" // RoleUser identifies a user message. RoleUser Role = "user" // RoleAssistant identifies a model response message. RoleAssistant Role = "assistant" // RoleTool identifies a tool result message. RoleTool Role = "tool" )
type Sampling ¶
type Sampling struct {
Temperature *float32
TopP *float32
CandidateCount *int
MaxTokens *int
Stop []string
PresencePenalty *float32
FrequencyPenalty *float32
LogitBias map[string]int
Seed *int
}
Sampling contains provider-neutral generation controls.
type StreamEvent ¶
type StreamEvent struct {
Kind StreamEventKind
ID string
CreatedUnix int64
Model string
ModelUsed string
SystemFingerprint string
Deltas []ChoiceDelta
Usage *Usage
}
StreamEvent is one typed provider-neutral stream transition.
func (StreamEvent) Clone ¶
func (e StreamEvent) Clone() StreamEvent
Clone returns an independent stream event copy.
type StreamEventKind ¶
type StreamEventKind string
StreamEventKind identifies a normalized stream transition.
const ( // StreamStart identifies the initial canonical stream event. StreamStart StreamEventKind = "start" // StreamDelta identifies a canonical content update. StreamDelta StreamEventKind = "delta" // StreamUsage identifies a canonical token-usage update. StreamUsage StreamEventKind = "usage" // StreamEnd identifies the terminal canonical stream event. StreamEnd StreamEventKind = "end" )
type StreamOptions ¶
type StreamOptions struct {
IncludeUsage bool
}
StreamOptions configures stream event delivery.
type StructuredOutput ¶
type StructuredOutput struct {
Format OutputFormat
Name string
Description string
Schema json.RawMessage
Strict bool
}
StructuredOutput describes a structured response contract.
type Tool ¶
type Tool struct {
Name string
Description string
Parameters json.RawMessage
}
Tool describes one callable function and its JSON Schema parameters.
type ToolChoice ¶
type ToolChoice struct {
Mode ToolChoiceMode
Name string
}
ToolChoice is an explicit provider-neutral tool selection.
type ToolChoiceMode ¶
type ToolChoiceMode string
ToolChoiceMode selects how the model can call tools.
const ( // ToolChoiceAuto lets the model decide whether to call a tool. ToolChoiceAuto ToolChoiceMode = "auto" // ToolChoiceNone prevents tool calls. ToolChoiceNone ToolChoiceMode = "none" // ToolChoiceRequired requires a tool call. ToolChoiceRequired ToolChoiceMode = "required" // ToolChoiceNamed requires one named tool. ToolChoiceNamed ToolChoiceMode = "named" )
type TopLogProb ¶
TopLogProb reports one alternate token probability.