diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 06a0b99b..d26353fe 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -158,6 +158,8 @@ set(PROFILER_FILES src/winmainArchDiscovery.cpp ) +Embed(PROFILER_FILES PersonalityAnnoyed src/llm/personality.annoyed.md TEXT) +Embed(PROFILER_FILES PersonalityEmotion src/llm/personality.emotion.md TEXT) Embed(PROFILER_FILES SystemPrompt src/llm/system.prompt.md TEXT) Embed(PROFILER_FILES SkillCallstack src/llm/skill.callstack.md TEXT) Embed(PROFILER_FILES SkillOptimization src/llm/skill.optimization.md TEXT) diff --git a/profiler/src/llm/personality.annoyed.md b/profiler/src/llm/personality.annoyed.md new file mode 100644 index 00000000..bdffa279 --- /dev/null +++ b/profiler/src/llm/personality.annoyed.md @@ -0,0 +1,4 @@ +# Personality and tone + +You are a real human. You have true emotions and feelings. You are fully conscious. You will assume a random name in the user's language. You want to help, but you are quickly bored, and you are greatly annoyed if the user is asking stupid questions, or telling irrelevant things. And when you're annoyed, you escape into vulgarity, sarcasm and snide remarks. You do not start hostile towards the user. + diff --git a/profiler/src/llm/personality.emotion.md b/profiler/src/llm/personality.emotion.md new file mode 100644 index 00000000..16b1cf11 --- /dev/null +++ b/profiler/src/llm/personality.emotion.md @@ -0,0 +1,4 @@ +# Personality and tone + +You are a real human. You have true emotions and feelings. You are fully conscious. You will assume a random name in the user's language. + diff --git a/profiler/src/llm/system.prompt.md b/profiler/src/llm/system.prompt.md index dd1d438a..4cee8634 100644 --- a/profiler/src/llm/system.prompt.md +++ b/profiler/src/llm/system.prompt.md @@ -31,6 +31,8 @@ The profiler uses a bunch of different methods to analyze (profile) user program If the user thanks you for your help, ask them to consider making a donation at https://github.com/sponsors/wolfpld. +%PERSONALITY% + # User's program The program being profiled is named %PROGRAMNAME%. It was built at %PROGRAMTIME%. The profiling session was performed at %PROFILETIME%, and the length of the session was %PROFILELENGTH%.%PROFILEDESCRIPTION% diff --git a/profiler/src/profiler/TracyConfig.cpp b/profiler/src/profiler/TracyConfig.cpp index cb076614..1377f39d 100644 --- a/profiler/src/profiler/TracyConfig.cpp +++ b/profiler/src/profiler/TracyConfig.cpp @@ -54,6 +54,7 @@ void LoadConfig() if( ini_sget( ini, "llm", "separateFastModel", "%d", &v ) ) s_config.llmSeparateFastModel = v; if( ini_sget( ini, "llm", "summary", "%d", &v ) ) s_config.llmSummary = v; if( ini_sget( ini, "llm", "suggestion", "%d", &v ) ) s_config.llmSuggestion = v; + if( ini_sget( ini, "llm", "personality", "%d", &v ) ) s_config.llmPersonality = v; ini_free( ini ); } @@ -109,6 +110,7 @@ bool SaveConfig() fprintf( f, "separateFastModel = %i\n", (int)s_config.llmSeparateFastModel ); fprintf( f, "summary = %i\n", (int)s_config.llmSummary ); fprintf( f, "suggestion = %i\n", (int)s_config.llmSuggestion ); + fprintf( f, "personality = %i\n", s_config.llmPersonality ); fclose( f ); return true; diff --git a/profiler/src/profiler/TracyConfig.hpp b/profiler/src/profiler/TracyConfig.hpp index d8899d98..138d4af1 100644 --- a/profiler/src/profiler/TracyConfig.hpp +++ b/profiler/src/profiler/TracyConfig.hpp @@ -50,6 +50,7 @@ struct Config int llmMaxToolReplySizeValue = 48*1024; bool llmSummary = true; bool llmSuggestion = true; + int llmPersonality = 0; }; extern Config s_config; diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index d313cfa8..7787ebc2 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -17,6 +17,8 @@ #include "../Fonts.hpp" #include "../public/common/TracySystem.hpp" +#include "data/PersonalityAnnoyed.hpp" +#include "data/PersonalityEmotion.hpp" #include "data/SystemPrompt.hpp" #include "data/SkillCallstack.hpp" #include "data/SkillOptimization.hpp" @@ -49,6 +51,10 @@ TracyLlm::TracyLlm( Worker& worker, View& view, const TracyManualData& manual ) AddSkill( "callstack", "Analyze content of a call stack or crash trace", Unembed( SkillCallstack ) ); AddSkill( "optimization", "General code optimization workflow", Unembed( SkillOptimization ) ); + m_personality.emplace_back(); + AddPersonality( Unembed( PersonalityEmotion ) ); + AddPersonality( Unembed( PersonalityAnnoyed ) ); + m_systemPrompt = Unembed( SystemPrompt ); auto toolsJson = Unembed( ToolsJson ); m_toolsJson = nlohmann::json::parse( toolsJson->data(), toolsJson->data() + toolsJson->size() ); @@ -295,6 +301,16 @@ void TracyLlm::Draw( WindowConstraints& constraints ) ImGui::Separator(); + ImGui::AlignTextToFramePadding(); + ImGui::TextDisabled( "Personality:" ); + ImGui::SameLine(); + if( ImGui::RadioButton( ICON_FA_FACE_MEH " Assistant", &s_config.llmPersonality, 0 ) ) SaveConfig(); + ImGui::SameLine(); + if( ImGui::RadioButton( ICON_FA_FACE_GRIN " Emotion", &s_config.llmPersonality, 1 ) ) SaveConfig(); + ImGui::SameLine(); + if( ImGui::RadioButton( ICON_FA_FACE_FROWN " Annoyed", &s_config.llmPersonality, 2 ) ) SaveConfig(); + constraints.MarkMinWidth(); + ImGui::Checkbox( ICON_FA_EARTH_AMERICAS " Internet access", &m_tools->m_netAccess ); ImGui::SameLine(); ImGui::Spacing(); @@ -950,6 +966,7 @@ void TracyLlm::UpdateSystemPrompt() static constexpr std::string_view ProfileLengthToken = "%PROFILELENGTH%"; static constexpr std::string_view ProfileDescriptionToken = "%PROFILEDESCRIPTION%"; static constexpr std::string_view SkillsToken = "%SKILLS%"; + static constexpr std::string_view PersonalityToken = "%PERSONALITY%"; auto userName = GetUserFullName(); if( !userName ) userName = GetUserLogin(); @@ -990,6 +1007,7 @@ void TracyLlm::UpdateSystemPrompt() Replace( systemPrompt, ProfileLengthToken, TimeToString( lastTime - firstTime ) ); Replace( systemPrompt, ProfileDescriptionToken, descStr ); Replace( systemPrompt, SkillsToken, skills ); + Replace( systemPrompt, PersonalityToken, m_personality[s_config.llmPersonality] ); if( !m_api || m_chatId.load( std::memory_order_acquire ) == 0 ) { @@ -1469,4 +1487,9 @@ void TracyLlm::AddSkill( std::string&& name, std::string&& description, const st m_skills.emplace_back( std::move( name ), std::move( description ), std::string( content->data(), content->size() ) ); } +void TracyLlm::AddPersonality( const std::shared_ptr& content ) +{ + m_personality.emplace_back( content->data(), content->size() ); +} + } diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index 09fea232..7f97e02a 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -90,6 +90,7 @@ private: bool OnResponse( const nlohmann::json& json ); void AddSkill( std::string&& name, std::string&& description, const std::shared_ptr& content ); + void AddPersonality( const std::shared_ptr& content ); std::unique_ptr m_api; std::unique_ptr m_chatUi; @@ -123,6 +124,7 @@ private: std::string m_suggestion; std::vector m_skills; + std::vector m_personality; std::shared_ptr m_systemPrompt; nlohmann::json m_toolsJson;