Fix (f1): load from the card
This commit is contained in:
6
bot.go
6
bot.go
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user