Documentation
¶
Index ¶
- func AdjustRuntimeConfidence(baseConf float64, hasPreference bool, providerBias float64, isTimeMatch bool) float64
- func CalculatePreferenceConfidence(successCount, totalCount int, avgQuality float64) float64
- type AnalysisResult
- type LearningEngine
- type ModelPreference
- type PreferenceModel
- type TimePattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustRuntimeConfidence ¶
func AdjustRuntimeConfidence(baseConf float64, hasPreference bool, providerBias float64, isTimeMatch bool) float64
AdjustRuntimeConfidence adjusts a hypothetical runtime confidence based on learned factors. This implements the design doc formula: Base + Pref Boost + Bias + Time
func CalculatePreferenceConfidence ¶
CalculatePreferenceConfidence computes the confidence score for a learned preference. It considers success rate, sample size, and consistency.
Types ¶
type AnalysisResult ¶
type AnalysisResult struct {
UserID string
Timestamp time.Time
RequestsAnalyzed int
NewPreferences *PreferenceModel
Suggestions []string
}
AnalysisResult holds the result of a history analysis run.
type LearningEngine ¶
type LearningEngine struct {
// contains filtered or unexported fields
}
LearningEngine orchestrates learning from routing history.
func NewLearningEngine ¶
func NewLearningEngine(cfg *config.LearningConfig, mem memory.MemoryManager) (*LearningEngine, error)
NewLearningEngine creates a new learning engine.
func (*LearningEngine) AnalyzeAll ¶
func (le *LearningEngine) AnalyzeAll()
AnalyzeAll triggers analysis for all known users.
func (*LearningEngine) AnalyzeUser ¶
func (le *LearningEngine) AnalyzeUser(ctx context.Context, apiKeyHash string) (*AnalysisResult, error)
AnalyzeUser performs deep analysis on a specific user's history.
func (*LearningEngine) ApplyPreferences ¶
func (le *LearningEngine) ApplyPreferences(model *PreferenceModel) error
ApplyPreferences applies learned preferences to the memory system.
func (*LearningEngine) Start ¶
func (le *LearningEngine) Start()
Start starts the background analysis routine.
type ModelPreference ¶
type ModelPreference struct {
Model string `json:"model"`
Confidence float64 `json:"confidence"`
UsageCount int `json:"usage_count"`
SuccessRate float64 `json:"success_rate"`
}
ModelPreference represents a specific preference for a model given an intent.
type PreferenceModel ¶
type PreferenceModel struct {
UserID string `json:"user_id"`
LastUpdated time.Time `json:"last_updated"`
TotalRequests int `json:"total_requests"`
ModelPreferences map[string]*ModelPreference `json:"model_preferences"` // Key: Intent
ProviderBias map[string]float64 `json:"provider_bias"` // Key: Provider, Value: -1.0 to 1.0
TimePatterns map[string]*TimePattern `json:"time_patterns"` // Key: "weekday" or "weekend"
}
PreferenceModel represents a learned model of user preferences.