The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
bugfix: throw exception if structured output parser doesn't get what it wants (#3044)
Tim Aspdcdcd3f636f9
diff --git a/langchain/output_parsers/structured.py b/langchain/output_parsers/structured.pyindex 566e0885d0..d9c7b83a01 100644--- a/langchain/output_parsers/structured.py+++ b/langchain/output_parsers/structured.py@@ -38,6 +38,12 @@ class StructuredOutputParser(BaseOutputParser):return STRUCTURED_FORMAT_INSTRUCTIONS.format(format=schema_str)def parse(self, text: str) -> Any:+ if "```json" not in text:+ raise OutputParserException(+ f"Got invalid return object. Expected markdown code snippet with JSON "+ f"object, but got:\n{text}"+ )+json_string = text.split("```json")[1].strip().strip("```").strip()try:json_obj = json.loads(json_string)