diff --git a/playerbot/PlayerbotAIConfig.cpp b/playerbot/PlayerbotAIConfig.cpp index d310e75ff..5d72756db 100644 --- a/playerbot/PlayerbotAIConfig.cpp +++ b/playerbot/PlayerbotAIConfig.cpp @@ -609,6 +609,9 @@ bool PlayerbotAIConfig::Initialize() std::replace(llmResponseStartPattern.begin(), llmResponseStartPattern.end(), '\'', '\"'); llmResponseEndPattern = config.GetStringDefault("AiPlayerbot.LLMResponseEndPattern", "\""); std::replace(llmResponseEndPattern.begin(), llmResponseEndPattern.end(), '\'', '\"'); + + llmPreventTalkingForPlayer = config.GetBoolDefault("AiPlayerbot.LLMPreventTalkingForPlayer", false); + //LLM END // Gear progression system diff --git a/playerbot/PlayerbotAIConfig.h b/playerbot/PlayerbotAIConfig.h index dc996d3c1..e7ad12d42 100644 --- a/playerbot/PlayerbotAIConfig.h +++ b/playerbot/PlayerbotAIConfig.h @@ -337,6 +337,7 @@ class PlayerbotAIConfig //LM BEGIN std::string llmApiEndpoint, llmApiKey, llmApiJson, llmPrePrompt, llmPrompt, llmPostPrompt, llmResponseStartPattern, llmResponseEndPattern; uint32 llmContextLength; + bool llmPreventTalkingForPlayer; ParsedUrl llmEndPointUrl; //LM END diff --git a/playerbot/PlayerbotLLMInterface.cpp b/playerbot/PlayerbotLLMInterface.cpp index 60f4c4410..39742f72a 100644 --- a/playerbot/PlayerbotLLMInterface.cpp +++ b/playerbot/PlayerbotLLMInterface.cpp @@ -2,11 +2,6 @@ #include "PlayerbotLLMInterface.h" #include "PlayerbotAIConfig.h" - -#include -#include -#include - #include #include #include @@ -24,9 +19,6 @@ #include #include #endif - - - std::string PlayerbotLLMInterface::Generate(const std::string& prompt) { const int bufferSize = 4096; char buffer[bufferSize]; diff --git a/playerbot/PlayerbotLLMInterface.h b/playerbot/PlayerbotLLMInterface.h index 8a7a2d1fa..1c67cb2ec 100644 --- a/playerbot/PlayerbotLLMInterface.h +++ b/playerbot/PlayerbotLLMInterface.h @@ -1,13 +1,8 @@ -namespace ai +class PlayerbotLLMInterface { - class PlayerbotLLMInterface - { - public: - PlayerbotLLMInterface() {} - static std::string Generate(const std::string& prompt); +public: + PlayerbotLLMInterface() {} + static std::string Generate(const std::string& prompt); - static std::vector ParseResponse(const std::string& response, std::string startPattern, std::string endPattern); - private: - - }; -} \ No newline at end of file + static std::vector ParseResponse(const std::string& response, std::string startPattern, std::string endPattern); +}; \ No newline at end of file diff --git a/playerbot/strategy/actions/SayAction.cpp b/playerbot/strategy/actions/SayAction.cpp index c15075c11..4493ac719 100644 --- a/playerbot/strategy/actions/SayAction.cpp +++ b/playerbot/strategy/actions/SayAction.cpp @@ -204,6 +204,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 placeholders[""] = std::to_string(player->GetLevel()); placeholders[""] = ai->GetChatHelper()->formatClass(player->getClass()); placeholders[""] = ai->GetChatHelper()->formatRace(player->getRace()); + #ifdef MANGOSBOT_ZERO placeholders[""] = "Vanilla"; #endif @@ -279,7 +280,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 json = BOT_TEXT2(json, placeholders); - std::string playerName; + std::string playerName = player->GetName(); uint32 type = CHAT_MSG_WHISPER; @@ -288,7 +289,6 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 case ChatChannelSource::SRC_WHISPER: { type = CHAT_MSG_WHISPER; - playerName = player->GetName(); break; } case ChatChannelSource::SRC_SAY: @@ -321,10 +321,18 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 packet_template << type; packet_template << lang; - if (!playerName.empty()) + if (type == CHAT_MSG_WHISPER) packet_template << playerName; std::string response = PlayerbotLLMInterface::Generate(json); + + if (sPlayerbotAIConfig.llmPreventTalkingForPlayer) + { + size_t pos = response.find(playerName + ":"); + if (pos != std::string::npos) + response = response.substr(0, pos) + sPlayerbotAIConfig.llmResponseEndPattern; + } + std::vector lines = PlayerbotLLMInterface::ParseResponse(response, sPlayerbotAIConfig.llmResponseStartPattern, sPlayerbotAIConfig.llmResponseEndPattern); std::vector packets;