Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string
Thinking Thinking
Tools []*ToolSchema
Messages []*Message
}
type ChatResponse ¶
type ChatResponse struct {
Role string `json:"role,omitzero"`
Content string `json:"content,omitzero"` // Content chunk
Thinking string `json:"thinking,omitzero"` // Thinking/reasoning content (if any)
ToolCall *ToolCall `json:"tool_call,omitzero"`
ToolCallID string `json:"tool_call_id,omitzero"` // For tool results, the ID of the tool call being responded to
Usage *Usage `json:"usage,omitzero"` // Token usage metadata (if available)
Done bool `json:"done,omitzero"` // True when response is complete
}
ChatResponse represents a streaming response from the chat API
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages providers
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, provider string, options ...Option) iter.Seq2[*ChatResponse, error]
Chat sends a chat request to the appropriate provider
type ErrMultipleModels ¶
func (*ErrMultipleModels) Error ¶
func (e *ErrMultipleModels) Error() string
type Message ¶
type Message struct {
Role string `json:"role,omitzero"`
Content string `json:"content,omitzero"`
Thinking string `json:"thinking,omitzero"` // For chain-of-thought / thinking content
ToolCall *ToolCall `json:"tool_call,omitzero"` // For assistant messages that invoke a tool
ToolCallID string `json:"tool_call_id,omitzero"` // For tool results, the ID of the tool call being responded to
}
Message represents a chat message
func AssistantMessage ¶
AssistantMessage creates an assistant message
func SystemMessage ¶
SystemMessage creates a system message
type Model ¶
type Model struct {
Provider string // Provider name
ID string // Model identifier
Meta *ModelMeta // Model metadata (nil if not available)
}
Model represents an available model
type ModelMeta ¶ added in v0.2.4
type ModelMeta struct {
DisplayName string // Human-friendly name for the model (if available)
KnowledgeCutoff time.Time // Zero time if unknown
ContextWindow int // Maximum context window in tokens
MaxOutputTokens int // Maximum output tokens (if known)
HasReasoning bool // Whether the model supports chain-of-thought / reasoning
}
Manually curated information about the model
type Option ¶
type Option func(*Config)
func WithMaxSteps ¶
WithMaxSteps sets the maximum number of steps in a turn
func WithMessage ¶
WithMessages sets initial conversation history
func WithThinking ¶
WithThinking sets the extended thinking level. Supported values: ThinkingLow, ThinkingMedium, ThinkingHigh. Default is ThinkingMedium if not specified.
type Provider ¶
type Provider interface {
Name() string
Model(ctx context.Context, id string) (*Model, error)
Models(ctx context.Context) ([]*Model, error)
Chat(ctx context.Context, req *ChatRequest) iter.Seq2[*ChatResponse, error]
}
Provider interface
type Tool ¶
type Tool interface {
Schema() *ToolSchema
Run(ctx context.Context, in json.RawMessage) (out []byte, err error)
}
Tool interface - high-level typed tool definition
type ToolCall ¶
type ToolCall struct {
ID string `json:"id,omitzero"`
Name string `json:"name,omitzero"`
Arguments json.RawMessage `json:"arguments,omitzero"`
ThoughtSignature []byte `json:"thought_signature,omitzero"`
}
ToolCall represents a tool invocation from the model
type ToolFunction ¶
type ToolFunction struct {
Name string
Description string
Parameters *ToolFunctionParameters
}
ToolFunction defines the function details for a tool
type ToolFunctionParameters ¶
type ToolFunctionParameters struct {
Type string
Properties map[string]*ToolProperty
Required []string
}
ToolFunctionParameters defines the parameters schema for a tool
type ToolProperty ¶
type ToolProperty struct {
Type string
Description string
Enum []string
Items *ToolProperty
}
ToolProperty defines a single property in the tool schema
type ToolSchema ¶
type ToolSchema struct {
Type string
Function *ToolFunction
}
ToolSchema defines a tool's JSON schema specification
type Usage ¶ added in v0.2.5
type Usage struct {
InputTokens int `json:"input_tokens,omitzero"`
OutputTokens int `json:"output_tokens,omitzero"`
TotalTokens int `json:"total_tokens,omitzero"`
CachedInputTokens int `json:"cached_input_tokens,omitzero"`
ReasoningTokens int `json:"reasoning_tokens,omitzero"`
}
Usage represents token usage for a single model response.