Documentation
¶
Overview ¶
Package base provides common functionality and utilities for AI providers. It includes base implementations, shared components, and standardized patterns that can be used by specific provider implementations.
Index ¶
- type BaseProvider
- func (p *BaseProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
- func (p *BaseProvider) Configure(config types.ProviderConfig) error
- func (p *BaseProvider) Description() string
- func (p *BaseProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
- func (p *BaseProvider) GetConfig() types.ProviderConfig
- func (p *BaseProvider) GetDefaultModel() string
- func (p *BaseProvider) GetMetrics() types.ProviderMetrics
- func (p *BaseProvider) GetModels(ctx context.Context) ([]types.Model, error)
- func (p *BaseProvider) GetToolFormat() types.ToolFormat
- func (p *BaseProvider) HealthCheck(ctx context.Context) error
- func (p *BaseProvider) IncrementRequestCount()
- func (p *BaseProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
- func (p *BaseProvider) IsAuthenticated() bool
- func (p *BaseProvider) LogRequest(method, url string, headers map[string]string, body interface{})
- func (p *BaseProvider) LogResponse(resp *http.Response, duration time.Duration)
- func (p *BaseProvider) Logout(ctx context.Context) error
- func (p *BaseProvider) Name() string
- func (p *BaseProvider) RecordError(err error)
- func (p *BaseProvider) RecordSuccess(latency time.Duration, tokensUsed int64)
- func (p *BaseProvider) SupportsResponsesAPI() bool
- func (p *BaseProvider) SupportsStreaming() bool
- func (p *BaseProvider) SupportsToolCalling() bool
- func (p *BaseProvider) Type() types.ProviderType
- func (p *BaseProvider) UpdateConfig(config types.ProviderConfig)
- func (p *BaseProvider) UpdateHealthStatus(healthy bool, message string)
- func (p *BaseProvider) UpdateHealthStatusResponseTime(responseTime float64)
- type BaseProviderStub
- func (b *BaseProviderStub) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
- func (b *BaseProviderStub) Configure(config types.ProviderConfig) error
- func (b *BaseProviderStub) Description() string
- func (b *BaseProviderStub) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
- func (b *BaseProviderStub) GetConfig() types.ProviderConfig
- func (b *BaseProviderStub) GetDefaultModel() string
- func (b *BaseProviderStub) GetMetrics() types.ProviderMetrics
- func (b *BaseProviderStub) GetModels(ctx context.Context) ([]types.Model, error)
- func (b *BaseProviderStub) GetToolFormat() types.ToolFormat
- func (b *BaseProviderStub) HealthCheck(ctx context.Context) error
- func (b *BaseProviderStub) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
- func (b *BaseProviderStub) IsAuthenticated() bool
- func (b *BaseProviderStub) Logout(ctx context.Context) error
- func (b *BaseProviderStub) Name() string
- func (b *BaseProviderStub) SupportsResponsesAPI() bool
- func (b *BaseProviderStub) SupportsStreaming() bool
- func (b *BaseProviderStub) SupportsToolCalling() bool
- func (b *BaseProviderStub) Type() types.ProviderType
- type MockStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseProvider ¶
type BaseProvider struct {
// contains filtered or unexported fields
}
BaseProvider provides common functionality for all providers
func NewBaseProvider ¶
func NewBaseProvider(name string, config types.ProviderConfig, client *http.Client, logger *log.Logger) *BaseProvider
NewBaseProvider creates a new base provider
func (*BaseProvider) Authenticate ¶
func (p *BaseProvider) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
Authenticate handles API key authentication
func (*BaseProvider) Configure ¶
func (p *BaseProvider) Configure(config types.ProviderConfig) error
Configure updates the provider configuration
func (*BaseProvider) Description ¶
func (p *BaseProvider) Description() string
func (*BaseProvider) GenerateChatCompletion ¶
func (p *BaseProvider) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
GenerateChatCompletion generates a mock chat completion
func (*BaseProvider) GetConfig ¶
func (p *BaseProvider) GetConfig() types.ProviderConfig
GetConfig returns the current provider configuration
func (*BaseProvider) GetDefaultModel ¶
func (p *BaseProvider) GetDefaultModel() string
func (*BaseProvider) GetMetrics ¶
func (p *BaseProvider) GetMetrics() types.ProviderMetrics
func (*BaseProvider) GetToolFormat ¶
func (p *BaseProvider) GetToolFormat() types.ToolFormat
func (*BaseProvider) HealthCheck ¶
func (p *BaseProvider) HealthCheck(ctx context.Context) error
func (*BaseProvider) IncrementRequestCount ¶
func (p *BaseProvider) IncrementRequestCount()
IncrementRequestCount increments the request counter
func (*BaseProvider) InvokeServerTool ¶
func (p *BaseProvider) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
InvokeServerTool invokes a server tool (not implemented in base provider)
func (*BaseProvider) IsAuthenticated ¶
func (p *BaseProvider) IsAuthenticated() bool
func (*BaseProvider) LogRequest ¶
func (p *BaseProvider) LogRequest(method, url string, headers map[string]string, body interface{})
LogRequest logs an HTTP request
func (*BaseProvider) LogResponse ¶
func (p *BaseProvider) LogResponse(resp *http.Response, duration time.Duration)
LogResponse logs detailed response information
func (*BaseProvider) Name ¶
func (p *BaseProvider) Name() string
func (*BaseProvider) RecordError ¶
func (p *BaseProvider) RecordError(err error)
RecordError records a failed API call
func (*BaseProvider) RecordSuccess ¶
func (p *BaseProvider) RecordSuccess(latency time.Duration, tokensUsed int64)
RecordSuccess records a successful API call
func (*BaseProvider) SupportsResponsesAPI ¶
func (p *BaseProvider) SupportsResponsesAPI() bool
func (*BaseProvider) SupportsStreaming ¶
func (p *BaseProvider) SupportsStreaming() bool
func (*BaseProvider) SupportsToolCalling ¶
func (p *BaseProvider) SupportsToolCalling() bool
func (*BaseProvider) Type ¶
func (p *BaseProvider) Type() types.ProviderType
func (*BaseProvider) UpdateConfig ¶
func (p *BaseProvider) UpdateConfig(config types.ProviderConfig)
UpdateConfig updates provider configuration
func (*BaseProvider) UpdateHealthStatus ¶
func (p *BaseProvider) UpdateHealthStatus(healthy bool, message string)
UpdateHealthStatus updates the health status
func (*BaseProvider) UpdateHealthStatusResponseTime ¶
func (p *BaseProvider) UpdateHealthStatusResponseTime(responseTime float64)
UpdateHealthStatusResponseTime updates the health status response time
type BaseProviderStub ¶
type BaseProviderStub struct {
*BaseProvider
}
BaseProviderStub wraps BaseProvider to implement Provider interface
func NewBaseProviderStub ¶
func NewBaseProviderStub(name string, config types.ProviderConfig, client *http.Client, logger *log.Logger) *BaseProviderStub
func (*BaseProviderStub) Authenticate ¶
func (b *BaseProviderStub) Authenticate(ctx context.Context, authConfig types.AuthConfig) error
func (*BaseProviderStub) Configure ¶
func (b *BaseProviderStub) Configure(config types.ProviderConfig) error
func (*BaseProviderStub) Description ¶
func (b *BaseProviderStub) Description() string
func (*BaseProviderStub) GenerateChatCompletion ¶
func (b *BaseProviderStub) GenerateChatCompletion(ctx context.Context, options types.GenerateOptions) (types.ChatCompletionStream, error)
func (*BaseProviderStub) GetConfig ¶
func (b *BaseProviderStub) GetConfig() types.ProviderConfig
func (*BaseProviderStub) GetDefaultModel ¶
func (b *BaseProviderStub) GetDefaultModel() string
func (*BaseProviderStub) GetMetrics ¶
func (b *BaseProviderStub) GetMetrics() types.ProviderMetrics
func (*BaseProviderStub) GetToolFormat ¶
func (b *BaseProviderStub) GetToolFormat() types.ToolFormat
func (*BaseProviderStub) HealthCheck ¶
func (b *BaseProviderStub) HealthCheck(ctx context.Context) error
func (*BaseProviderStub) InvokeServerTool ¶
func (b *BaseProviderStub) InvokeServerTool(ctx context.Context, toolName string, params interface{}) (interface{}, error)
func (*BaseProviderStub) IsAuthenticated ¶
func (b *BaseProviderStub) IsAuthenticated() bool
func (*BaseProviderStub) Name ¶
func (b *BaseProviderStub) Name() string
Name returns the stub provider name
func (*BaseProviderStub) SupportsResponsesAPI ¶
func (b *BaseProviderStub) SupportsResponsesAPI() bool
func (*BaseProviderStub) SupportsStreaming ¶
func (b *BaseProviderStub) SupportsStreaming() bool
func (*BaseProviderStub) SupportsToolCalling ¶
func (b *BaseProviderStub) SupportsToolCalling() bool
func (*BaseProviderStub) Type ¶
func (b *BaseProviderStub) Type() types.ProviderType
type MockStream ¶
type MockStream struct {
// contains filtered or unexported fields
}
MockStream implementation
func (*MockStream) Close ¶
func (ms *MockStream) Close() error
func (*MockStream) Next ¶
func (ms *MockStream) Next() (types.ChatCompletionChunk, error)