Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
// Stream sends a request and returns a channel of Chunks.
// The implementation MUST close the channel after the stream ends or errors.
// The implementation MUST respect context cancellation.
Stream(ctx context.Context, req Request) (<-chan Chunk, error)
// Name returns a human-readable identifier for this adapter,
// e.g. "openai", "anthropic", "gemini".
Name() string
}
Adapter translates between the canonical Request/Chunk types and a specific model provider's wire format.
type Chunk ¶
type Chunk struct {
Type ChunkType `json:"type"`
Text string `json:"text,omitempty"`
ReasoningContent string `json:"reasoning_content,omitempty"`
ToolCall *ToolCallDelta `json:"tool_call,omitempty"`
Finish *FinishReason `json:"finish,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Err error `json:"-"`
}
Chunk is a single item from the adapter's stream channel.
type ChunkType ¶
type ChunkType string
ChunkType discriminates the kind of content in a stream chunk.
type FinishReason ¶
type FinishReason struct {
Reason string `json:"reason"`
}
FinishReason is the terminal state of a generation.
type Message ¶
type Message struct {
Role MessageRole `json:"role"`
Content string `json:"content"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
Message is a single turn in the conversation history.
type MessageRole ¶
type MessageRole string
MessageRole distinguishes system, user, assistant, and tool messages.
const ( RoleSystem MessageRole = "system" RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" RoleTool MessageRole = "tool" )
type Request ¶
type Request struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Tools []ToolDef `json:"tools,omitempty"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"`
}
Request is the canonical request sent to the model adapter.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments"`
}
ToolCall represents a tool invocation from the model.
type ToolCallDelta ¶
type ToolCallDelta struct {
ID string `json:"id,omitempty"`
Index int `json:"index"`
Name string `json:"name,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
ToolCallDelta is a partial or complete tool call from the stream.
Click to show internal directories.
Click to hide internal directories.