Documentation
¶
Index ¶
- type Alert
- type AlertEngine
- func (e *AlertEngine) AcknowledgeAlert(alertID string) error
- func (e *AlertEngine) Evaluate(ctx context.Context, evalCtx *EvalContext) []Alert
- func (e *AlertEngine) EvaluateRiskEscalation(ctx context.Context, conversationID string, ...) []Alert
- func (e *AlertEngine) EvaluateSentimentDrop(ctx context.Context, conversationID string, trend *sentiment.Trend) []Alert
- func (e *AlertEngine) EvaluateWaitTime(ctx context.Context, conversationID string, waitTime time.Duration) []Alert
- func (e *AlertEngine) EvaluateWorkload(ctx context.Context, workloads []CounselorWorkload) []Alert
- func (e *AlertEngine) GetAlerts(filter AlertFilter) []Alert
- func (e *AlertEngine) ResolveAlert(alertID string) error
- type AlertFilter
- type AlertRule
- type AlertType
- type Config
- type CounselorWorkload
- type EvalContext
- type Handler
- type LLMProvider
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
ID string `json:"id"`
Type AlertType `json:"type"`
Severity Severity `json:"severity"`
ConversationID string `json:"conversationId,omitempty"`
CounselorID string `json:"counselorId,omitempty"`
Title string `json:"title"`
Description string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
AcknowledgedAt *time.Time `json:"acknowledgedAt,omitempty"`
ResolvedAt *time.Time `json:"resolvedAt,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Alert represents a supervisor alert.
type AlertEngine ¶
type AlertEngine struct {
// contains filtered or unexported fields
}
AlertEngine generates and manages supervisor alerts using a hybrid rule-based + AI approach.
func NewAlertEngine ¶
func NewAlertEngine(provider LLMProvider, cfg Config) *AlertEngine
NewAlertEngine creates a new AlertEngine. If provider is nil, only rule-based detection is used.
func (*AlertEngine) AcknowledgeAlert ¶
func (e *AlertEngine) AcknowledgeAlert(alertID string) error
AcknowledgeAlert marks an alert as acknowledged.
func (*AlertEngine) Evaluate ¶
func (e *AlertEngine) Evaluate(ctx context.Context, evalCtx *EvalContext) []Alert
Evaluate runs all alert rules against the given context and returns any new alerts.
func (*AlertEngine) EvaluateRiskEscalation ¶
func (e *AlertEngine) EvaluateRiskEscalation(ctx context.Context, conversationID string, classification *classifier.Classification) []Alert
EvaluateRiskEscalation checks for risk escalation in a conversation.
func (*AlertEngine) EvaluateSentimentDrop ¶
func (e *AlertEngine) EvaluateSentimentDrop(ctx context.Context, conversationID string, trend *sentiment.Trend) []Alert
EvaluateSentimentDrop checks for sentiment drops in a conversation.
func (*AlertEngine) EvaluateWaitTime ¶
func (e *AlertEngine) EvaluateWaitTime(ctx context.Context, conversationID string, waitTime time.Duration) []Alert
EvaluateWaitTime checks conversation wait times.
func (*AlertEngine) EvaluateWorkload ¶
func (e *AlertEngine) EvaluateWorkload(ctx context.Context, workloads []CounselorWorkload) []Alert
EvaluateWorkload checks workload distribution across counselors.
func (*AlertEngine) GetAlerts ¶
func (e *AlertEngine) GetAlerts(filter AlertFilter) []Alert
GetAlerts returns alerts matching the given filter.
func (*AlertEngine) ResolveAlert ¶
func (e *AlertEngine) ResolveAlert(alertID string) error
ResolveAlert marks an alert as resolved.
type AlertFilter ¶
type AlertFilter struct {
Type *AlertType `json:"type,omitempty"`
Severity *Severity `json:"severity,omitempty"`
ConversationID string `json:"conversationId,omitempty"`
Unresolved bool `json:"unresolved,omitempty"`
Since *time.Time `json:"since,omitempty"`
Limit int `json:"limit,omitempty"`
}
AlertFilter defines criteria for filtering alerts.
type AlertRule ¶
type AlertRule struct {
Type AlertType
Evaluate func(ctx *EvalContext) *Alert
}
AlertRule defines a rule for generating alerts.
type Config ¶
type Config struct {
MaxAlerts int
MaxConversationsPerAgent int
MaxWaitTime time.Duration
OnAlert func(Alert)
}
Config holds configuration for the AlertEngine.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default alert engine configuration.
type CounselorWorkload ¶
type CounselorWorkload struct {
CounselorID string `json:"counselorId"`
ActiveConversations int `json:"activeConversations"`
AverageWaitTime time.Duration `json:"averageWaitTime"`
}
CounselorWorkload represents a counselor's current workload.
type EvalContext ¶
type EvalContext struct {
ConversationID string
CounselorID string
Classification *classifier.Classification
Sentiment *sentiment.Trend
Workloads []CounselorWorkload
WaitTime time.Duration
Timestamp time.Time
}
EvalContext provides data to alert rules during evaluation.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides HTTP handlers for the alerts API.
func NewHandler ¶
func NewHandler(engine *AlertEngine) *Handler
NewHandler creates a new alerts API handler.
func (*Handler) HandleAcknowledge ¶
func (h *Handler) HandleAcknowledge(w http.ResponseWriter, r *http.Request)
HandleAcknowledge handles POST /api/alerts/{id}/acknowledge.
func (*Handler) HandleGetAlerts ¶
func (h *Handler) HandleGetAlerts(w http.ResponseWriter, r *http.Request)
HandleGetAlerts handles GET /api/alerts. Supports query parameters: type, severity, conversationId, unresolved, since, limit.
func (*Handler) HandleResolve ¶
func (h *Handler) HandleResolve(w http.ResponseWriter, r *http.Request)
HandleResolve handles POST /api/alerts/{id}/resolve.
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers the alerts API routes on a ServeMux.