Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
AnthropicProvider implements Provider for the Anthropic Messages API.
func NewAnthropicProvider ¶
func NewAnthropicProvider(name, model, baseURL, authMethod string, oauthCfg *auth.DeviceFlowConfig, store auth.Store) *AnthropicProvider
NewAnthropicProvider creates a new Anthropic provider adapter. If baseURL is empty, the default Anthropic API URL is used.
func (*AnthropicProvider) Authenticate ¶
func (p *AnthropicProvider) Authenticate() error
func (*AnthropicProvider) ID ¶
func (p *AnthropicProvider) ID() string
func (*AnthropicProvider) Query ¶
func (p *AnthropicProvider) Query(ctx context.Context, messages []Message, opts QueryOpts) (<-chan StreamChunk, error)
func (*AnthropicProvider) Validate ¶
func (p *AnthropicProvider) Validate() error
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider implements Provider for the Google Gemini API.
func NewGeminiProvider ¶
func NewGeminiProvider(name, model, baseURL, authMethod string, oauthCfg *auth.DeviceFlowConfig, store auth.Store) *GeminiProvider
NewGeminiProvider creates a new Gemini provider adapter. If baseURL is empty, the default Gemini API URL is used.
func (*GeminiProvider) Authenticate ¶
func (p *GeminiProvider) Authenticate() error
func (*GeminiProvider) ID ¶
func (p *GeminiProvider) ID() string
func (*GeminiProvider) Query ¶
func (p *GeminiProvider) Query(ctx context.Context, messages []Message, opts QueryOpts) (<-chan StreamChunk, error)
func (*GeminiProvider) Validate ¶
func (p *GeminiProvider) Validate() error
type Message ¶
type Message struct {
Role Role `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // set on assistant messages requesting tools
ToolCallID string `json:"tool_call_id,omitempty"` // set on tool result messages (Role = RoleTool)
}
Message represents a single message in a conversation.
type OpenAICompatProvider ¶
type OpenAICompatProvider struct {
// contains filtered or unexported fields
}
OpenAICompatProvider implements Provider for OpenAI-compatible APIs with a configurable base URL. It reuses the OpenAI SSE parsing logic.
func NewOpenAICompatProvider ¶
func NewOpenAICompatProvider(name, model, baseURL string, authMethod config.AuthMethod, store auth.Store) *OpenAICompatProvider
NewOpenAICompatProvider creates a new OpenAI-compatible provider adapter. The auth method determines whether an Authorization header is sent.
func (*OpenAICompatProvider) Authenticate ¶
func (p *OpenAICompatProvider) Authenticate() error
func (*OpenAICompatProvider) ID ¶
func (p *OpenAICompatProvider) ID() string
func (*OpenAICompatProvider) Query ¶
func (p *OpenAICompatProvider) Query(ctx context.Context, messages []Message, opts QueryOpts) (<-chan StreamChunk, error)
func (*OpenAICompatProvider) Validate ¶
func (p *OpenAICompatProvider) Validate() error
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider implements Provider for the OpenAI Chat Completions API.
func NewOpenAIProvider ¶
func NewOpenAIProvider(name, model, baseURL, authMethod string, oauthCfg *auth.DeviceFlowConfig, store auth.Store) *OpenAIProvider
NewOpenAIProvider creates a new OpenAI provider adapter. If baseURL is empty, the default OpenAI API URL is used.
func (*OpenAIProvider) Authenticate ¶
func (p *OpenAIProvider) Authenticate() error
func (*OpenAIProvider) ID ¶
func (p *OpenAIProvider) ID() string
func (*OpenAIProvider) Query ¶
func (p *OpenAIProvider) Query(ctx context.Context, messages []Message, opts QueryOpts) (<-chan StreamChunk, error)
func (*OpenAIProvider) Validate ¶
func (p *OpenAIProvider) Validate() error
type Provider ¶
type Provider interface {
// ID returns the unique identifier for this provider (from config name).
ID() string
// Query sends messages to the provider and returns a channel of streaming chunks.
Query(ctx context.Context, messages []Message, opts QueryOpts) (<-chan StreamChunk, error)
// Authenticate performs any necessary authentication (API key validation, OAuth flow).
Authenticate() error
// Validate checks that the provider is reachable and properly configured.
Validate() error
}
Provider is the interface that all LLM provider adapters must implement.
type QueryOpts ¶
type QueryOpts struct {
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Tools []ToolDefinition `json:"tools,omitempty"`
ReasoningEffort ReasoningEffort `json:"reasoning_effort,omitempty"`
}
QueryOpts holds options for a query.
type ReasoningEffort ¶ added in v1.11.0
type ReasoningEffort string
ReasoningEffort controls how much "thinking" a model does before responding. Not all models support this — providers that don't will ignore it.
const ( ReasoningOff ReasoningEffort = "" // no reasoning requested (model default) ReasoningLow ReasoningEffort = "low" // minimal reasoning ReasoningMedium ReasoningEffort = "medium" // standard reasoning ReasoningHigh ReasoningEffort = "high" // deep reasoning )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all configured providers and provides access to them.
func NewRegistry ¶
NewRegistry creates a Registry from the application config. It instantiates provider adapters for each entry in config.Providers.
func NewRegistryWithStore ¶
NewRegistryWithStore creates a Registry using the given auth store. This allows callers to pre-populate API keys before creating the registry.
func NewTestRegistry ¶ added in v0.2.0
NewTestRegistry creates a Registry for testing. The primary parameter is the primary provider; all are added to the registry's provider list.
func (*Registry) Healthy ¶
Healthy returns providers that pass Validate(). Providers that fail validation are silently excluded.
type StreamChunk ¶
type StreamChunk struct {
// Delta is the incremental text content.
Delta string
// Done indicates this is the final chunk.
Done bool
// Status indicates this chunk is a progress/status message (not model output).
// Status chunks should be displayed but not persisted to conversation history.
Status bool
// ToolCalls contains any tool calls emitted in the final chunk.
// Only populated when Done is true and the model requested tool use.
ToolCalls []ToolCall
// InputTokens is the total input tokens for this request.
// Only populated when Done is true.
InputTokens int
// OutputTokens is the total output tokens for this response.
// Only populated when Done is true.
OutputTokens int
// Error is set if the provider encountered an error.
Error error
}
StreamChunk represents a single chunk of a streaming response.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments string `json:"arguments"`
ThoughtSignature string `json:"thought_signature,omitempty"` // Gemini thought signature for round-tripping
}
ToolCall represents a tool invocation from the model.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
ToolDefinition defines a tool the model can call.