Skip to content

The agent engineering platform.

fix(core): output parser bugs in xml.py and pydantic.py (#35641)

AI不止语3a6053329580
diff --git a/libs/core/langchain_core/output_parsers/pydantic.py b/libs/core/langchain_core/output_parsers/pydantic.py
index 3f8130e1e3..27f0664b06 100644
--- a/libs/core/langchain_core/output_parsers/pydantic.py
+++ b/libs/core/langchain_core/output_parsers/pydantic.py
@@ -74,7 +74,7 @@ class PydanticOutputParser(JsonOutputParser, Generic[TBaseModel]):
The parsed Pydantic object.
"""
try:
- json_object = super().parse_result(result)
+ json_object = super().parse_result(result, partial=partial)
return self._parse_obj(json_object)
except OutputParserException:
if partial:
diff --git a/libs/core/langchain_core/output_parsers/xml.py b/libs/core/langchain_core/output_parsers/xml.py
index a26a37ffcf..f3f2bcad09 100644
--- a/libs/core/langchain_core/output_parsers/xml.py
+++ b/libs/core/langchain_core/output_parsers/xml.py
@@ -63,8 +63,9 @@ class _StreamingParser:
if not _HAS_DEFUSEDXML:
msg = (
"defusedxml is not installed. "
- "Please install it to use the defusedxml parser."
- "You can install it with `pip install defusedxml` "
+ "Please install it to use the defusedxml parser. "
+ "You can install it with `pip install defusedxml`. "
+ "See https://github.com/tiran/defusedxml for more details"
)
raise ImportError(msg)
parser_ = XMLParser(target=TreeBuilder())
@@ -214,8 +215,8 @@ class XMLOutputParser(BaseTransformOutputParser[dict[str, Any]]):
Raises:
OutputParserException: If the XML is not well-formed.
- ImportError: If defus`edxml is not installed and the `defusedxml` parser is
- requested.
+ ImportError: If `defusedxml` is not installed and the `defusedxml` parser
+ is requested.
"""
# Try to find XML string within triple backticks
# Imports are temporarily placed here to avoid issue with caching on CI
@@ -224,8 +225,8 @@ class XMLOutputParser(BaseTransformOutputParser[dict[str, Any]]):
if not _HAS_DEFUSEDXML:
msg = (
"defusedxml is not installed. "
- "Please install it to use the defusedxml parser."
- "You can install it with `pip install defusedxml`"
+ "Please install it to use the defusedxml parser. "
+ "You can install it with `pip install defusedxml`. "
"See https://github.com/tiran/defusedxml for more details"
)
raise ImportError(msg)