From 71b245ad6faf5d82404dc635fdec1c79b1ff79f2 Mon Sep 17 00:00:00 2001
From: Elliot Kang <kkang2097@gmail.com>
Date: Sun, 10 Sep 2023 21:36:16 -0700
Subject: [PATCH] Update OutputParser.test.ts

added new test cases, our LLM is not guaranteed to give us the exact formatted output.
---
 packages/core/src/tests/OutputParser.test.ts | 57 ++++++++++++++------
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/packages/core/src/tests/OutputParser.test.ts b/packages/core/src/tests/OutputParser.test.ts
index 20cee6598..cb4418987 100644
--- a/packages/core/src/tests/OutputParser.test.ts
+++ b/packages/core/src/tests/OutputParser.test.ts
@@ -1,7 +1,7 @@
 import { SubQuestionOutputParser } from "../OutputParser";
 
 describe("SubQuestionOutputParser", () => {
-  test("parses expected",() => {
+  test("parses expected", () => {
     //TODO: This is dummy code, fill this in...
     const parser = new SubQuestionOutputParser();
 
@@ -17,30 +17,53 @@ describe("SubQuestionOutputParser", () => {
     ];
 
     const data_str: string = JSON.stringify(data);
-    const full_string = 
-`\`\`\`json
+    const full_string = `\`\`\`json
 ${data_str}
 \`\`\``;
 
-    const real_answer = {parsedOutput: data, rawOutput: full_string};
-    
+    const real_answer = { parsedOutput: data, rawOutput: full_string };
+
     expect(parser.parse(full_string)).toEqual(real_answer);
   });
 
+  test("parses unexpected", () => {
+    const parser = new SubQuestionOutputParser();
+    const data_str =
+      "[\n" +
+      "    {\n" +
+      `        "subQuestion": "Sorry, I don't have any relevant information to answer your question",\n` +
+      '        "toolName": ""\n' +
+      "    }\n" +
+      "]";
+    const data = [
+      {
+        subQuestion:
+          "Sorry, I don't have any relevant information to answer your question",
+        toolName: "",
+      },
+    ];
+    const real_answer = { parsedOutput: data, rawOutput: data_str };
+    expect(parser.parse(data_str)).toEqual(real_answer);
+  });
 
-  test("parses unexpected", ()=> {
+  test("parses unexpected2", () => {
     const parser = new SubQuestionOutputParser();
-    const data_str = '[\n' +
-    '    {\n' +
-    `        "subQuestion": "Sorry, I don't have any relevant information to answer your question",\n` +
-    '        "toolName": ""\n' +
-    '    }\n' +
-    ']';
-    const data = [{subQuestion: "Sorry, I don't have any relevant information to answer your question",
-                    toolName: ""}];
-    const real_answer = {parsedOutput: data, rawOutput: data_str};
+    const data_str =
+      "[\n" +
+      "    {\n" +
+      '        "subQuestion": "What is the meaning of smth1",\n' +
+      '        "toolName": "smth1"\n' +
+      "    },\n" +
+      "    {\n" +
+      '        "subQuestion": "What is the meaning of smth2",\n' +
+      '        "toolName": "smth2"\n' +
+      "    }\n" +
+      "]";
+    const data = [
+      { subQuestion: "What is the meaning of smth1", toolName: "smth1" },
+      { subQuestion: "What is the meaning of smth2", toolName: "smth2" },
+    ];
+    const real_answer = { parsedOutput: data, rawOutput: data_str };
     expect(parser.parse(data_str)).toEqual(real_answer);
   });
 });
-
-
-- 
GitLab