mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-24 09:40:53 +00:00
Implement disabling LLM summary and suggestion.
This commit is contained in:
@@ -52,6 +52,8 @@ void LoadConfig()
|
||||
if( ini_sget( ini, "llm", "limitToolReplySize", "%d", &v ) ) s_config.llmLimitToolReplySize = v;
|
||||
if( ini_sget( ini, "llm", "maxToolReplySizeValue", "%d", &v ) ) s_config.llmMaxToolReplySizeValue = v;
|
||||
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;
|
||||
|
||||
ini_free( ini );
|
||||
}
|
||||
@@ -105,6 +107,8 @@ bool SaveConfig()
|
||||
fprintf( f, "limitToolReplySize = %i\n", (int)s_config.llmLimitToolReplySize );
|
||||
fprintf( f, "maxToolReplySizeValue = %i\n", s_config.llmMaxToolReplySizeValue );
|
||||
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 );
|
||||
|
||||
fclose( f );
|
||||
return true;
|
||||
|
||||
@@ -48,6 +48,8 @@ struct Config
|
||||
bool llmAnnotateCallstacks = false;
|
||||
bool llmLimitToolReplySize = false;
|
||||
int llmMaxToolReplySizeValue = 48*1024;
|
||||
bool llmSummary = true;
|
||||
bool llmSuggestion = true;
|
||||
};
|
||||
|
||||
extern Config s_config;
|
||||
|
||||
@@ -325,6 +325,18 @@ void TracyLlm::Draw()
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
if( ImGui::Checkbox( ICON_FA_HAND_POINT_RIGHT " Show summary", &s_config.llmSummary ) )
|
||||
{
|
||||
SaveConfig();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox( ICON_FA_COMMENT_DOTS " Chat suggestion", &s_config.llmSuggestion ) )
|
||||
{
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
if( ImGui::TreeNode( "Advanced" ) )
|
||||
{
|
||||
if( responding ) ImGui::BeginDisabled();
|
||||
@@ -1077,7 +1089,7 @@ void TracyLlm::SendMessage()
|
||||
std::unique_lock lock( m_chatLock );
|
||||
ManageContext();
|
||||
auto chat = m_chat;
|
||||
bool needSummary = m_summary.empty();
|
||||
bool needSummary = m_summary.empty() && s_config.llmSummary;
|
||||
lock.unlock();
|
||||
|
||||
for( auto& msg : chat )
|
||||
@@ -1330,30 +1342,33 @@ bool TracyLlm::OnResponse( const nlohmann::json& json )
|
||||
if( msg.contains( "model" ) ) msg.erase( "model" );
|
||||
}
|
||||
|
||||
auto suggestionQuery = chat;
|
||||
suggestionQuery.push_back( nlohmann::json {
|
||||
{"role", "user"},
|
||||
{"content", "Based on this conversation, suggest one useful follow-up question the user might want to ask next. It should be relevant, actionable, and something the user would genuinely want to explore. Reply with ONLY the question text, in the user's language, under 80 characters."}
|
||||
} );
|
||||
const int chatId = m_chatId.load( std::memory_order_acquire );
|
||||
QueueFastMessageLocking( suggestionQuery, [this, chatId]( const nlohmann::json& res ) {
|
||||
if( m_chatId.load( std::memory_order_acquire ) != chatId ) return;
|
||||
if( res.contains( "choices" ) )
|
||||
{
|
||||
auto& choices = res["choices"];
|
||||
if( choices.is_array() && !choices.empty() )
|
||||
if( s_config.llmSuggestion )
|
||||
{
|
||||
auto suggestionQuery = chat;
|
||||
suggestionQuery.push_back( nlohmann::json {
|
||||
{"role", "user"},
|
||||
{"content", "Based on this conversation, suggest one useful follow-up question the user might want to ask next. It should be relevant, actionable, and something the user would genuinely want to explore. Reply with ONLY the question text, in the user's language, under 80 characters."}
|
||||
} );
|
||||
const int chatId = m_chatId.load( std::memory_order_acquire );
|
||||
QueueFastMessageLocking( suggestionQuery, [this, chatId]( const nlohmann::json& res ) {
|
||||
if( m_chatId.load( std::memory_order_acquire ) != chatId ) return;
|
||||
if( res.contains( "choices" ) )
|
||||
{
|
||||
if( choices[0].contains( "message" ) && choices[0]["message"].contains( "content" ) )
|
||||
auto& choices = res["choices"];
|
||||
if( choices.is_array() && !choices.empty() )
|
||||
{
|
||||
auto str = choices[0]["message"]["content"].get<std::string>();
|
||||
std::ranges::replace( str, '\n', ' ' );
|
||||
std::ranges::replace( str, '\r', ' ' );
|
||||
std::lock_guard lock( m_chatLock );
|
||||
m_suggestion = std::move( str );
|
||||
if( choices[0].contains( "message" ) && choices[0]["message"].contains( "content" ) )
|
||||
{
|
||||
auto str = choices[0]["message"]["content"].get<std::string>();
|
||||
std::ranges::replace( str, '\n', ' ' );
|
||||
std::ranges::replace( str, '\r', ' ' );
|
||||
std::lock_guard lock( m_chatLock );
|
||||
m_suggestion = std::move( str );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
jobsLock.lock();
|
||||
m_focusInput = true;
|
||||
|
||||
Reference in New Issue
Block a user