Enha: charlist in cards
This commit is contained in:
25
helpfuncs.go
25
helpfuncs.go
@@ -164,7 +164,7 @@ func setLogLevel(sl string) {
|
||||
}
|
||||
|
||||
func listRolesWithUser() []string {
|
||||
roles := chatBody.ListRoles()
|
||||
roles := listChatRoles()
|
||||
// Remove user role if it exists in the list (to avoid duplicates and ensure it's at position 0)
|
||||
filteredRoles := make([]string, 0, len(roles))
|
||||
for _, role := range roles {
|
||||
@@ -250,3 +250,26 @@ func randString(n int) string {
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// set of roles within card definition and mention in chat history
|
||||
func listChatRoles() []string {
|
||||
currentChat, ok := chatMap[activeChatName]
|
||||
cbc := chatBody.ListRoles()
|
||||
if !ok {
|
||||
return cbc
|
||||
}
|
||||
currentCard, ok := sysMap[currentChat.Agent]
|
||||
if !ok {
|
||||
// log error
|
||||
logger.Warn("failed to find current card in sysMap", "agent", currentChat.Agent, "sysMap", sysMap)
|
||||
return cbc
|
||||
}
|
||||
charset := []string{}
|
||||
for _, name := range currentCard.Characters {
|
||||
if !strInSlice(name, cbc) {
|
||||
charset = append(charset, name)
|
||||
}
|
||||
}
|
||||
charset = append(charset, cbc...)
|
||||
return charset
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user