Skip to content

Commit

Permalink
fix(duplicates): workaround for duplicates
Browse files Browse the repository at this point in the history
a proper fix will come later. Stopgap solution.
  • Loading branch information
massi-ang authored and bigadsoleiman committed Feb 2, 2024
1 parent 58876be commit c1ef47d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/user-interface/react-app/src/components/chatbot/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,22 @@ export function updateMessageHistoryRef(
messageHistory.at(-1)?.type !== ChatBotMessageType.Human
) {
const lastMessage = messageHistory.at(-1)!;
lastMessage.tokens = lastMessage.tokens || [];
lastMessage.tokens = lastMessage.tokens ?? [];
if (hasToken) {
lastMessage.tokens.push(token);
// Workaround for text duplicates issue
if (
!lastMessage.tokens
.map((t) => t.sequenceNumber)
.includes(token.sequenceNumber)
) {
lastMessage.tokens.push(token);
} else {
return;
}
} else {
}

lastMessage.tokens.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
console.log(lastMessage);
if (lastMessage.tokens.length > 0) {
const lastRunId =
lastMessage.tokens[lastMessage.tokens.length - 1].runId;
Expand Down

0 comments on commit c1ef47d

Please sign in to comment.