actually reactive

This commit is contained in:
Green Sky 2024-01-29 23:08:54 +01:00
parent 283d3ad575
commit eba657c484
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -27,6 +27,7 @@ LlamaCppWeb::~LlamaCppWeb(void) {
} }
bool LlamaCppWeb::isGood(void) { bool LlamaCppWeb::isGood(void) {
//return true; // HACK: test old llama server
auto res = _cli.Get("/health"); auto res = _cli.Get("/health");
if ( if (
res.error() != httplib::Error::Success || res.error() != httplib::Error::Success ||
@ -122,7 +123,7 @@ std::string LlamaCppWeb::completeLine(const std::string_view prompt) {
{"temperature", 0.9}, // depends 1.0 for chat models {"temperature", 0.9}, // depends 1.0 for chat models
{"top_k", 60}, {"top_k", 60},
{"top_p", 1.0}, // disable {"top_p", 1.0}, // disable
{"n_predict", 1000}, {"n_predict", 400},
{"seed", _rng()}, {"seed", _rng()},
{"stop", {"\n"}}, {"stop", {"\n"}},
{"cache_prompt", static_cast<bool>(_use_server_cache)}, {"cache_prompt", static_cast<bool>(_use_server_cache)},

View File

@ -96,7 +96,7 @@ void RPBot::stateTransition(const Contact3 c, const StateIdle& from, StateNextAc
template<> template<>
void RPBot::stateTransition(const Contact3, const StateNextActor&, StateIdle& to) { void RPBot::stateTransition(const Contact3, const StateNextActor&, StateIdle& to) {
to.timeout = std::uniform_real_distribution<>{10.f, 45.f}(_rng); to.timeout = std::uniform_real_distribution<>{30.f, 5.f*60.f}(_rng);
} }
template<> template<>
@ -142,6 +142,8 @@ R"sys(Transcript of a group chat, where {self_name} talks to online strangers.
assert(_conf.has_string("RPBot", "system_prompt")); assert(_conf.has_string("RPBot", "system_prompt"));
registerCommands(); registerCommands();
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
} }
float RPBot::tick(float time_delta) { float RPBot::tick(float time_delta) {
@ -279,6 +281,10 @@ bool RPBot::onEvent(const Message::Events::MessageConstruct& e) {
return false; return false;
} }
if (_cr.any_of<Contact::Components::TagSelfStrong>(contact_from)) {
return false; // ignore own messages
}
Contact3 rpbot_contact = entt::null; Contact3 rpbot_contact = entt::null;
// check ContactTo (public) // check ContactTo (public)
@ -302,6 +308,7 @@ bool RPBot::onEvent(const Message::Events::MessageConstruct& e) {
auto& timeout = _cr.get<StateIdle>(rpbot_contact).timeout; auto& timeout = _cr.get<StateIdle>(rpbot_contact).timeout;
// TODO: config with id // TODO: config with id
timeout = std::min<float>(timeout, _conf.get_double("RPBot", "max_interactive_delay").value_or(4.f)); timeout = std::min<float>(timeout, _conf.get_double("RPBot", "max_interactive_delay").value_or(4.f));
std::cout << "RPBot: onMsg new timeout: " << timeout << "\n";
return false; return false;
} }