L3-Chains RouterOutputParser fails in JS

I’m attempting to follow the course using the LangChain JS api. In the L3 MultiPromptChain the RouterOutputParser is throwing an error attempting to parse the output, but as far as I can tell the output is correct according to the prompt. I’ve extracted the output it’s failing to parse and can recreate the error with this short snippet:

import { RouterOutputParser } from 'langchain/output_parsers';

let outputParser = new RouterOutputParser();

let result = await outputParser.parse('```json\n' +
    '{\n' +
    '    "destination": "physics",\n' +
    '    "next_inputs": "Explain black body radiation"\n' +
    '}\n' +
    '```');

Any ideas why this is failing?

1 Like

i encountered the same issue in the original python code.

i changed the last sentence of MULTI_PROMPT_ROUTER_TEMPLATE and it worked.

change to →

<< OUTPUT (remember to include the ```json and ```)>>"""

3 Likes