chore: initial commit

This commit is contained in:
whlaoding
2026-02-21 23:01:39 +08:00
commit c2bebb3457
21 changed files with 1913 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package memory
import "strings"
func CompressForPrompt(messages []Message, maxChars int) string {
if maxChars <= 0 {
maxChars = 8000
}
builder := strings.Builder{}
for _, msg := range messages {
line := msg.Role + ": " + msg.Content + "\n"
if builder.Len()+len(line) > maxChars {
break
}
builder.WriteString(line)
}
return builder.String()
}