Skip to content

Commit

Permalink
allow serialize_to_str to work with non ascii when dumping via json.d…
Browse files Browse the repository at this point in the history
…umps (microsoft#2714)

Co-authored-by: Jason <[email protected]>
Co-authored-by: Chi Wang <[email protected]>
  • Loading branch information
3 people authored May 24, 2024
1 parent c2d4d46 commit aad6a28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autogen/function_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@ def serialize_to_str(x: Any) -> str:
elif isinstance(x, BaseModel):
return model_dump_json(x)
else:
return json.dumps(x)
return json.dumps(x, ensure_ascii=False)
4 changes: 4 additions & 0 deletions test/test_function_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ async def f(
assert actual[1] == "EUR"


def test_serialize_to_str_with_nonascii() -> None:
assert serialize_to_str("中文") == "中文"


def test_serialize_to_json() -> None:
assert serialize_to_str("abc") == "abc"
assert serialize_to_str(123) == "123"
Expand Down

0 comments on commit aad6a28

Please sign in to comment.