diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-28 08:09:56 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-28 08:09:56 +0300 |
| commit | 83f99d3577052b57fd9470cafaddc1ae3bcb8a2f (patch) | |
| tree | 4b9f4ca9e04e4add8034fb86ee11b9b9116fe5bc /session.go | |
| parent | e52143407367e54f5b04177957f5f0436e28718b (diff) | |
Enha: first chat name convention
Diffstat (limited to 'session.go')
| -rw-r--r-- | session.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -131,13 +131,18 @@ func loadOldChatOrGetNew() []models.RoleMsg { chat, err := store.GetLastChat() if err != nil { logger.Warn("failed to load history chat", "error", err) + maxID, err := store.ChatGetMaxID() + if err != nil { + logger.Error("failed to fetch max chat id", "error", err) + } + maxID++ chat := &models.Chat{ - ID: 0, + ID: maxID, CreatedAt: time.Now(), UpdatedAt: time.Now(), Agent: cfg.AssistantRole, } - chat.Name = fmt.Sprintf("%s_%v", chat.Agent, chat.CreatedAt.Unix()) + chat.Name = fmt.Sprintf("%s_%v", chat.Agent, chat.ID) activeChatName = chat.Name chatMap[chat.Name] = chat return defaultStarter @@ -149,10 +154,6 @@ func loadOldChatOrGetNew() []models.RoleMsg { chatMap[chat.Name] = chat return defaultStarter } - // if chat.Name == "" { - // logger.Warn("empty chat name", "id", chat.ID) - // chat.Name = fmt.Sprintf("%s_%v", chat.Agent, chat.CreatedAt.Unix()) - // } chatMap[chat.Name] = chat activeChatName = chat.Name cfg.AssistantRole = chat.Agent |
