summaryrefslogtreecommitdiff
path: root/helpfuncs.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-03 11:46:03 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-03 11:46:03 +0300
commit0e5d37666f92bc75f12f118fc77a7e4af4a5924b (patch)
tree967b9de608288a3cfbd40aaf284b6bd7b640a4b9 /helpfuncs.go
parent093103bdd7cd02e10f2339e7beeb71375fb16256 (diff)
Enha: id for card map
Diffstat (limited to 'helpfuncs.go')
-rw-r--r--helpfuncs.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/helpfuncs.go b/helpfuncs.go
index c407465..dab6b61 100644
--- a/helpfuncs.go
+++ b/helpfuncs.go
@@ -198,7 +198,11 @@ func initSysCards() ([]string, error) {
logger.Warn("empty role", "file", cc.FilePath)
continue
}
- sysMap[cc.Role] = cc
+ if cc.ID == "" {
+ cc.ID = models.ComputeCardID(cc.Role, cc.FilePath)
+ }
+ sysMap[cc.ID] = cc
+ roleToID[cc.Role] = cc.ID
labels = append(labels, cc.Role)
}
return labels, nil
@@ -289,8 +293,8 @@ func listRolesWithUser() []string {
func loadImage() {
filepath := defaultImage
- cc, ok := sysMap[cfg.AssistantRole]
- if ok {
+ cc := GetCardByRole(cfg.AssistantRole)
+ if cc != nil {
if strings.HasSuffix(cc.FilePath, ".png") {
filepath = cc.FilePath
}
@@ -468,13 +472,9 @@ func listChatRoles() []string {
if !ok {
return cbc
}
- currentCard, ok := sysMap[currentChat.Agent]
- if !ok {
- // case which won't let to switch roles:
- // started new chat (basic_sys or any other), at the start it yet be saved or have chatbody
- // if it does not have a card or chars, it'll return an empty slice
- // log error
- logger.Warn("failed to find current card in sysMap", "agent", currentChat.Agent, "sysMap", sysMap)
+ currentCard := GetCardByRole(currentChat.Agent)
+ if currentCard == nil {
+ logger.Warn("failed to find current card", "agent", currentChat.Agent)
return cbc
}
charset := []string{}