package main import ( "github.com/sirupsen/logrus" ) // logRequest logs incoming chat requests and extracted info func logRequest(req ChatRequest, keywords map[string]interface{}, candidates []Reason, bestID string, err error) { logrus.WithFields(logrus.Fields{ "message": req.Message, "keywords": keywords, "candidates": getCandidateIDs(candidates), "bestID": bestID, "err": err, }).Info("Chat request trace") } func getCandidateIDs(candidates []Reason) []string { ids := make([]string, len(candidates)) for i, c := range candidates { ids[i] = c.ID } return ids } // Procedure represents a single procedure for a visit reason type Procedure struct { Name string `yaml:"name" json:"name"` Price int `yaml:"price" json:"price"` DurationMin int `yaml:"duration_minutes" json:"duration_minutes"` } // Reason represents a visit reason entry type Reason struct { ID string `yaml:"id" json:"id"` Reason string `yaml:"reason" json:"reason"` Keywords []string `yaml:"keywords" json:"keywords"` Procedures []Procedure `yaml:"procedures" json:"procedures"` Notes string `yaml:"notes" json:"notes,omitempty"` } // ChatRequest represents the incoming chat message type ChatRequest struct { Message string `json:"message"` } // ChatResponse represents the response to the frontend type ChatResponse struct { Match *string `json:"match"` Procedures []Procedure `json:"procedures,omitempty"` TotalPrice int `json:"total_price,omitempty"` TotalDuration int `json:"total_duration,omitempty"` Notes string `json:"notes,omitempty"` }