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

5
bot.go
View File

@@ -162,6 +162,7 @@ func chatRound(userMsg, role string, tv *tview.TextView) {
botRespMode = true
reader := formMsg(chatBody, userMsg, role)
go sendMsgToLLM(reader)
fmt.Fprintf(tv, fmt.Sprintf("(%d) ", len(chatBody.Messages)))
fmt.Fprintf(tv, assistantIcon)
respText := strings.Builder{}
out:
@@ -171,6 +172,7 @@ out:
// fmt.Printf(chunk)
fmt.Fprintf(tv, chunk)
respText.WriteString(chunk)
tv.ScrollToEnd()
case <-streamDone:
break out
}
@@ -179,7 +181,6 @@ out:
chatBody.Messages = append(chatBody.Messages, models.MessagesStory{
Role: assistantRole, Content: respText.String(),
})
// TODO:
// bot msg is done;
// now check it for func call
logChat(chatFileLoaded, chatBody.Messages)
@@ -299,7 +300,7 @@ func chatToTextSlice(showSys bool) []string {
if !showSys && (msg.Role != assistantRole && msg.Role != userRole) {
continue
}
resp[i] = msg.ToText()
resp[i] = msg.ToText(i)
}
return resp
}