Files
eleith a8c5dc5475 feat(ai): Implement multi-call AI grouping and summarization (#56)
This commit enhances the AI view to be more reliable and performant.

The AI digest generation now makes multiple calls to the LLM to create its own primary and sub-groups, replacing the previous single-call, category-based approach. The overview summary has been removed in favor of per-group summaries to manage context length. To improve reliability, the LLM calls for summarization and sub-grouping have been separated, and the timeout handling has been refactored to use a per-try timeout, making it more resilient to transient server errors.

The email template has also been updated to include the primary group summaries, aligning its purpose with the overview HTML page.

Reviewed-on: #56
2025-09-05 19:11:22 +00:00

33 lines
783 B
Go

package utils
import (
"regexp"
"strings"
)
func Slugify(input string) string {
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
if err != nil {
panic(err)
}
processedString := reg.ReplaceAllString(input, " ")
processedString = strings.TrimSpace(processedString)
slug := strings.ReplaceAll(processedString, " ", "-")
slug = strings.ToLower(slug)
return slug
}
// UniqueWords extracts unique words from a string, converts them to lowercase.
func UniqueWords(input string) []string {
words := strings.Fields(strings.ToLower(input))
uniqueMap := make(map[string]bool)
for _, word := range words {
uniqueMap[word] = true
}
uniqueSlice := make([]string, 0, len(uniqueMap))
for word := range uniqueMap {
uniqueSlice = append(uniqueSlice, word)
}
return uniqueSlice
}