Open hadifar opened 2 months ago
I'm not sure whether this is a bug. @eyurtsev What do you think?
This is a python issue with str and json. str() by design converts python dictionaries to use single quotes for keys which is not allowed in json spec. When you try to loads a str() of a dictionary then you will get a JSONParse error.
JsonOutputParser() could handle this with replacing all single quotes with double quotes but that carries some risk. The json utility already has to handle mismatched quotes, etc. It feels unlikely that an LLM returns a json with single quoted properties. FYI - @ashvin-a @eyurtsev
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
File "langchain_core\output_parsers\json.py", line 87, in parse_result raise OutputParserException(msg, llm_output=text) from e langchaincore.exceptions.OutputParserException: Invalid json output: {'response': "The user question does not align with the structure or data within our database tables. The tables are relational in terms and follow the naming convention of 'galvatron' or'mac', however the user question appears unrelated to the type of data and structure of the tables."}
Description
I'm not entirely sure if it is a bug. I found it really strange that when string contains escape character we have such an issue. We can resolve the issue by dumping it to JSON first.
System Info
System Information
Package Information