Documentation
¶
Overview ¶
Package generic provides an AIProvider implementation for any OpenAI-compatible API. This can be used with providers like Ollama, Together AI, Fireworks, vLLM, or any other service that implements the OpenAI chat completions API format.
Index ¶
- type Config
- type Provider
- func (p *Provider) Complete(ctx context.Context, req ai.CompletionRequest) (*ai.CompletionResponse, error)
- func (p *Provider) CompleteStream(_ context.Context, _ ai.CompletionRequest) (<-chan ai.StreamChunk, error)
- func (p *Provider) Models() []ai.ModelInfo
- func (p *Provider) Name() string
- func (p *Provider) SupportsToolUse() bool
- func (p *Provider) ToolComplete(ctx context.Context, req ai.ToolCompletionRequest) (*ai.ToolCompletionResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Name is the unique provider name (e.g., "ollama", "together", "fireworks").
Name string
// BaseURL is the base URL for the API (e.g., "http://localhost:11434/v1").
BaseURL string
// APIKey is the bearer token for authentication (optional for local providers).
APIKey string //nolint:gosec // G117: config field
// Models lists the models available from this provider.
Models []ai.ModelInfo
// Headers adds extra HTTP headers to every request.
Headers map[string]string
// SupportsTools indicates whether this provider supports function/tool calling.
SupportsTools bool
}
Config holds configuration for a generic OpenAI-compatible provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements ai.AIProvider for any OpenAI-compatible API.
func (*Provider) Complete ¶
func (p *Provider) Complete(ctx context.Context, req ai.CompletionRequest) (*ai.CompletionResponse, error)
func (*Provider) CompleteStream ¶
func (p *Provider) CompleteStream(_ context.Context, _ ai.CompletionRequest) (<-chan ai.StreamChunk, error)
func (*Provider) SupportsToolUse ¶
func (*Provider) ToolComplete ¶
func (p *Provider) ToolComplete(ctx context.Context, req ai.ToolCompletionRequest) (*ai.ToolCompletionResponse, error)
Click to show internal directories.
Click to hide internal directories.