Skip to content

Commit 01573c1

Browse files
soapunmdrxy
andauthored
fix(core): ensure_ascii=False in PydanticOutputParser exception formatting (#34006)
- **Description:** When formatting an error, `PydanticOutputParser` dumps json with default `ensure_ascii=True` - **Issue:** Fixes #34005 - **Dependencies:** None - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. **We will not consider a PR unless these three are passing in CI.** See [contribution guidelines](https://docs.langchain.com/oss/python/contributing) for more. Co-authored-by: Mason Daugherty <[email protected]>
1 parent 2ba3ce8 commit 01573c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libs/core/langchain_core/output_parsers/pydantic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _parse_obj(self, obj: dict) -> TBaseModel:
3737
def _parser_exception(
3838
self, e: Exception, json_object: dict
3939
) -> OutputParserException:
40-
json_string = json.dumps(json_object)
40+
json_string = json.dumps(json_object, ensure_ascii=False)
4141
name = self.pydantic_object.__name__
4242
msg = f"Failed to parse {name} from completion {json_string}. Got: {e}"
4343
return OutputParserException(msg, llm_output=json_string)

0 commit comments

Comments
 (0)