aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/AnswerParser.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-08-19 10:55:57 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-08-19 10:55:57 -0400
commitff3c041af6738d025926732115a032d40cffb859 (patch)
treee55ad36ed1ef999b498bd4f87e505bf7ff6c3263 /src/client/views/nodes/ChatBox/AnswerParser.ts
parent2c38022a7f21d4b498277b18ad31baf24ac3a143 (diff)
working on making streaming work
Diffstat (limited to 'src/client/views/nodes/ChatBox/AnswerParser.ts')
-rw-r--r--src/client/views/nodes/ChatBox/AnswerParser.ts14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/client/views/nodes/ChatBox/AnswerParser.ts b/src/client/views/nodes/ChatBox/AnswerParser.ts
index 9956792d8..68637b7c7 100644
--- a/src/client/views/nodes/ChatBox/AnswerParser.ts
+++ b/src/client/views/nodes/ChatBox/AnswerParser.ts
@@ -2,7 +2,7 @@ import { ASSISTANT_ROLE, AssistantMessage, Citation, CHUNK_TYPE, TEXT_TYPE, getC
import { v4 as uuid } from 'uuid';
export class AnswerParser {
- static parse(xml: string): AssistantMessage {
+ static parse(xml: string, currentMessage: AssistantMessage): AssistantMessage {
const answerRegex = /<answer>([\s\S]*?)<\/answer>/;
const citationsRegex = /<citations>([\s\S]*?)<\/citations>/;
const citationRegex = /<citation index="([^"]+)" chunk_id="([^"]+)" type="([^"]+)">([\s\S]*?)<\/citation>/g;
@@ -102,14 +102,10 @@ export class AnswerParser {
followUpQuestions.push(questionMatch[1].trim());
}
}
+ currentMessage.content = currentMessage.content.concat(content);
+ currentMessage.citations = citations;
+ currentMessage.follow_up_questions = followUpQuestions;
- const assistantResponse: AssistantMessage = {
- role: ASSISTANT_ROLE.ASSISTANT,
- content,
- follow_up_questions: followUpQuestions,
- citations,
- };
-
- return assistantResponse;
+ return currentMessage;
}
}