aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/AnswerParser.ts
diff options
context:
space:
mode:
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;
}
}