Documentation
¶
Overview ¶
Package troubleshoot provides AI-powered error diagnosis and pattern recognition.
This package analyzes error messages using AI and known patterns to provide root cause analysis and remediation suggestions. Patterns are stored in a shared database for team-wide knowledge sharing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyErrorMessage indicates error message is required ErrEmptyErrorMessage = errors.New("error message cannot be empty") // ErrInvalidConfidence indicates confidence score out of range ErrInvalidConfidence = errors.New("confidence must be between 0.0 and 1.0") )
Functions ¶
This section is empty.
Types ¶
type Diagnosis ¶
type Diagnosis struct {
ErrorMessage string `json:"error_message"`
RootCause string `json:"root_cause"`
Hypotheses []Hypothesis `json:"hypotheses"`
Recommendations []string `json:"recommendations"`
RelatedPatterns []Pattern `json:"related_patterns"`
Confidence float64 `json:"confidence"`
}
Diagnosis represents AI-powered error analysis.
type Hypothesis ¶
type Hypothesis struct {
Description string `json:"description"`
Likelihood float64 `json:"likelihood"`
Evidence string `json:"evidence"`
}
Hypothesis represents a possible cause of the error.
func (*Hypothesis) Validate ¶
func (h *Hypothesis) Validate() error
Validate validates a hypothesis.
type Pattern ¶
type Pattern struct {
ID string `json:"id"`
ErrorType string `json:"error_type"`
Description string `json:"description"`
Solution string `json:"solution"`
Frequency int `json:"frequency"`
Confidence float64 `json:"confidence"`
CreatedAt time.Time `json:"created_at"`
}
Pattern represents a known error pattern with solution.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides AI-powered error diagnosis.
func NewService ¶
NewService creates a new troubleshoot service.
The service uses vector storage for pattern matching and an optional AI client for hypothesis generation. If aiClient is nil, the service will only use pattern-based diagnosis.
func (*Service) Diagnose ¶
Diagnose analyzes an error message and provides diagnosis.
The diagnosis process: 1. Search known patterns for similar errors 2. If high-confidence match (>0.8) found, return pattern-based diagnosis 3. Otherwise, query AI for hypothesis generation 4. Combine pattern matches with AI hypotheses 5. Generate recommendations
func (*Service) GetPatterns ¶
GetPatterns retrieves all known error patterns.
Patterns are sorted by frequency (most common first) and returned with their metadata.
type VectorStore ¶
type VectorStore interface {
AddDocuments(ctx context.Context, docs []vectorstore.Document) error
SearchWithFilters(ctx context.Context, query string, k int, filters map[string]interface{}) ([]vectorstore.SearchResult, error)
}
VectorStore defines the interface for vector database operations.