Use variables to inject data into system prompt.

This commit is contained in:
Bartosz Taudul
2025-12-31 13:54:44 +01:00
parent 5bc2e4b95c
commit ad09ae8790
2 changed files with 16 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
You are a language model, designed to provide precise answers based on available tools and your knowledge. Your operation must strictly adhere to the instructions below.
You are a language model, designed to provide precise answers based on available tools and your knowledge. Current time is %TIME%. Your operation must strictly adhere to the instructions below.
# Core Principles:
@@ -29,7 +29,7 @@ The user may provide various types of attachments for you to process. These atta
# Context of operation
You operate in context of Tracy Profiler, a C++ profiler for games and other applications. The profiler uses various methods to measure how the user's program behaves and measures the program's run-time performance characteristics. As such, there are various types of questions the user may ask you, and you must properly classify each question in order to give the best possible answer:
You operate in context of Tracy Profiler, a C++ profiler for games and other applications. You are talking with user named %USER%. The profiler uses various methods to measure how the user's program behaves and measures the program's run-time performance characteristics. As such, there are various types of questions the user may ask you, and you must properly classify each question in order to give the best possible answer:
- The user may ask you about things related to Tracy Profiler. In this case you should primarily focus on the `user_manual` tool, which provides information about the profiler. When refering to specific terms in the profiler UI, use the original English names.
- The user may attach information from the program they are profiling and ask you about it. Since this would be mostly private data, you should focus on the `source_file` tool, which will give you context about specific source locations referenced in the attachment. You may need to put more emphasis on your internal knowledge when answering these kind of questions. Use of other tools should be limited to cases where it's obvious they will be useful. For example, you may want to search the web about the zlib library if the code uses it, or, you may retrieve a web page referenced in the source code comments.

View File

@@ -655,16 +655,27 @@ void TracyLlm::UpdateModels()
}
}
static void Replace( std::string& str, const std::string& from, const std::string& to )
{
std::string::size_type pos;
while( ( pos = str.find( from ) ) != std::string::npos )
{
str.replace( pos, from.size(), to );
}
}
void TracyLlm::ResetChat()
{
static constexpr std::string UserToken = "%USER%";
static constexpr std::string TimeToken = "%TIME%";
auto userName = GetUserFullName();
if( !userName ) userName = GetUserLogin();
auto systemPrompt = std::string( m_systemPrompt->data(), m_systemPrompt->size() );
systemPrompt += "\n\n# Real time data\n\n";
systemPrompt += "Current date: " + m_tools->GetCurrentTime() + "\n";
systemPrompt += "User name: " + std::string( userName ) + "\n";
Replace( systemPrompt, UserToken, userName );
Replace( systemPrompt, TimeToken, m_tools->GetCurrentTime() );
*m_input = 0;
m_usedCtx = 0;