Use usermappings in chat

If the db contains usermappings for the session these are sent to the LLM instead of generic names.
This commit is contained in:
ET
2025-12-05 14:52:38 +01:00
committed by Rishikanth Chandrasekaran
parent 323e0faea2
commit bde45ddb6a

View File

@@ -467,12 +467,28 @@ func (h *Handler) SendChatMessage(c *gin.Context) {
var sb strings.Builder
// Get speaker mappings
mappings, err := h.speakerMappingRepo.ListByJob(c.Request.Context(), session.TranscriptionID)
speakerMap := make(map[string]string)
if err == nil {
for _, m := range mappings {
speakerMap[m.OriginalSpeaker] = m.CustomName
}
} else {
fmt.Printf("Failed to get speaker mappings for job %s: %v\n", session.TranscriptionID, err)
}
for _, seg := range t.Segments {
start := formatTime(seg.Start)
end := formatTime(seg.End)
speakerName := seg.Speaker
if customName, ok := speakerMap[speakerName]; ok {
speakerName = customName
}
fmt.Fprintf(&sb, "[%s] [%s - %s] %s\n",
seg.Speaker,
speakerName,
start,
end,
strings.TrimSpace(seg.Text),