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

Improved max_words utils function

This commit is contained in:
niansa 2023-04-29 21:47:32 +02:00
parent 2addd816e2
commit 1611b82e37
2 changed files with 4 additions and 4 deletions

View file

@ -420,7 +420,7 @@ private:
+'#'+(config.shard_count!=1?std::to_string(config.shard_id):""); // Shard ID
}
dpp::embed create_chat_embed(dpp::snowflake guild_id, dpp::snowflake thread_id, const std::string& model_name, bool instruct_mode, const dpp::user& author, const std::string& first_message = "") const {
dpp::embed create_chat_embed(dpp::snowflake guild_id, dpp::snowflake thread_id, const std::string& model_name, bool instruct_mode, const dpp::user& author, std::string_view first_message = "") const {
dpp::embed embed;
// Create embed
embed.set_title(create_thread_name(model_name, instruct_mode))
@ -434,7 +434,7 @@ private:
if (shorted.size() != first_message.size()) {
shorted += "...";
}
embed.add_field("", shorted);
embed.description += "\n\n"+shorted;
}
// Return final result
return embed;

View file

@ -39,7 +39,7 @@ std::string_view max_words(std::string_view text, unsigned count) {
// Get idx after last word
for (idx = 0; idx != text.size() && word_count != count; idx++) {
char c = text[idx];
if (c == ' ' || word_len == 7) {
if (c == ' ' || word_len == 8) {
if (word_len != 0) {
word_count++;
word_len = 0;
@ -49,6 +49,6 @@ std::string_view max_words(std::string_view text, unsigned count) {
}
}
// Return resulting string
return {text.data()+idx, text.size()-idx};
return {text.data(), text.size()-idx};
}
}