provider

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoHealthyProvider indicates that no healthy provider is available
	ErrNoHealthyProvider = errors.New("no healthy provider available")
)

Functions

This section is empty.

Types

type HealthStatus

type HealthStatus struct {
	Healthy          bool          // Whether the provider is currently healthy
	LastCheck        time.Time     // When the last health check was performed
	ConsecutiveFails int           // Number of consecutive failures
	Latency          time.Duration // Last observed latency
	ErrorCount       int64         // Total number of errors
	RequestCount     int64         // Total number of requests
}

HealthStatus represents the current health state of a provider

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles LLM provider management and selection

func NewManager

func NewManager(cfg *config.Config, logger *zap.Logger, registry *prometheus.Registry) (*Manager, error)

NewManager creates a new provider manager

func (*Manager) CheckProviderHealth added in v0.0.11

func (m *Manager) CheckProviderHealth(name string, llm gollm.LLM) HealthStatus

CheckProviderHealth performs a health check on a provider

func (*Manager) Execute added in v0.0.11

func (m *Manager) Execute(ctx context.Context, operation func(llm gollm.LLM) error, prompt *gollm.Prompt) error

Execute coordinates provider execution with proper error handling

func (*Manager) GetHealthCheckErrors added in v0.0.11

func (m *Manager) GetHealthCheckErrors() *prometheus.CounterVec

GetHealthCheckErrors returns the health check errors counter for testing

func (*Manager) GetHealthStatus added in v0.0.12

func (m *Manager) GetHealthStatus(name string) HealthStatus

GetHealthStatus returns the health status for a provider

func (*Manager) GetProvider added in v0.0.11

func (m *Manager) GetProvider() (gollm.LLM, error)

GetProvider returns a healthy provider or error if none available

func (*Manager) PerformHealthCheck added in v0.0.12

func (m *Manager) PerformHealthCheck()

PerformHealthCheck performs a health check on all providers

func (*Manager) SetProviders added in v0.0.11

func (m *Manager) SetProviders(providers map[string]gollm.LLM)

SetProviders replaces the current providers with new ones (for testing)

func (*Manager) UpdateHealthStatus added in v0.0.11

func (m *Manager) UpdateHealthStatus(name string, status HealthStatus)

UpdateHealthStatus updates the health status for a provider

Jump to

Keyboard shortcuts

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