Don't crash when prompt is too large.

This commit is contained in:
Adam Treat
2023-04-26 19:08:37 -04:00
parent 562906da11
commit 70e6b45123
3 changed files with 17 additions and 1 deletions

View File

@@ -252,6 +252,13 @@ bool LLMObject::handleResponse(int32_t token, const std::string &response)
fflush(stdout);
#endif
// check for error
if (token < 0) {
m_response.append(response);
emit responseChanged();
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());