Documentation
¶
Overview ¶
Package examples provides code examples demonstrating how to use the AI Provider Kit's segregated provider interfaces following the Interface Segregation Principle (ISP).
NOTE: This file contains educational examples. The FlexibleMockProvider is a mock implementation for demonstration purposes only and should NOT be used in production.
Index ¶
- type AuthConfig
- type ChatCompletionChunk
- type ChatCompletionStream
- type ChatProvider
- type ChatService
- type CoreProvider
- type FlexibleMockProvider
- func (p *FlexibleMockProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
- func (p *FlexibleMockProvider) Configure(config types.ProviderConfig) error
- func (p *FlexibleMockProvider) Description() string
- func (p *FlexibleMockProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
- func (p *FlexibleMockProvider) GetConfig() types.ProviderConfig
- func (p *FlexibleMockProvider) GetDefaultModel() string
- func (p *FlexibleMockProvider) GetMetrics() types.ProviderMetrics
- func (p *FlexibleMockProvider) GetModels(ctx context.Context) ([]types.Model, error)
- func (p *FlexibleMockProvider) GetToolFormat() types.ToolFormat
- func (p *FlexibleMockProvider) HealthCheck(ctx context.Context) error
- func (p *FlexibleMockProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
- func (p *FlexibleMockProvider) IsAuthenticated() bool
- func (p *FlexibleMockProvider) Logout(ctx context.Context) error
- func (p *FlexibleMockProvider) Name() string
- func (p *FlexibleMockProvider) SupportsResponsesAPI() bool
- func (p *FlexibleMockProvider) SupportsStreaming() bool
- func (p *FlexibleMockProvider) SupportsToolCalling() bool
- func (p *FlexibleMockProvider) Type() types.ProviderType
- type FlexibleMockStream
- type FlexibleProviderFactory
- func (f *FlexibleProviderFactory) CreateChatProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ChatProvider, error)
- func (f *FlexibleProviderFactory) CreateHealthCheckProvider(providerType types.ProviderType, config types.ProviderConfig) (types.HealthCheckProvider, error)
- func (f *FlexibleProviderFactory) CreateModelProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ModelProvider, error)
- type GenerateOptions
- type HealthCheckProvider
- type HealthMonitoringService
- type HealthStatus
- type Model
- type ModelDiscoveryService
- type ModelProvider
- type MultiPurposeService
- type Pricing
- type Provider
- type ProviderConfig
- type ProviderInfo
- type ProviderInfoService
- type ProviderMetrics
- type ProviderType
- type ToolCallingProvider
- type ToolExecutionService
- type ToolFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionChunk ¶
type ChatCompletionChunk = types.ChatCompletionChunk
Re-export commonly used types for convenience
type ChatCompletionStream ¶
type ChatCompletionStream = types.ChatCompletionStream
Re-export commonly used types for convenience
type ChatProvider ¶
type ChatProvider = types.ChatProvider
Re-export commonly used types for convenience
type ChatService ¶
type ChatService struct {
// contains filtered or unexported fields
}
ChatService only needs to generate completions, so it depends only on ChatProvider
func NewChatService ¶
func NewChatService(provider ChatProvider) *ChatService
func (*ChatService) GenerateResponse ¶
func (s *ChatService) GenerateResponse(ctx context.Context, options GenerateOptions) (ChatCompletionStream, error)
type CoreProvider ¶
type CoreProvider = types.CoreProvider
Re-export commonly used types for convenience
type FlexibleMockProvider ¶
type FlexibleMockProvider struct {
// contains filtered or unexported fields
}
FlexibleMockProvider is a mock implementation that satisfies all provider interfaces for demonstration purposes in the FlexibleProviderFactory example.
IMPORTANT: This is an example implementation that returns simulated data. Do NOT use this in production code.
func (*FlexibleMockProvider) Authenticate ¶
func (p *FlexibleMockProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
Authenticate authenticates the mock provider (always succeeds)
func (*FlexibleMockProvider) Configure ¶
func (p *FlexibleMockProvider) Configure(config types.ProviderConfig) error
Configure configures the mock provider with the given config
func (*FlexibleMockProvider) Description ¶
func (p *FlexibleMockProvider) Description() string
func (*FlexibleMockProvider) GenerateChatCompletion ¶
func (p *FlexibleMockProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
GenerateChatCompletion generates a mock chat completion stream
func (*FlexibleMockProvider) GetConfig ¶
func (p *FlexibleMockProvider) GetConfig() types.ProviderConfig
func (*FlexibleMockProvider) GetDefaultModel ¶
func (p *FlexibleMockProvider) GetDefaultModel() string
func (*FlexibleMockProvider) GetMetrics ¶
func (p *FlexibleMockProvider) GetMetrics() types.ProviderMetrics
func (*FlexibleMockProvider) GetToolFormat ¶
func (p *FlexibleMockProvider) GetToolFormat() types.ToolFormat
func (*FlexibleMockProvider) HealthCheck ¶
func (p *FlexibleMockProvider) HealthCheck(ctx context.Context) error
HealthCheck performs a health check on the provider
func (*FlexibleMockProvider) InvokeServerTool ¶
func (p *FlexibleMockProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
func (*FlexibleMockProvider) IsAuthenticated ¶
func (p *FlexibleMockProvider) IsAuthenticated() bool
func (*FlexibleMockProvider) Logout ¶
func (p *FlexibleMockProvider) Logout(ctx context.Context) error
func (*FlexibleMockProvider) Name ¶
func (p *FlexibleMockProvider) Name() string
Name returns the mock provider name
func (*FlexibleMockProvider) SupportsResponsesAPI ¶
func (p *FlexibleMockProvider) SupportsResponsesAPI() bool
SupportsResponsesAPI indicates if the provider supports the responses API
func (*FlexibleMockProvider) SupportsStreaming ¶
func (p *FlexibleMockProvider) SupportsStreaming() bool
SupportsStreaming indicates if the provider supports streaming responses
func (*FlexibleMockProvider) SupportsToolCalling ¶
func (p *FlexibleMockProvider) SupportsToolCalling() bool
SupportsToolCalling returns true for mock provider
func (*FlexibleMockProvider) Type ¶
func (p *FlexibleMockProvider) Type() types.ProviderType
type FlexibleMockStream ¶
type FlexibleMockStream struct {
// contains filtered or unexported fields
}
FlexibleMockStream implements ChatCompletionStream for mock responses
func (*FlexibleMockStream) Close ¶
func (m *FlexibleMockStream) Close() error
func (*FlexibleMockStream) Next ¶
func (m *FlexibleMockStream) Next() (types.ChatCompletionChunk, error)
type FlexibleProviderFactory ¶
type FlexibleProviderFactory struct{}
FlexibleProviderFactory demonstrates how to create providers with different interface requirements.
IMPORTANT: This is an example implementation for educational purposes only. It creates mock providers that return simulated data and should NOT be used in production. For production use, integrate with the actual provider factory implementations.
func (*FlexibleProviderFactory) CreateChatProvider ¶
func (f *FlexibleProviderFactory) CreateChatProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ChatProvider, error)
CreateChatProvider creates a provider that implements only the ChatProvider interface. This allows clients to depend only on chat completion functionality.
func (*FlexibleProviderFactory) CreateHealthCheckProvider ¶
func (f *FlexibleProviderFactory) CreateHealthCheckProvider(providerType types.ProviderType, config types.ProviderConfig) (types.HealthCheckProvider, error)
CreateHealthCheckProvider creates a provider that implements only the HealthCheckProvider interface. This allows clients to depend only on health checking functionality.
func (*FlexibleProviderFactory) CreateModelProvider ¶
func (f *FlexibleProviderFactory) CreateModelProvider(providerType types.ProviderType, config types.ProviderConfig) (types.ModelProvider, error)
CreateModelProvider creates a provider that implements only the ModelProvider interface. This allows clients to depend only on model discovery functionality.
type GenerateOptions ¶
type GenerateOptions = types.GenerateOptions
Re-export commonly used types for convenience
type HealthCheckProvider ¶
type HealthCheckProvider = types.HealthCheckProvider
Re-export commonly used types for convenience
type HealthMonitoringService ¶
type HealthMonitoringService struct {
// contains filtered or unexported fields
}
HealthMonitoringService only needs to check health, so it depends only on HealthCheckProvider
func NewHealthMonitoringService ¶
func NewHealthMonitoringService() *HealthMonitoringService
func (*HealthMonitoringService) AddProvider ¶
func (s *HealthMonitoringService) AddProvider(provider HealthCheckProvider)
func (*HealthMonitoringService) CheckAllHealth ¶
func (s *HealthMonitoringService) CheckAllHealth(ctx context.Context) map[string]error
type HealthStatus ¶
type HealthStatus = types.HealthStatus
Re-export commonly used types for convenience
type ModelDiscoveryService ¶
type ModelDiscoveryService struct {
// contains filtered or unexported fields
}
ModelDiscoveryService only needs to discover models, so it depends only on ModelProvider
func NewModelDiscoveryService ¶
func NewModelDiscoveryService() *ModelDiscoveryService
func (*ModelDiscoveryService) AddProvider ¶
func (s *ModelDiscoveryService) AddProvider(provider ModelProvider)
func (*ModelDiscoveryService) GetAllModels ¶
type MultiPurposeService ¶
type MultiPurposeService struct {
// contains filtered or unexported fields
}
MultiPurposeService demonstrates how to compose multiple interfaces
func NewMultiPurposeService ¶
func NewMultiPurposeService(provider Provider) *MultiPurposeService
func (*MultiPurposeService) GetHealth ¶
func (s *MultiPurposeService) GetHealth(ctx context.Context) error
func (*MultiPurposeService) GetProviderInfo ¶
func (s *MultiPurposeService) GetProviderInfo() string
func (*MultiPurposeService) SupportsTools ¶
func (s *MultiPurposeService) SupportsTools() bool
type ProviderConfig ¶
type ProviderConfig = types.ProviderConfig
Re-export commonly used types for convenience
type ProviderInfo ¶
type ProviderInfo = types.ProviderInfo
Re-export commonly used types for convenience
type ProviderInfoService ¶
type ProviderInfoService struct {
// contains filtered or unexported fields
}
ProviderInfoService only needs basic provider info, so it depends only on CoreProvider
func NewProviderInfoService ¶
func NewProviderInfoService() *ProviderInfoService
func (*ProviderInfoService) AddProvider ¶
func (s *ProviderInfoService) AddProvider(provider CoreProvider)
func (*ProviderInfoService) ListProviders ¶
func (s *ProviderInfoService) ListProviders() []ProviderInfo
type ProviderMetrics ¶
type ProviderMetrics = types.ProviderMetrics
Re-export commonly used types for convenience
type ToolCallingProvider ¶
type ToolCallingProvider = types.ToolCallingProvider
Re-export commonly used types for convenience
type ToolExecutionService ¶
type ToolExecutionService struct {
// contains filtered or unexported fields
}
ToolExecutionService only needs to call tools, so it depends only on ToolCallingProvider
func NewToolExecutionService ¶
func NewToolExecutionService(provider ToolCallingProvider) *ToolExecutionService
func (*ToolExecutionService) ExecuteTool ¶
func (s *ToolExecutionService) ExecuteTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)