Skip to content

Commit

Permalink
fix(search): token limit in chat approach
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Oct 13, 2023
1 parent 1f2c0b3 commit e6ad883
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/search/src/lib/approaches/chat-read-retrieve-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach {
messageBuilder.appendMessage('user', userContent, appendIndex);

for (const historyMessage of history.slice(0, -1).reverse()) {
if (messageBuilder.tokens > maxTokens) {
break;
}
if (historyMessage.bot) {
messageBuilder.appendMessage('assistant', historyMessage.bot, appendIndex);
}
Expand Down

0 comments on commit e6ad883

Please sign in to comment.