Documentation
¶
Overview ¶
Package factory provides provider factory functionality for AI providers. It includes registration, creation, and management of different AI provider implementations.
Package factory provides provider registration and factory functions for AI providers. It includes default provider registrations and specialized factory functions.
Package factory provides validation and configuration parsing utilities for AI providers. It includes provider configuration validation and helper functions for config map parsing.
Index ¶
- func CreateChatProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ChatProvider, error)
- func CreateModelProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ModelProvider, error)
- func CreateProviderFromConfig(factory *DefaultProviderFactory, configMap map[string]interface{}) (types.Provider, error)
- func InitializeDefaultProviders(factory *DefaultProviderFactory)
- func RegisterDefaultProviders(factory *DefaultProviderFactory)
- func ValidateProviderConfig(config types.ProviderConfig) error
- type DefaultProviderFactory
- type FactoryMockStream
- type SimpleProviderStub
- func (p *SimpleProviderStub) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
- func (p *SimpleProviderStub) Configure(config types.ProviderConfig) error
- func (p *SimpleProviderStub) Description() string
- func (p *SimpleProviderStub) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
- func (p *SimpleProviderStub) GetConfig() types.ProviderConfig
- func (p *SimpleProviderStub) GetDefaultModel() string
- func (p *SimpleProviderStub) GetMetrics() types.ProviderMetrics
- func (p *SimpleProviderStub) GetModels(ctx context.Context) ([]types.Model, error)
- func (p *SimpleProviderStub) GetToolFormat() types.ToolFormat
- func (p *SimpleProviderStub) HealthCheck(ctx context.Context) error
- func (p *SimpleProviderStub) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
- func (p *SimpleProviderStub) IsAuthenticated() bool
- func (p *SimpleProviderStub) Logout(ctx context.Context) error
- func (p *SimpleProviderStub) Name() string
- func (p *SimpleProviderStub) SupportsResponsesAPI() bool
- func (p *SimpleProviderStub) SupportsStreaming() bool
- func (p *SimpleProviderStub) SupportsToolCalling() bool
- func (p *SimpleProviderStub) Type() types.ProviderType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChatProvider ¶
func CreateChatProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ChatProvider, error)
CreateChatProvider creates a ChatProvider instance. This demonstrates interface segregation - clients can depend only on ChatProvider when they only need chat completion capabilities.
func CreateModelProvider ¶
func CreateModelProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ModelProvider, error)
CreateModelProvider creates a ModelProvider instance. This demonstrates interface segregation - clients can depend only on ModelProvider when they only need model discovery capabilities.
func CreateProviderFromConfig ¶
func CreateProviderFromConfig(factory *DefaultProviderFactory, configMap map[string]interface{}) (types.Provider, error)
func InitializeDefaultProviders ¶
func InitializeDefaultProviders(factory *DefaultProviderFactory)
InitializeDefaultProviders registers stub providers only for providers without real implementations This function is used for testing providers that don't have actual implementations yet. For providers with real implementations, use RegisterDefaultProviders instead.
func RegisterDefaultProviders ¶
func RegisterDefaultProviders(factory *DefaultProviderFactory)
RegisterDefaultProviders registers all default providers with the factory
func ValidateProviderConfig ¶
func ValidateProviderConfig(config types.ProviderConfig) error
Types ¶
type DefaultProviderFactory ¶
type DefaultProviderFactory struct {
// contains filtered or unexported fields
}
DefaultProviderFactory is the default factory implementation
func NewProviderFactory ¶
func NewProviderFactory() *DefaultProviderFactory
NewProviderFactory creates a new provider factory
func (*DefaultProviderFactory) CreateProvider ¶
func (f *DefaultProviderFactory) CreateProvider(providerType types.ProviderType, config types.ProviderConfig) (types.Provider, error)
CreateProvider creates a provider instance
func (*DefaultProviderFactory) GetSupportedProviders ¶
func (f *DefaultProviderFactory) GetSupportedProviders() []types.ProviderType
GetSupportedProviders returns all supported provider types
func (*DefaultProviderFactory) RegisterProvider ¶
func (f *DefaultProviderFactory) RegisterProvider(providerType types.ProviderType, factoryFunc func(types.ProviderConfig) types.Provider)
RegisterProvider registers a new provider type
type FactoryMockStream ¶
type FactoryMockStream struct{}
FactoryMockStream implements types.ChatCompletionStream
func (*FactoryMockStream) Close ¶
func (m *FactoryMockStream) Close() error
func (*FactoryMockStream) Next ¶
func (m *FactoryMockStream) Next() (types.ChatCompletionChunk, error)
type SimpleProviderStub ¶
type SimpleProviderStub struct {
// contains filtered or unexported fields
}
SimpleProviderStub implements types.Provider interface
func (*SimpleProviderStub) Authenticate ¶
func (p *SimpleProviderStub) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
func (*SimpleProviderStub) Configure ¶
func (p *SimpleProviderStub) Configure(config types.ProviderConfig) error
func (*SimpleProviderStub) Description ¶
func (p *SimpleProviderStub) Description() string
func (*SimpleProviderStub) GenerateChatCompletion ¶
func (p *SimpleProviderStub) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
func (*SimpleProviderStub) GetConfig ¶
func (p *SimpleProviderStub) GetConfig() types.ProviderConfig
func (*SimpleProviderStub) GetDefaultModel ¶
func (p *SimpleProviderStub) GetDefaultModel() string
func (*SimpleProviderStub) GetMetrics ¶
func (p *SimpleProviderStub) GetMetrics() types.ProviderMetrics
func (*SimpleProviderStub) GetToolFormat ¶
func (p *SimpleProviderStub) GetToolFormat() types.ToolFormat
func (*SimpleProviderStub) HealthCheck ¶
func (p *SimpleProviderStub) HealthCheck(ctx context.Context) error
func (*SimpleProviderStub) InvokeServerTool ¶
func (p *SimpleProviderStub) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
func (*SimpleProviderStub) IsAuthenticated ¶
func (p *SimpleProviderStub) IsAuthenticated() bool
func (*SimpleProviderStub) Name ¶
func (p *SimpleProviderStub) Name() string
Name returns the provider name
func (*SimpleProviderStub) SupportsResponsesAPI ¶
func (p *SimpleProviderStub) SupportsResponsesAPI() bool
func (*SimpleProviderStub) SupportsStreaming ¶
func (p *SimpleProviderStub) SupportsStreaming() bool
func (*SimpleProviderStub) SupportsToolCalling ¶
func (p *SimpleProviderStub) SupportsToolCalling() bool
func (*SimpleProviderStub) Type ¶
func (p *SimpleProviderStub) Type() types.ProviderType