Skip to content
Snippets Groups Projects
Commit 71b245ad authored by Elliot Kang's avatar Elliot Kang
Browse files

Update OutputParser.test.ts

added new test cases, our LLM is not guaranteed to give us the exact formatted output.
parent 5b070cf8
No related branches found
No related tags found
No related merge requests found
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);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment