Feat: load char/agent; agent-chat flow

This commit is contained in:
Grail Finder
2024-12-09 19:26:26 +03:00
parent bdd40ea8df
commit 67f36d417f
5 changed files with 119 additions and 40 deletions

View File

@@ -79,6 +79,24 @@ func loadHistoryChat(chatName string) ([]models.RoleMsg, error) {
return chat.ToHistory()
}
func loadAgentsLastChat(agent string) ([]models.RoleMsg, error) {
chat, err := store.GetLastChatByAgent(agent)
if err != nil {
return nil, err
}
history, err := chat.ToHistory()
if err != nil {
return nil, err
}
if chat.Name == "" {
logger.Warn("empty chat name", "id", chat.ID)
chat.Name = fmt.Sprintf("%s_%d", chat.Agent, chat.ID)
}
chatMap[chat.Name] = chat
activeChatName = chat.Name
return history, nil
}
func loadOldChatOrGetNew() []models.RoleMsg {
newChat := &models.Chat{
ID: 0,