diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 4f4e26ec..908573d2 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -615,7 +615,25 @@ void TracyLlm::Draw() think = TracyLlmChat::Think::ToolCall; } const auto isLast = it + 1 == m_chat.end(); - if( !m_chatUi->Turn( role, it, m_chat.end(), think, isLast ) ) + bool fadeout = false; + if( role == TracyLlmChat::TurnRole::Assistant && !m_allThinkingRegions && !isLast ) + { + auto nit = it + 1; + while( nit != m_chat.end() ) + { + const auto& nline = *nit; + if( !nline.contains( "role" ) ) { nit++; continue; } + const auto& nroleStr = nline["role"].get_ref(); + if( nroleStr == "assistant" && nline.contains( "content" ) ) + { + fadeout = true; + break; + } + if( nroleStr == "user" ) break; + nit++; + } + } + if( !m_chatUi->Turn( role, it, m_chat.end(), think, isLast, fadeout ) ) { if( role == TracyLlmChat::TurnRole::Assistant ) { diff --git a/profiler/src/profiler/TracyLlmChat.cpp b/profiler/src/profiler/TracyLlmChat.cpp index 06c38d69..0379c34e 100644 --- a/profiler/src/profiler/TracyLlmChat.cpp +++ b/profiler/src/profiler/TracyLlmChat.cpp @@ -227,7 +227,7 @@ void TracyLlmChat::End() } } -bool TracyLlmChat::Turn( TurnRole role, std::vector::iterator it, const std::vector::iterator& end, Think think, bool last ) +bool TracyLlmChat::Turn( TurnRole role, std::vector::iterator it, const std::vector::iterator& end, Think think, bool last, bool fadeout ) { auto& json = *it; if( json.contains( "role" ) && json["role"].get_ref() == "tool" ) return true; @@ -391,7 +391,9 @@ bool TracyLlmChat::Turn( TurnRole role, std::vector::iterator it if( ptr != end ) { NormalScope(); + if( fadeout ) ImGui::PushStyleColor( ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled] ); m_markdown.Print( content.c_str(), content.size() ); + if( fadeout ) ImGui::PopStyleColor(); if( roleStr == "assistant" ) ImGui::Spacing(); } } diff --git a/profiler/src/profiler/TracyLlmChat.hpp b/profiler/src/profiler/TracyLlmChat.hpp index 5213b74d..5c3f96ce 100644 --- a/profiler/src/profiler/TracyLlmChat.hpp +++ b/profiler/src/profiler/TracyLlmChat.hpp @@ -43,7 +43,7 @@ public: void Begin(); void End(); - bool Turn( TurnRole role, std::vector::iterator it, const std::vector::iterator& end, Think think, bool last ); + bool Turn( TurnRole role, std::vector::iterator it, const std::vector::iterator& end, Think think, bool last, bool fadeout ); void SetModelTimeLabel( const char* model, uint64_t duration_ns ); private: