From 2bf0a3c7f924680dfc2e9b30c04bd117cc3a646c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 Jan 2026 18:56:19 +0100 Subject: [PATCH] Implement fast message queries. --- profiler/src/profiler/TracyLlm.cpp | 20 ++++++++++++++++++++ profiler/src/profiler/TracyLlm.hpp | 3 +++ 2 files changed, 23 insertions(+) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 9c22cd8f..18a0d393 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -659,6 +659,14 @@ void TracyLlm::WorkerThread() case Task::SendMessage: SendMessage( lock ); break; + case Task::FastMessage: + { + lock.unlock(); + auto response = m_api->SendMessage( m_currentJob->param2, m_fastIdx ); + m_currentJob->callback2( response ); + lock.lock(); + break; + } case Task::Tokenize: { lock.unlock(); @@ -799,6 +807,18 @@ bool TracyLlm::QueueSendMessage() return true; } +bool TracyLlm::QueueFastMessage( const nlohmann::json& req, std::function callback ) +{ + if( !m_api->IsConnected() || m_fastIdx < 0 ) return false; + m_jobs.emplace_back( std::make_shared( WorkItem { + .task = Task::FastMessage, + .callback2 = std::move( callback ), + .param2 = req + } ) ); + m_cv.notify_all(); + return true; +} + void TracyLlm::AddMessage( std::string&& str, const char* role ) { if( !m_api ) diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index 4422e22e..a514a804 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -28,6 +28,7 @@ class TracyLlm { Connect, SendMessage, + FastMessage, Tokenize }; @@ -37,6 +38,7 @@ class TracyLlm std::function callback; std::function callback2; std::string param; + nlohmann::json param2; bool stop; }; @@ -50,6 +52,7 @@ public: void AddAttachment( std::string&& str, const char* role ); void AddMessage( std::string&& str, const char* role ); bool QueueSendMessage(); + bool QueueFastMessage( const nlohmann::json& req, std::function callback ); bool m_show = false;