add online users to prompt

This commit is contained in:
Green Sky 2024-02-07 11:25:22 +01:00
parent d0dfe6b121
commit be58c0cece
No known key found for this signature in database
2 changed files with 11 additions and 2 deletions

View File

@ -18,6 +18,7 @@ TODO: move rpbot to own repo
- System prompt that is prefixed - System prompt that is prefixed
- can contain specific formatters: - can contain specific formatters:
- `{self_name}` username for specified chat - `{self_name}` username for specified chat
- `{online_users}` coma seperated list of online users
- default: `Transcript of a group chat, where {self_name} talks to online strangers.\n{self_name} is creative and curious. {self_name} is writing with precision, but also with occasional typos.\n` - default: `Transcript of a group chat, where {self_name} talks to online strangers.\n{self_name} is creative and curious. {self_name} is writing with precision, but also with occasional typos.\n`
- `RPBot`, `min_messages`(, opt contact ID) - `RPBot`, `min_messages`(, opt contact ID)

View File

@ -62,12 +62,20 @@ void RPBot::stateTransition(const Contact3 c, const StateIdle& from, StateNextAc
to.prompt = _conf.get_string("RPBot", "system_prompt").value(); to.prompt = _conf.get_string("RPBot", "system_prompt").value();
} }
std::string online_users;
for (const auto& [_, name] : mpb.names) {
if (!online_users.empty()) {
online_users += ", ";
}
online_users += name;
}
to.prompt = fmt::format(fmt::runtime(to.prompt), to.prompt = fmt::format(fmt::runtime(to.prompt),
fmt::arg("self_name", to.possible_names.at(self)) fmt::arg("self_name", to.possible_names.at(self)),
//fmt::arg("chat_name", "test_group"), //fmt::arg("chat_name", "test_group"),
//fmt::arg("chat_type", "Group") //fmt::arg("chat_type", "Group")
//fmt::arg("chat_topic", "Group") //fmt::arg("chat_topic", "Group")
// current online? fmt::arg("online_users", online_users)
// current date? // current date?
); );
} }