Parsing error when using StructuredOutputParser.fromZodSchema and schema has an array #6948
Replies: 1 comment 4 replies
-
Hey @yonatanhakatan! 👋 How can I assist you today? I found a similar unsolved discussion regarding parsing nested objects inside arrays with To resolve the
If your JSON input is formatted as a markdown code snippet, ensure it is correctly extracted before parsing. The parser expects the JSON to be well-formatted and free of any markdown artifacts. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
This works:
This does not work:
Description
I'm exploring using langchain.js to provide more structured output when interacting with llm's.
I've been following this guide: https://js.langchain.com/docs/how_to/output_parser_structured and as per my first example above when my zod schema describes the shape of the output as being an
answer
key with a simple string value everything works fine.However, as per the 2nd example above when I change the shape of the zod schema to expect an answer which is an array of strings I get an
OutputParserException
error:System Info
platform: mac
node: v20.17.0
npm: 10.8.2
Beta Was this translation helpful? Give feedback.
All reactions