From 761cb1041b8c77a20804107b1d13ead87718bf57 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 Jan 2026 17:58:22 +0100 Subject: [PATCH] Add fast model selection to the UI. --- profiler/src/profiler/TracyConfig.cpp | 2 + profiler/src/profiler/TracyConfig.hpp | 1 + profiler/src/profiler/TracyLlm.cpp | 55 ++++++++++++++++++++++++++- profiler/src/profiler/TracyLlm.hpp | 1 + 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/profiler/src/profiler/TracyConfig.cpp b/profiler/src/profiler/TracyConfig.cpp index eb2a282b..0ba66851 100644 --- a/profiler/src/profiler/TracyConfig.cpp +++ b/profiler/src/profiler/TracyConfig.cpp @@ -42,6 +42,7 @@ void LoadConfig() if( ini_sget( ini, "llm", "enabled", "%d", &v ) ) s_config.llm = v; if( v2 = ini_get( ini, "llm", "address" ); v2 ) s_config.llmAddress = v2; if( v2 = ini_get( ini, "llm", "model" ); v2 ) s_config.llmModel = v2; + if( v2 = ini_get( ini, "llm", "fastModel" ); v2 ) s_config.llmFastModel = v2; if( v2 = ini_get( ini, "llm", "embeddings" ); v2 ) s_config.llmEmbeddingsModel = v2; if( v2 = ini_get( ini, "llm", "useragent" ); v2 ) s_config.llmUserAgent = v2; if( v2 = ini_get( ini, "llm", "searchIdentifier" ); v2 ) s_config.llmSearchIdentifier = v2; @@ -89,6 +90,7 @@ bool SaveConfig() fprintf( f, "enabled = %i\n", (int)s_config.llm ); fprintf( f, "address = %s\n", s_config.llmAddress.c_str() ); fprintf( f, "model = %s\n", s_config.llmModel.c_str() ); + fprintf( f, "fastModel = %s\n", s_config.llmFastModel.c_str() ); fprintf( f, "embeddings = %s\n", s_config.llmEmbeddingsModel.c_str() ); fprintf( f, "useragent = %s\n", s_config.llmUserAgent.c_str() ); fprintf( f, "searchIdentifier = %s\n", s_config.llmSearchIdentifier.c_str() ); diff --git a/profiler/src/profiler/TracyConfig.hpp b/profiler/src/profiler/TracyConfig.hpp index 9cdb31f9..f3e07266 100644 --- a/profiler/src/profiler/TracyConfig.hpp +++ b/profiler/src/profiler/TracyConfig.hpp @@ -38,6 +38,7 @@ struct Config #endif std::string llmAddress = "http://localhost:11434"; std::string llmModel; + std::string llmFastModel; std::string llmEmbeddingsModel; std::string llmUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"; std::string llmSearchIdentifier; diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 485d9be5..9c22cd8f 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -197,7 +197,7 @@ void TracyLlm::Draw() const auto& models = m_api->GetModels(); ImGui::AlignTextToFramePadding(); - TextDisabledUnformatted( "Model:" ); + TextDisabledUnformatted( "Chat model:" ); ImGui::SameLine(); if( models.empty() || m_modelIdx < 0 ) { @@ -230,7 +230,40 @@ void TracyLlm::Draw() } ImGui::AlignTextToFramePadding(); - TextDisabledUnformatted( "Embeddings:" ); + TextDisabledUnformatted( "Fast model:" ); + ImGui::SameLine(); + if( models.empty() || m_fastIdx < 0 ) + { + ImGui::TextUnformatted( "No models available" ); + } + else + { + ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); + if( ImGui::BeginCombo( "##fastmodel", models[m_fastIdx].name.c_str() ) ) + { + for( size_t i = 0; i < models.size(); ++i ) + { + const auto& model = models[i]; + if( model.embeddings ) continue; + if( ImGui::Selectable( model.name.c_str(), i == m_fastIdx ) ) + { + m_fastIdx = i; + s_config.llmFastModel = model.name; + SaveConfig(); + } + if( m_fastIdx == i ) ImGui::SetItemDefaultFocus(); + if( !model.quant.empty() ) + { + ImGui::SameLine(); + ImGui::TextDisabled( "(%s)", model.quant.c_str() ); + } + } + ImGui::EndCombo(); + } + } + + ImGui::AlignTextToFramePadding(); + TextDisabledUnformatted( "Embeddings model:" ); ImGui::SameLine(); if( models.empty() || m_embedIdx < 0 ) { @@ -644,6 +677,7 @@ void TracyLlm::WorkerThread() void TracyLlm::UpdateModels() { m_modelIdx = -1; + m_fastIdx = -1; m_embedIdx = -1; auto& models = m_api->GetModels(); @@ -664,6 +698,23 @@ void TracyLlm::UpdateModels() m_modelIdx = std::distance( models.begin(), it ); } + it = std::ranges::find_if( models, []( const auto& model ) { return model.name == s_config.llmFastModel; } ); + if( it == models.end() ) + { + for( int i=0; i m_tools; int m_modelIdx; + int m_fastIdx; int m_embedIdx; std::atomic m_exit;