Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateCost ¶
EstimateCost calculates the approximate cost in cents for a request.
Types ¶
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
func NewAnthropicProvider ¶
func NewAnthropicProvider(apiKey string, client *http.Client) *AnthropicProvider
func (*AnthropicProvider) Chat ¶
func (p *AnthropicProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*AnthropicProvider) ChatStream ¶
func (p *AnthropicProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*AnthropicProvider) Name ¶
func (p *AnthropicProvider) Name() string
type ChatRequest ¶
type ChatResponse ¶
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
func NewGeminiProvider ¶
func NewGeminiProvider(ctx context.Context, apiKey string) (*GeminiProvider, error)
func (*GeminiProvider) Chat ¶
func (p *GeminiProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*GeminiProvider) ChatStream ¶
func (p *GeminiProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
func NewMockProvider ¶
func NewMockProvider(name string) *MockProvider
func (*MockProvider) Chat ¶
func (p *MockProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*MockProvider) ChatStream ¶
func (p *MockProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*MockProvider) Name ¶
func (p *MockProvider) Name() string
type OllamaProvider ¶
type OllamaProvider struct {
// contains filtered or unexported fields
}
func NewOllamaProvider ¶
func NewOllamaProvider(host string) *OllamaProvider
func (*OllamaProvider) Chat ¶
func (p *OllamaProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*OllamaProvider) ChatStream ¶
func (p *OllamaProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*OllamaProvider) Name ¶
func (p *OllamaProvider) Name() string
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey string) *OpenAIProvider
func (*OpenAIProvider) Chat ¶
func (p *OpenAIProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*OpenAIProvider) ChatStream ¶
func (p *OpenAIProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*OpenAIProvider) Name ¶
func (p *OpenAIProvider) Name() string
type Provider ¶
type Provider interface {
// Name returns the provider identifier (e.g., "openai", "anthropic").
Name() string
// Chat dispatches a non-streaming request.
Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
// ChatStream dispatches a streaming request.
// It returns a channel of chunks and a channel for errors.
ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
}
Provider defines the interface for an upstream LLM backend.
type ResilientProvider ¶
type ResilientProvider struct {
// contains filtered or unexported fields
}
ResilientProvider wraps a Provider with retries, timeouts, and circuit breaking logic.
func NewResilientProvider ¶
func NewResilientProvider(base Provider, maxRetries int, timeout time.Duration) *ResilientProvider
func (*ResilientProvider) Chat ¶
func (p *ResilientProvider) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*ResilientProvider) ChatStream ¶
func (p *ResilientProvider) ChatStream(ctx context.Context, req ChatRequest) (<-chan ChatChunk, <-chan error)
func (*ResilientProvider) Name ¶
func (p *ResilientProvider) Name() string
Click to show internal directories.
Click to hide internal directories.