aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/AnswerParser.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-08-29 21:01:29 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-08-29 21:01:29 -0400
commit3a1d859359b462fc9a9f1c001d6681a8d886f2b6 (patch)
treea0969bee2375be2c2d795dcd046de60ed67a3ad5 /src/client/views/nodes/ChatBox/AnswerParser.ts
parent9be434cddc30baada63aff0c5dae6dbf606f2590 (diff)
added loop summary and updated type for RAG tool output
Diffstat (limited to 'src/client/views/nodes/ChatBox/AnswerParser.ts')
-rw-r--r--src/client/views/nodes/ChatBox/AnswerParser.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/client/views/nodes/ChatBox/AnswerParser.ts b/src/client/views/nodes/ChatBox/AnswerParser.ts
index 05d26b8de..885114195 100644
--- a/src/client/views/nodes/ChatBox/AnswerParser.ts
+++ b/src/client/views/nodes/ChatBox/AnswerParser.ts
@@ -10,10 +10,12 @@ export class AnswerParser {
const questionRegex = /<question>(.*?)<\/question>/g;
const groundedTextRegex = /<grounded_text citation_index="([^"]+)">([\s\S]*?)<\/grounded_text>/g;
const normalTextRegex = /<normal_text>([\s\S]*?)<\/normal_text>/g;
+ const loopSummaryRegex = /<loop_summary>([\s\S]*?)<\/loop_summary>/;
const answerMatch = answerRegex.exec(xml);
const citationsMatch = citationsRegex.exec(xml);
const followUpQuestionsMatch = followUpQuestionsRegex.exec(xml);
+ const loopSummaryMatch = loopSummaryRegex.exec(xml);
if (!answerMatch) {
throw new Error('Invalid XML: Missing <answer> tag.');
@@ -31,6 +33,9 @@ export class AnswerParser {
if (followUpQuestionsMatch) {
rawTextContent = rawTextContent.replace(followUpQuestionsMatch[0], '').trim();
}
+ if (loopSummaryMatch) {
+ rawTextContent = rawTextContent.replace(loopSummaryMatch[0], '').trim();
+ }
// Parse citations
let citationMatch;
@@ -112,6 +117,7 @@ export class AnswerParser {
follow_up_questions: followUpQuestions,
citations,
processing_info: processingInfo,
+ loop_summary: loopSummaryMatch ? loopSummaryMatch[1].trim() : undefined,
};
return assistantResponse;