diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index 0951a50a..5cf29372 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -77,6 +77,89 @@ static std::unique_ptr ParseHtml( const std::string& html ) return doc; } +TracyLlmTools::TracyLlmTools() + : m_manual( Unembed( Manual ) ) +{ + std::string_view manual( m_manual->data(), m_manual->size() ); + const auto sz = (int)m_manual->size(); + + std::vector levels = { 0 }; + std::vector chapterNames = { "Title Page" }; + + int manualChunkPos = 0; + int pos = 0; + while( pos < sz ) + { + auto next = manual.find( '\n', pos ); + if( next == std::string_view::npos ) next = sz; + if( next != pos ) + { + std::string_view line( manual.data() + pos, next - pos ); + if( line[0] == '#' ) + { + if( manualChunkPos != pos ) + { + std::string manualChunk; + if( levels[0] != 0 ) + { + manualChunk += "Section " + std::to_string( levels[0] ); + for( size_t i=1; idata(), m_manual->size() ); - const auto sz = (int)m_manual->size(); - m_manualChunks.clear(); - - std::vector> chunks; - std::vector levels = { 0 }; - std::vector chapterNames = { "Title Page" }; - - int manualChunkPos = 0; - int pos = 0; - while( pos < sz ) - { - auto next = manual.find( '\n', pos ); - if( next == std::string_view::npos ) next = sz; - if( next != pos ) - { - std::string_view line( manual.data() + pos, next - pos ); - if( line[0] == '#' ) - { - if( manualChunkPos != pos ) - { - std::string manualChunk; - if( levels[0] != 0 ) - { - manualChunk += "Section " + std::to_string( levels[0] ); - for( size_t i=1; i( length, csz ); for( size_t i=0; i() ); - m_manualEmbeddings->Add( chunks[i].second, embeddings ); + m_manualEmbeddings->Add( m_chunkData[i].second, embeddings ); } std::lock_guard lock( m_lock ); diff --git a/profiler/src/profiler/TracyLlmTools.hpp b/profiler/src/profiler/TracyLlmTools.hpp index 5c12f185..54604f3d 100644 --- a/profiler/src/profiler/TracyLlmTools.hpp +++ b/profiler/src/profiler/TracyLlmTools.hpp @@ -34,6 +34,7 @@ public: float progress = 0; }; + TracyLlmTools(); ~TracyLlmTools(); ToolReply HandleToolCalls( const std::string& name, const std::vector& args, TracyLlmApi& api, int contextSize, bool hasEmbeddingsModel ); @@ -71,6 +72,7 @@ private: std::shared_ptr m_manual; std::vector m_manualChunks; + std::vector> m_chunkData; }; }