From e4e23eabb6722bd1a710adfecbf88c6e7f389cf6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 May 2025 19:01:47 +0200 Subject: [PATCH] Hook up LLM window. --- profiler/src/profiler/TracyLlm.cpp | 10 ++++++++++ profiler/src/profiler/TracyLlm.hpp | 4 ++++ profiler/src/profiler/TracyView.cpp | 6 ++++++ profiler/src/profiler/TracyView.hpp | 3 +++ 4 files changed, 23 insertions(+) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 01b476f8..704df499 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -2,6 +2,7 @@ #include #include "TracyConfig.hpp" +#include "TracyImGui.hpp" #include "TracyLlm.hpp" extern tracy::Config s_config; @@ -68,4 +69,13 @@ size_t TracyLlm::GetCtxSize( const std::string& model ) const } } +void TracyLlm::Draw() +{ + const auto scale = GetScale(); + ImGui::SetNextWindowSize( ImVec2( 400 * scale, 800 * scale ), ImGuiCond_FirstUseEver ); + ImGui::Begin( "Tracy AI", &m_show, ImGuiWindowFlags_NoScrollbar ); + if( ImGui::GetCurrentWindowRead()->SkipItems ) { ImGui::End(); return; } + ImGui::End(); +} + } diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index f6a4424e..c07043a1 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -21,6 +21,10 @@ public: [[nodiscard]] std::vector GetModels() const; [[nodiscard]] size_t GetCtxSize( const std::string& model ) const; + void Draw(); + + bool m_show = false; + private: std::unique_ptr m_ollama; diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index ca063185..78f5878b 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -957,6 +957,11 @@ bool View::DrawImpl() ImGui::EndPopup(); } } + if( m_llm.IsValid() ) + { + ImGui::SameLine(); + ToggleButton( ICON_FA_ROBOT, m_llm.m_show ); + } if( m_worker.AreFramesUsed() ) { ImGui::SameLine(); @@ -1151,6 +1156,7 @@ bool View::DrawImpl() if( m_sampleParents.symAddr != 0 ) DrawSampleParents(); if( m_showRanges ) DrawRanges(); if( m_showWaitStacks ) DrawWaitStacks(); + if( m_llm.m_show ) m_llm.Draw(); if( m_setRangePopup.active ) { diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 95cc31ac..dd8b43fd 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -17,6 +17,7 @@ #include "TracyBuzzAnim.hpp" #include "TracyConfig.hpp" #include "TracyDecayValue.hpp" +#include "TracyLlm.hpp" #include "TracySourceContents.hpp" #include "TracyTimelineController.hpp" #include "TracyUserData.hpp" @@ -936,6 +937,8 @@ private: lastTime = 0; } } m_flameGraphInvariant; + + TracyLlm m_llm; }; }