diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 21e5c95c..c3cf8488 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -205,7 +205,8 @@ void TracyLlm::Draw() return; } - if( m_api->GetModels().empty() ) + const auto& models = m_api->GetModels(); + if( models.empty() ) { ImGui::PushFont( g_fonts.big ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); @@ -217,7 +218,7 @@ void TracyLlm::Draw() return; } - const auto ctxSize = m_api->GetContextSize(); + const auto ctxSize = models[m_modelIdx].contextSize; if( ctxSize > 0 ) { ImGui::Spacing(); @@ -692,7 +693,7 @@ bool TracyLlm::OnResponse( const nlohmann::json& json ) auto tool = lines[0]; lines.erase( lines.begin() ); lock.unlock(); - const auto reply = m_tools.HandleToolCalls( tool, lines, *m_api ); + const auto reply = m_tools.HandleToolCalls( tool, lines, m_api->GetModels()[m_modelIdx].contextSize ); const auto output = "\n" + reply.reply; m_usedCtx += output.size() / 4; lock.lock(); diff --git a/profiler/src/profiler/TracyLlmApi.cpp b/profiler/src/profiler/TracyLlmApi.cpp index a197b341..0601c64b 100644 --- a/profiler/src/profiler/TracyLlmApi.cpp +++ b/profiler/src/profiler/TracyLlmApi.cpp @@ -34,7 +34,6 @@ void TracyLlmApi::SetupCurl() bool TracyLlmApi::Connect( const char* url ) { - m_contextSize = -1; m_url = url; m_models.clear(); if( m_curl ) curl_easy_cleanup( m_curl ); diff --git a/profiler/src/profiler/TracyLlmApi.hpp b/profiler/src/profiler/TracyLlmApi.hpp index 67cb2b72..f8de5f80 100644 --- a/profiler/src/profiler/TracyLlmApi.hpp +++ b/profiler/src/profiler/TracyLlmApi.hpp @@ -34,7 +34,6 @@ public: [[nodiscard]] bool IsConnected() const { return m_curl != nullptr; } [[nodiscard]] const std::vector& GetModels() const { return m_models; } - [[nodiscard]] int GetContextSize() const { return m_contextSize; } private: void SetupCurl(); @@ -47,7 +46,6 @@ private: Type m_type; std::vector m_models; - int m_contextSize; }; } diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index 8544b4f0..f4253b32 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -6,7 +6,6 @@ #include #include -#include "TracyLlmApi.hpp" #include "TracyLlmTools.hpp" constexpr const char* NoNetworkAccess = "Internet access is disabled by the user. You may inform the user that he can enable it in the settings, so that you can use the tools to gather information."; @@ -43,9 +42,9 @@ static std::string UrlEncode( const std::string& str ) return out; } -TracyLlmTools::ToolReply TracyLlmTools::HandleToolCalls( const std::string& name, const std::vector& args, const TracyLlmApi& api) +TracyLlmTools::ToolReply TracyLlmTools::HandleToolCalls( const std::string& name, const std::vector& args, int contextSize ) { - m_ctxSize = api.GetContextSize(); + m_ctxSize = contextSize; if( name == "fetch_web_page" ) { diff --git a/profiler/src/profiler/TracyLlmTools.hpp b/profiler/src/profiler/TracyLlmTools.hpp index 29ac9851..5f819b1d 100644 --- a/profiler/src/profiler/TracyLlmTools.hpp +++ b/profiler/src/profiler/TracyLlmTools.hpp @@ -9,8 +9,6 @@ namespace tracy { -class TracyLlmApi; - class TracyLlmTools { public: @@ -20,7 +18,7 @@ public: std::string image; }; - ToolReply HandleToolCalls( const std::string& name, const std::vector& args, const TracyLlmApi& api ); + ToolReply HandleToolCalls( const std::string& name, const std::vector& args, int contextSize ); std::string GetCurrentTime(); bool m_netAccess = true;