1
0
Fork 0
mirror of https://gitlab.com/niansa/discord_llama.git synced 2025-03-06 20:48:25 +01:00

Give up after timeout

This commit is contained in:
niansa/tuxifan 2023-03-20 11:54:48 +01:00
parent 85753f8f00
commit c6228a280a

View file

@ -186,19 +186,16 @@ class Bot {
// Run model
std::scoped_lock L(llm_lock);
std::string output;
Timer typingIndicatorTimer;
bool timed_out;
do {
Timer timeout;
timed_out = false;
output = LLM().run(prompt, "\n", [&] () {
if (timeout.get<std::chrono::minutes>() > 4) {
timed_out = true;
return false;
}
return true;
});
} while (timed_out);
Timer timeout;
bool timed_out = false;
output = LLM().run(prompt, "\n", [&] () {
if (timeout.get<std::chrono::minutes>() > 4) {
timed_out = true;
return false;
}
return true;
});
if (timed_out) output = "Fehler: Zeitüberschreitung";
// Send resulting message
msg.content = output;
bot.message_edit(msg);