robust_output_parser
JSON output parser with robust error handling
Warning
This module was written to parse sloppy JSON emitted by the Mixtral-8/7xb family of models and is currently deprecated and not being actively maintained.
Attributes
FORMAT_INSTRUCTIONS
module-attribute
FORMAT_INSTRUCTIONS = 'The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```. JSON must be parsable by Python\'s json.loads() method:\n\n```json\n{{\n{format}\n}}\n```'
Classes
RobustOutputParser
Bases: StructuredOutputParser
Enhancement to the StructuredOutputParser class that allows for more flexible parsing of JSON output from LLMs.
Functions
get_clean_json
Extracts a clean JSON string from the given text and returns it as a dictionary.
Parameters:
-
text
(str
) –The input text containing the JSON.
Returns:
-
dict
(Dict[Any, Any]
) –The extracted JSON as a dictionary.
Raises:
-
ValueError
–If the JSON cannot be extracted or parsed.