From 746f28e3c9d040e7e71f3f72ddd3af4f974d72df Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 23 May 2025 01:11:20 +0200 Subject: [PATCH] Add UI for building manual embeddings. --- profiler/src/profiler/TracyLlm.cpp | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index b9549ee2..ef2716ee 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -88,6 +88,30 @@ void TracyLlm::Draw() } auto& style = ImGui::GetStyle(); + + const auto manualEmbeddingsState = m_tools.GetManualEmbeddingsState(); + if( manualEmbeddingsState.inProgress ) + { + ImGui::PushFont( g_fonts.big ); + ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 7 ) * 0.5f ) ); + TextCentered( ICON_FA_BOOK_BOOKMARK ); + ImGui::Spacing(); + TextCentered( "Building manual embeddings..." ); + ImGui::Spacing(); + DrawWaitingDots( s_time ); + ImGui::TextUnformatted( "" ); + ImGui::PopFont(); + char tmp[128]; + snprintf( tmp, sizeof( tmp ), "Progress: %.1f%%", manualEmbeddingsState.progress * 100 ); + TextCentered( tmp ); + ImGui::Spacing(); + const auto sz = ImGui::CalcTextSize( "Cancel" ).x + style.FramePadding.x * 2; + ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - sz ) * 0.5f ); + if( ImGui::Button( "Cancel" ) ) m_tools.CancelManualEmbeddings(); + ImGui::End(); + return; + } + std::lock_guard lock( m_lock ); const auto hasChat = m_chat.size() <= 1 && *m_input == 0; @@ -251,6 +275,29 @@ void TracyLlm::Draw() return; } + if( !manualEmbeddingsState.done || manualEmbeddingsState.model != models[m_embedIdx].name ) + { + if( m_embedIdx < 0 ) ImGui::BeginDisabled(); + if( ImGui::SmallButton( ICON_FA_BOOK_BOOKMARK " Learn manual" ) ) + { + if( m_responding ) m_stop = true; + m_tools.BuildManualEmbeddings( models[m_embedIdx].name, *m_api ); + } + if( m_embedIdx < 0 ) ImGui::EndDisabled(); + ImGui::SameLine(); + ImGui::PushFont( g_fonts.small ); + ImGui::AlignTextToFramePadding(); + if( !manualEmbeddingsState.done ) + { + tracy::TextDisabledUnformatted( "Embeddings not calculated" ); + } + else + { + ImGui::TextDisabled( "Embeddings calculated for model %s", manualEmbeddingsState.model.c_str() ); + } + ImGui::PopFont(); + } + const auto ctxSize = models[m_modelIdx].contextSize; if( ctxSize > 0 ) {