Skip to content

Commit da4da5f

Browse files
author
Afonso Menegola
committed
featgit status
1 parent 0f087a4 commit da4da5f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/unittests/flows/llm_flows/test_output_schema_processor.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,41 @@ async def test_output_schema_helper_functions():
254254
assert extracted_json is None
255255

256256

257+
@pytest.mark.asyncio
258+
async def test_get_structured_model_response_with_non_ascii():
259+
"""Test get_structured_model_response with non-ASCII characters."""
260+
from google.adk.events.event import Event
261+
from google.adk.flows.llm_flows._output_schema_processor import (
262+
get_structured_model_response,
263+
)
264+
from google.genai import types
265+
266+
# Test with a dictionary containing non-ASCII characters
267+
test_dict = {'city': 'São Paulo'}
268+
expected_json = '{"city": "São Paulo"}'
269+
270+
# Create a function response event
271+
function_response_event = Event(
272+
author='test_agent',
273+
content=types.Content(
274+
role='user',
275+
parts=[
276+
types.Part(
277+
function_response=types.FunctionResponse(
278+
name='set_model_response', response=test_dict
279+
)
280+
)
281+
],
282+
),
283+
)
284+
285+
# Get the structured response
286+
extracted_json = get_structured_model_response(function_response_event)
287+
288+
# Assert that the output is the expected JSON string without escaped characters
289+
assert extracted_json == expected_json
290+
291+
257292
@pytest.mark.asyncio
258293
async def test_end_to_end_integration():
259294
"""Test the complete output schema with tools integration."""

0 commit comments

Comments
 (0)