Move the saving of the tokens to the impl and not the callbacks responsibility.

This commit is contained in:
Adam Treat
2023-04-27 11:16:51 -04:00
parent ba4b28fcd5
commit 5a7d40f604
3 changed files with 25 additions and 13 deletions

View File

@@ -265,10 +265,6 @@ QList<QString> LLMObject::modelList() const
bool LLMObject::handlePrompt(int32_t token)
{
if (s_ctx.tokens.size() == s_ctx.n_ctx)
s_ctx.tokens.erase(s_ctx.tokens.begin());
s_ctx.tokens.push_back(token);
// m_promptResponseTokens and m_responseLogits are related to last prompt/response not
// the entire context window which we can reset on regenerate prompt
++m_promptResponseTokens;
@@ -289,11 +285,6 @@ bool LLMObject::handleResponse(int32_t token, const std::string &response)
return false;
}
// Save the token to our prompt ctxt
if (s_ctx.tokens.size() == s_ctx.n_ctx)
s_ctx.tokens.erase(s_ctx.tokens.begin());
s_ctx.tokens.push_back(token);
// m_promptResponseTokens and m_responseLogits are related to last prompt/response not
// the entire context window which we can reset on regenerate prompt
++m_promptResponseTokens;