mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-13 15:14:50 -06:00
Copybara import of the project:
-- 50b09bbe9735c889a9c815eddcee6715ebe848da by Yuan Chai <350365422@qq.com>: fix: improve json serialization by allowing non-ascii characters -- c66977ae6ec4edc71a2d633eb09918eb2a226461 by Yuan Chai <350365422@qq.com>: fix: serialize function call arguments to JSON string Previously accepted JSON objects directly, which was less robust. Now serialize arguments to JSON strings using `_safe_json_serialize`, ensuring stability and handling non-ASCII characters correctly. COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/605 from nauyiahc:fix_non_ascii_char a52513c5747296b717acee989684324e1b072d34 PiperOrigin-RevId: 764396496
This commit is contained in:
parent
3cd4cd3ecf
commit
c4cd1802bf
@ -136,7 +136,7 @@ def _safe_json_serialize(obj) -> str:
|
||||
|
||||
try:
|
||||
# Try direct JSON serialization first
|
||||
return json.dumps(obj)
|
||||
return json.dumps(obj, ensure_ascii=False)
|
||||
except (TypeError, OverflowError):
|
||||
return str(obj)
|
||||
|
||||
@ -186,7 +186,7 @@ def _content_to_message_param(
|
||||
id=part.function_call.id,
|
||||
function=Function(
|
||||
name=part.function_call.name,
|
||||
arguments=json.dumps(part.function_call.args),
|
||||
arguments=_safe_json_serialize(part.function_call.args),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user