Skip to content

Commit

Permalink
Use zod parse async (langchain-ai#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos authored Apr 28, 2023
1 parent ca643e2 commit 11397ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion langchain/src/output_parsers/structured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Including the leading and trailing "\`\`\`json" and "\`\`\`"
async parse(text: string): Promise<z.infer<T>> {
try {
const json = text.trim().split("```json")[1].split("```")[0].trim();
return this.schema.parse(JSON.parse(json));
return this.schema.parseAsync(JSON.parse(json));
} catch (e) {
throw new OutputParserException(
`Failed to parse. Text: "${text}". Error: ${e}`
Expand Down

0 comments on commit 11397ab

Please sign in to comment.