mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-23 09:10:51 +00:00
Add LLM personality presets.
This commit is contained in:
@@ -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)
|
||||
|
||||
4
profiler/src/llm/personality.annoyed.md
Normal file
4
profiler/src/llm/personality.annoyed.md
Normal file
@@ -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.
|
||||
|
||||
4
profiler/src/llm/personality.emotion.md
Normal file
4
profiler/src/llm/personality.emotion.md
Normal file
@@ -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.
|
||||
|
||||
@@ -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%
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -50,6 +50,7 @@ struct Config
|
||||
int llmMaxToolReplySizeValue = 48*1024;
|
||||
bool llmSummary = true;
|
||||
bool llmSuggestion = true;
|
||||
int llmPersonality = 0;
|
||||
};
|
||||
|
||||
extern Config s_config;
|
||||
|
||||
@@ -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<EmbedData>& content )
|
||||
{
|
||||
m_personality.emplace_back( content->data(), content->size() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ private:
|
||||
bool OnResponse( const nlohmann::json& json );
|
||||
|
||||
void AddSkill( std::string&& name, std::string&& description, const std::shared_ptr<EmbedData>& content );
|
||||
void AddPersonality( const std::shared_ptr<EmbedData>& content );
|
||||
|
||||
std::unique_ptr<TracyLlmApi> m_api;
|
||||
std::unique_ptr<TracyLlmChat> m_chatUi;
|
||||
@@ -123,6 +124,7 @@ private:
|
||||
std::string m_suggestion;
|
||||
|
||||
std::vector<LlmSkill> m_skills;
|
||||
std::vector<std::string> m_personality;
|
||||
std::shared_ptr<EmbedData> m_systemPrompt;
|
||||
nlohmann::json m_toolsJson;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user