factory

package
v1.0.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package factory provides the provider factory pattern for creating and managing AI provider instances. It includes provider registration, configuration validation, and dynamic provider instantiation.

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

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

func (*DefaultProviderFactory) SetMetricsCollector added in v1.0.7

func (f *DefaultProviderFactory) SetMetricsCollector(collector types.MetricsCollector)

SetMetricsCollector sets the metrics collector for the factory When set, all providers created by this factory will have the collector configured

type FactoryMockStream

type FactoryMockStream struct{}

FactoryMockStream implements types.ChatCompletionStream

func (*FactoryMockStream) Close

func (m *FactoryMockStream) Close() error

func (*FactoryMockStream) Next

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) GetModels

func (p *SimpleProviderStub) GetModels(ctx context.Context) ([]types.Model, error)

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) Logout

func (p *SimpleProviderStub) Logout(ctx context.Context) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL