mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-13 15:14:50 -06:00
fix: do not convert "false" value to dict
This causes information loss, and is unexpected from user. PiperOrigin-RevId: 764558190
This commit is contained in:
parent
b70e74c450
commit
60ceea72bd
@ -107,9 +107,9 @@ You could retry calling this tool, but it is IMPORTANT for you to provide all th
|
||||
or hasattr(self.func, '__call__')
|
||||
and inspect.iscoroutinefunction(self.func.__call__)
|
||||
):
|
||||
return await self.func(**args_to_call) or {}
|
||||
return await self.func(**args_to_call)
|
||||
else:
|
||||
return self.func(**args_to_call) or {}
|
||||
return self.func(**args_to_call)
|
||||
|
||||
# TODO(hangfei): fix call live for function stream.
|
||||
async def _call_live(
|
||||
|
@ -86,6 +86,16 @@ def function_for_testing_with_4_arg_and_no_tool_context(arg1, arg2, arg3, arg4):
|
||||
pass
|
||||
|
||||
|
||||
def function_returning_none() -> None:
|
||||
"""Function for testing with no return value."""
|
||||
return None
|
||||
|
||||
|
||||
def function_returning_empty_dict() -> dict[str, str]:
|
||||
"""Function for testing with empty dict return value."""
|
||||
return {}
|
||||
|
||||
|
||||
def test_init():
|
||||
"""Test that the FunctionTool is initialized correctly."""
|
||||
tool = FunctionTool(function_for_testing_with_no_args)
|
||||
@ -94,6 +104,20 @@ def test_init():
|
||||
assert tool.func == function_for_testing_with_no_args
|
||||
|
||||
|
||||
def test_function_returning_none():
|
||||
"""Test that the function returns with None actually returning None."""
|
||||
tool = FunctionTool(function_returning_none)
|
||||
result = await tool.run_async(args={}, tool_context=MagicMock())
|
||||
assert result is None
|
||||
|
||||
|
||||
def test_function_returning_empty_dict():
|
||||
"""Test that the function returns with empty dict actually returning empty dict."""
|
||||
tool = FunctionTool(function_returning_empty_dict)
|
||||
result = await tool.run_async(args={}, tool_context=MagicMock())
|
||||
assert isinstance(result, dict)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_async_with_tool_context_async_func():
|
||||
"""Test that run_async calls the function with tool_context when tool_context is in signature (async function)."""
|
||||
|
Loading…
Reference in New Issue
Block a user