Feat: add msg index

This commit is contained in:
Grail Finder
2024-11-16 16:19:27 +03:00
parent 1fe807de8e
commit b2c8698926
4 changed files with 64 additions and 22 deletions

View File

@@ -61,17 +61,17 @@ type MessagesStory struct {
Content string `json:"content"`
}
func (m MessagesStory) ToText() string {
func (m MessagesStory) ToText(i int) string {
icon := ""
switch m.Role {
case "assistant":
icon = "<🤖>: "
icon = fmt.Sprintf("(%d) <🤖>: ", i)
case "user":
icon = "<user>: "
icon = fmt.Sprintf("(%d) <user>: ", i)
case "system":
icon = "<system>: "
icon = fmt.Sprintf("(%d) <system>: ", i)
case "tool":
icon = "<tool>: "
icon = fmt.Sprintf("(%d) <tool>: ", i)
}
textMsg := fmt.Sprintf("%s%s\n", icon, m.Content)
return strings.ReplaceAll(textMsg, "\n\n", "\n")