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.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/views/nodes/ChatBox/AnswerParser.ts b/src/client/views/nodes/ChatBox/AnswerParser.ts
index 68637b7c7..1d46a366d 100644
--- a/src/client/views/nodes/ChatBox/AnswerParser.ts
+++ b/src/client/views/nodes/ChatBox/AnswerParser.ts
@@ -1,8 +1,8 @@
-import { ASSISTANT_ROLE, AssistantMessage, Citation, CHUNK_TYPE, TEXT_TYPE, getChunkType } from './types';
+import { ASSISTANT_ROLE, AssistantMessage, Citation, CHUNK_TYPE, TEXT_TYPE, getChunkType, ProcessingInfo } from './types';
import { v4 as uuid } from 'uuid';
export class AnswerParser {
- static parse(xml: string, currentMessage: AssistantMessage): AssistantMessage {
+ static parse(xml: string, processingInfo: ProcessingInfo[]): 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,10 +102,15 @@ export class AnswerParser {
followUpQuestions.push(questionMatch[1].trim());
}
}
- currentMessage.content = currentMessage.content.concat(content);
- currentMessage.citations = citations;
- currentMessage.follow_up_questions = followUpQuestions;
- return currentMessage;
+ const assistantResponse: AssistantMessage = {
+ role: ASSISTANT_ROLE.ASSISTANT,
+ content,
+ follow_up_questions: followUpQuestions,
+ citations,
+ processing_info: processingInfo,
+ };
+
+ return assistantResponse;
}
}