inference

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package inference owns provider-neutral inference values and stream events.

Index

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 Choice

type Choice struct {
	Index        int
	Message      Message
	FinishReason string
	LogProbs     []LogProb
}

Choice is one completed model choice.

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 Embedding

type Embedding struct {
	Index  int
	Vector []float32
}

Embedding is one normalized vector.

type EmbeddingInput

type EmbeddingInput struct {
	Texts    []string
	TokenIDs [][]int
}

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

Clone returns an independent embedding request copy.

type EmbeddingResponse

type EmbeddingResponse struct {
	Model string
	Data  []Embedding
	Usage Usage
}

EmbeddingResponse is the canonical embedding response.

func (EmbeddingResponse) Clone

Clone returns an independent embedding response copy.

type Image

type Image struct {
	URL    string
	Detail string
}

Image describes an image input.

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 ToolCall

type ToolCall struct {
	ID        string
	Name      string
	Arguments string
}

ToolCall is one model-requested function call.

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

type TopLogProb struct {
	Token string
	Value float64
	Bytes []int
}

TopLogProb reports one alternate token probability.

type Usage

type Usage struct {
	InputTokens     int
	OutputTokens    int
	TotalTokens     int
	ReasoningTokens int
}

Usage reports normalized token counts.

Jump to

Keyboard shortcuts

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