Compare commits
2 Commits
feat/char-
...
875de679cf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
875de679cf | ||
|
|
3b542421e3 |
@@ -167,7 +167,6 @@ func (m *RoleMsg) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *RoleMsg) ToText(i int) string {
|
func (m *RoleMsg) ToText(i int) string {
|
||||||
icon := fmt.Sprintf("(%d)", i)
|
|
||||||
// Convert content to string representation
|
// Convert content to string representation
|
||||||
var contentStr string
|
var contentStr string
|
||||||
if !m.hasContentParts {
|
if !m.hasContentParts {
|
||||||
@@ -193,7 +192,7 @@ func (m *RoleMsg) ToText(i int) string {
|
|||||||
// since icon and content are separated by \n
|
// since icon and content are separated by \n
|
||||||
contentStr, _ = strings.CutPrefix(contentStr, m.Role+":")
|
contentStr, _ = strings.CutPrefix(contentStr, m.Role+":")
|
||||||
// if !strings.HasPrefix(contentStr, m.Role+":") {
|
// if !strings.HasPrefix(contentStr, m.Role+":") {
|
||||||
icon = fmt.Sprintf("(%d) <%s>: ", i, m.Role)
|
icon := fmt.Sprintf("(%d) <%s>: ", i, m.Role)
|
||||||
// }
|
// }
|
||||||
textMsg := fmt.Sprintf("[-:-:b]%s[-:-:-]\n%s\n", icon, contentStr)
|
textMsg := fmt.Sprintf("[-:-:b]%s[-:-:-]\n%s\n", icon, contentStr)
|
||||||
return strings.ReplaceAll(textMsg, "\n\n", "\n")
|
return strings.ReplaceAll(textMsg, "\n\n", "\n")
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table {
|
|||||||
chatList[i] = name
|
chatList[i] = name
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
// Sort chatList by UpdatedAt field in descending order (most recent first)
|
||||||
|
for i := 0; i < len(chatList)-1; i++ {
|
||||||
|
for j := i + 1; j < len(chatList); j++ {
|
||||||
|
if chatMap[chatList[i]].UpdatedAt.Before(chatMap[chatList[j]].UpdatedAt) {
|
||||||
|
// Swap chatList[i] and chatList[j]
|
||||||
|
chatList[i], chatList[j] = chatList[j], chatList[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Add 1 extra row for header
|
// Add 1 extra row for header
|
||||||
rows, cols := len(chatMap)+1, len(actions)+4 // +2 for name, +2 for timestamps
|
rows, cols := len(chatMap)+1, len(actions)+4 // +2 for name, +2 for timestamps
|
||||||
chatActTable := tview.NewTable().
|
chatActTable := tview.NewTable().
|
||||||
|
|||||||
1
tools.go
1
tools.go
@@ -330,6 +330,7 @@ func memorise(args map[string]string) []byte {
|
|||||||
Topic: args["topic"],
|
Topic: args["topic"],
|
||||||
Mind: args["data"],
|
Mind: args["data"],
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
|
CreatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
if _, err := store.Memorise(memory); err != nil {
|
if _, err := store.Memorise(memory); err != nil {
|
||||||
logger.Error("failed to save memory", "err", err, "memoory", memory)
|
logger.Error("failed to save memory", "err", err, "memoory", memory)
|
||||||
|
|||||||
Reference in New Issue
Block a user