From 66bbd96d261a26faa8195b9366476ffbfac24ecd Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 Oct 2026 22:23:37 +0200 Subject: [PATCH] Access the user manual data through its singleton in the LLM chain. --- profiler/src/profiler/TracyLlm.cpp | 4 ++-- profiler/src/profiler/TracyLlm.hpp | 3 +-- profiler/src/profiler/TracyLlmTools.cpp | 11 +++++------ profiler/src/profiler/TracyLlmTools.hpp | 4 +--- profiler/src/profiler/TracyView.cpp | 7 ++----- profiler/src/profiler/TracyView.hpp | 2 -- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index e537de9a..ef0d476b 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -31,7 +31,7 @@ extern double s_time; constexpr size_t InputBufferSize = 1024; -TracyLlm::TracyLlm( Worker& worker, View& view, const TracyManualData& manual ) +TracyLlm::TracyLlm( Worker& worker, View& view ) : m_exit( false ) , m_input( nullptr ) , m_apiInput( nullptr ) @@ -65,7 +65,7 @@ TracyLlm::TracyLlm( Worker& worker, View& view, const TracyManualData& manual ) m_api = std::make_unique(); m_chatUi = std::make_unique( view, worker, m_skills ); - m_tools = std::make_unique( worker, view, manual, m_skills ); + m_tools = std::make_unique( worker, view, m_skills ); m_busy = true; QueueConnect(); diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index f8580220..9983aa8d 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -21,7 +21,6 @@ constexpr int DefaultToolReplyLimit = 48 * 1024; class TracyLlmApi; class TracyLlmChat; class TracyLlmTools; -class TracyManualData; class View; class WindowConstraints; class Worker; @@ -54,7 +53,7 @@ class TracyLlm }; public: - TracyLlm( Worker& worker, View& view, const TracyManualData& manual ); + TracyLlm( Worker& worker, View& view ); ~TracyLlm(); [[nodiscard]] bool IsBusy() const { std::lock_guard lock( m_jobsLock ); return m_busy; } diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index 574c9403..b6fbcd79 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -85,14 +85,13 @@ static std::unique_ptr ParseHtml( const std::string& html ) return doc; } -TracyLlmTools::TracyLlmTools( Worker& worker, const View& view, const TracyManualData& manual, const std::vector& skills ) +TracyLlmTools::TracyLlmTools( Worker& worker, const View& view, const std::vector& skills ) : m_worker( worker ) , m_view( view ) - , m_manual( manual ) , m_skills( skills ) { int idx = 0; - for( auto& chunk : m_manual.GetChunks() ) + for( auto& chunk : GetManualData().GetChunks() ) { std::string hdr; if( !chunk.section.empty() ) hdr += "Section " + chunk.section; @@ -245,7 +244,7 @@ void TracyLlmTools::SelectManualEmbeddings( const std::string& model ) try { - m_manualEmbeddings = std::make_unique( cache, m_manual.GetHash() ); + m_manualEmbeddings = std::make_unique( cache, GetManualData().GetHash() ); m_manualEmbeddingState = { .model = model, .done = true }; } catch( std::exception& ) {} @@ -346,7 +345,7 @@ void TracyLlmTools::ManualEmbeddingsWorker( TracyLlmApi& api ) i += bsz; } - m_manualEmbeddings->Save( cache, m_manual.GetHash() ); + m_manualEmbeddings->Save( cache, GetManualData().GetHash() ); lock.lock(); m_manualEmbeddingState.inProgress = false; @@ -838,7 +837,7 @@ std::string TracyLlmTools::SearchManual( const std::string& query, TracyLlmApi& } if( chunks.size() > MaxOutputChunks ) chunks.resize( MaxOutputChunks ); - auto& manualChunks = m_manual.GetChunks(); + auto& manualChunks = GetManualData().GetChunks(); const auto maxSize = CalcMaxSize(); int totalSize = 0; int idx; diff --git a/profiler/src/profiler/TracyLlmTools.hpp b/profiler/src/profiler/TracyLlmTools.hpp index cd560570..cc324eea 100644 --- a/profiler/src/profiler/TracyLlmTools.hpp +++ b/profiler/src/profiler/TracyLlmTools.hpp @@ -18,7 +18,6 @@ namespace tracy struct LlmSkill; class TracyLlmApi; -class TracyManualData; class View; class Worker; @@ -33,7 +32,7 @@ public: float progress = 0; }; - TracyLlmTools( Worker& worker, const View& view, const TracyManualData& manual, const std::vector& skills ); + TracyLlmTools( Worker& worker, const View& view, const std::vector& skills ); ~TracyLlmTools(); std::string HandleToolCalls( const std::string& tool, const nlohmann::json& json, TracyLlmApi& api, int contextSize, bool hasEmbeddingsModel ); @@ -86,7 +85,6 @@ private: Worker& m_worker; const View& m_view; - const TracyManualData& m_manual; const std::vector& m_skills; }; diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index cd787cd7..870816a6 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -16,7 +16,6 @@ #include "TracyFileRead.hpp" #include "TracyFilesystem.hpp" #include "TracyImGui.hpp" -#include "TracyManualData.hpp" #include "TracyPrint.hpp" #include "TracySafeFileWrite.hpp" #include "TracySourceView.hpp" @@ -54,13 +53,12 @@ View::View( void(*cbMainThread)(const std::function&, bool), const char* , m_achievements( s_config.achievements ) , m_horizontalScrollMultiplier( s_config.horizontalScrollMultiplier ) , m_verticalScrollMultiplier( s_config.verticalScrollMultiplier ) - , m_manualData( GetManualData() ) , m_markdown( this, &m_worker, &GetManualWindow() ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else , m_td( std::thread::hardware_concurrency(), "ViewMt" ) - , m_llm( m_worker, *this, m_manualData ) + , m_llm( m_worker, *this ) #endif { InitTextEditor(); @@ -86,13 +84,12 @@ View::View( void(*cbMainThread)(const std::function&, bool), FileRead& f , m_achievements( s_config.achievements ) , m_horizontalScrollMultiplier( s_config.horizontalScrollMultiplier ) , m_verticalScrollMultiplier( s_config.verticalScrollMultiplier ) - , m_manualData( GetManualData() ) , m_markdown( this, &m_worker, &GetManualWindow() ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else , m_td( std::thread::hardware_concurrency(), "ViewMt" ) - , m_llm( m_worker, *this, m_manualData ) + , m_llm( m_worker, *this ) #endif { m_notificationTime = 4; diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 68e06471..658cbb17 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -18,7 +18,6 @@ #include "TracyBuzzAnim.hpp" #include "TracyConfig.hpp" #include "TracyDecayValue.hpp" -#include "TracyManualData.hpp" #include "TracyManualWindow.hpp" #include "TracyMarkdown.hpp" #include "TracySourceContents.hpp" @@ -1078,7 +1077,6 @@ private: double m_horizontalScrollMultiplier = 1.0; double m_verticalScrollMultiplier = 1.0; - const TracyManualData& m_manualData; Markdown m_markdown; TaskDispatch m_td;