Skip to content

Commit e28224b

Browse files
committed
enhance json parses
1 parent f963e5a commit e28224b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/components/nodes/outputparsers/StructuredOutputParser/StructuredOutputParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class StructuredOutputParser implements INode {
7979

8080
// Fix broken JSON from LLM
8181
structuredOutputParser.parse = (text) => {
82-
const jsonString = text.includes('```') ? text.trim().split(/```(?:json)?/)[1] : text.trim()
82+
const jsonString = text.replace(/(?:^[^{[]*)|(?:[^}\]]*$)/g, '')
8383
return baseParse.call(structuredOutputParser, jsonrepair(jsonString))
8484
}
8585

0 commit comments

Comments
 (0)