[core] add test for json parser (#15297)

this should fail, but isnt

---------

Co-authored-by: Nuno Campos <nuno@langchain.dev>
This commit is contained in:
Harrison Chase
2023-12-29 09:59:39 -08:00
committed by GitHub
parent ec090745a6
commit c3b3b77a11
3 changed files with 36 additions and 20 deletions

View File

@@ -78,17 +78,20 @@ class JsonOutputFunctionsParser(BaseCumulativeTransformOutputParser[Any]):
raise OutputParserException(f"Could not parse function call: {exc}")
try:
if partial:
if self.args_only:
return parse_partial_json(
function_call["arguments"], strict=self.strict
)
else:
return {
**function_call,
"arguments": parse_partial_json(
try:
if self.args_only:
return parse_partial_json(
function_call["arguments"], strict=self.strict
),
}
)
else:
return {
**function_call,
"arguments": parse_partial_json(
function_call["arguments"], strict=self.strict
),
}
except json.JSONDecodeError:
return None
else:
if self.args_only:
try: