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
|
chatBody.Messages = history
|
||||||
}
|
}
|
||||||
|
|
||||||
func charToStart(agentName string) bool {
|
func charToStart(agentName string, keepSysP bool) bool {
|
||||||
cc, ok := sysMap[agentName]
|
cc, ok := sysMap[agentName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
applyCharCard(cc, true)
|
applyCharCard(cc, keepSysP)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1223,7 +1223,7 @@ func summarizeAndStartNewChat() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Start a new chat
|
// Start a new chat
|
||||||
startNewChat()
|
startNewChat(true)
|
||||||
// Inject summary as a tool call response
|
// Inject summary as a tool call response
|
||||||
toolMsg := models.RoleMsg{
|
toolMsg := models.RoleMsg{
|
||||||
Role: cfg.ToolRole,
|
Role: cfg.ToolRole,
|
||||||
|
|||||||
@@ -121,12 +121,12 @@ func initSysCards() ([]string, error) {
|
|||||||
return labels, nil
|
return labels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startNewChat() {
|
func startNewChat(keepSysP bool) {
|
||||||
id, err := store.ChatGetMaxID()
|
id, err := store.ChatGetMaxID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("failed to get chat id", "error", err)
|
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)
|
logger.Warn("no such sys msg", "name", cfg.AssistantRole)
|
||||||
}
|
}
|
||||||
// set chat body
|
// set chat body
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table {
|
|||||||
}
|
}
|
||||||
// Update sysMap with fresh card data
|
// Update sysMap with fresh card data
|
||||||
sysMap[agentName] = newCard
|
sysMap[agentName] = newCard
|
||||||
applyCharCard(newCard, false)
|
// fetching sysprompt and first message anew from the card
|
||||||
startNewChat()
|
startNewChat(false)
|
||||||
pages.RemovePage(historyPage)
|
pages.RemovePage(historyPage)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
@@ -543,7 +543,7 @@ func makeAgentTable(agentList []string) *tview.Table {
|
|||||||
// notification := fmt.Sprintf("chat: %s; action: %s", selectedChat, tc.Text)
|
// notification := fmt.Sprintf("chat: %s; action: %s", selectedChat, tc.Text)
|
||||||
switch tc.Text {
|
switch tc.Text {
|
||||||
case "load":
|
case "load":
|
||||||
if ok := charToStart(selected); !ok {
|
if ok := charToStart(selected, true); !ok {
|
||||||
logger.Warn("no such sys msg", "name", selected)
|
logger.Warn("no such sys msg", "name", selected)
|
||||||
pages.RemovePage(agentPage)
|
pages.RemovePage(agentPage)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user