mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-01 16:08:30 +00:00
Decrease context usage when removing chat content.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user