Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrModelNotFound = errors.New("model not found") ErrNoMessages = errors.New("no messages provided") )
Functions ¶
func DefaultModel ¶
func DefaultModel(pt ProviderType) string
DefaultModel returns the default model for a provider type.
func DefaultURL ¶
func DefaultURL(pt ProviderType) string
DefaultURL returns the default base URL for a provider type.
func Register ¶
func Register(pt ProviderType, r Registration)
Register adds a provider to the global registry.
Types ¶
type CompletionOptions ¶
type CompletionOptions struct {
Model string
Temperature float32
MaxTokens int // 0 = provider default
TopP float32 // 0 = provider default
}
CompletionOptions configures a completion request. Zero values for MaxTokens and TopP mean "use provider default".
type Provider ¶
type Provider interface {
CreateCompletion(ctx context.Context, messages []Message, opts *CompletionOptions) (string, error)
StreamCompletion(ctx context.Context, messages []Message, opts *CompletionOptions, onResponse func(string)) error
ListModels(ctx context.Context) ([]ModelInfo, error)
Name() string
Description() string
}
Provider defines the interface for AI providers.
type ProviderInfo ¶
type ProviderInfo struct {
Type ProviderType
Name string
Description string
}
ProviderInfo describes an available provider.
func All ¶
func All() []ProviderInfo
All returns info for all registered providers in registration order.
type ProviderType ¶
type ProviderType string
ProviderType identifies a provider implementation.
const ( Ollama ProviderType = "ollama" LocalAI ProviderType = "localai" OpenAI ProviderType = "openai" Groq ProviderType = "groq" Custom ProviderType = "custom" )
Click to show internal directories.
Click to hide internal directories.