diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index c6cb321a..485d9be5 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -854,6 +854,24 @@ void TracyLlm::SendMessage( std::unique_lock& lock ) auto chat = m_chat; AddMessageBlocking( { { "role", "assistant" } }, lock ); + size_t i = 1; + while( i < chat.size() ) + { + if( chat[i]["role"].get_ref() == "user" && + chat[i-1]["role"].get_ref() == "user" ) + { + auto& str = chat[i-1]["content"].get_ref(); + assert( str.starts_with( "\n" ) ); + str.append( "\n\n" ); + str.append( chat[i]["content"].get_ref() ); + chat.erase( chat.begin() + i ); + } + else + { + i++; + } + } + nlohmann::json req; req["model"] = m_api->GetModels()[m_modelIdx].name; req["messages"] = std::move( chat );