diff options
| -rw-r--r-- | bot.go | 6 | ||||
| -rw-r--r-- | helpfuncs.go | 4 | ||||
| -rw-r--r-- | tables.go | 6 | ||||
| -rw-r--r-- | tui.go | 2 |
4 files changed, 9 insertions, 9 deletions
@@ -1165,12 +1165,12 @@ func applyCharCard(cc *models.CharCard, loadHistory bool) { chatBody.Messages = history } -func charToStart(agentName string) bool { +func charToStart(agentName string, keepSysP bool) bool { cc, ok := sysMap[agentName] if !ok { return false } - applyCharCard(cc, true) + applyCharCard(cc, keepSysP) return true } @@ -1223,7 +1223,7 @@ func summarizeAndStartNewChat() { return } // Start a new chat - startNewChat() + startNewChat(true) // Inject summary as a tool call response toolMsg := models.RoleMsg{ Role: cfg.ToolRole, diff --git a/helpfuncs.go b/helpfuncs.go index dff53b9..538b4aa 100644 --- a/helpfuncs.go +++ b/helpfuncs.go @@ -121,12 +121,12 @@ func initSysCards() ([]string, error) { return labels, nil } -func startNewChat() { +func startNewChat(keepSysP bool) { id, err := store.ChatGetMaxID() if err != nil { logger.Error("failed to get chat id", "error", err) } - if ok := charToStart(cfg.AssistantRole); !ok { + if ok := charToStart(cfg.AssistantRole, keepSysP); !ok { logger.Warn("no such sys msg", "name", cfg.AssistantRole) } // set chat body @@ -206,8 +206,8 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table { } // Update sysMap with fresh card data sysMap[agentName] = newCard - applyCharCard(newCard, false) - startNewChat() + // fetching sysprompt and first message anew from the card + startNewChat(false) pages.RemovePage(historyPage) return default: @@ -543,7 +543,7 @@ func makeAgentTable(agentList []string) *tview.Table { // notification := fmt.Sprintf("chat: %s; action: %s", selectedChat, tc.Text) switch tc.Text { case "load": - if ok := charToStart(selected); !ok { + if ok := charToStart(selected, true); !ok { logger.Warn("no such sys msg", "name", selected) pages.RemovePage(agentPage) return @@ -1016,7 +1016,7 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlN { - startNewChat() + startNewChat(true) return nil } if event.Key() == tcell.KeyCtrlO { |
