Decrease context usage when removing chat content.

This commit is contained in:
Bartosz Taudul
2025-06-29 14:08:40 +02:00
parent b54c4f7aa9
commit 4e8fb7870b

View File

@@ -472,6 +472,15 @@ void TracyLlm::Draw()
inputChanged = true;
}
auto cit = it;
while( cit != m_chat.end() )
{
const auto& content = (*cit)["content"].get_ref<const std::string&>();
const auto tokens = m_api->Tokenize( content, m_modelIdx );
m_usedCtx -= tokens >= 0 ? tokens : content.size() / 4;
++cit;
}
m_chat.erase( it, m_chat.end() );
if( m_responding ) m_stop = true;
ImGui::PopID();