Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/unittests/models/test_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2985,6 +2985,43 @@ def test_message_to_generate_content_response_tool_call_malformed_arguments_logs
assert '{"city":"unterminated' in caplog.text


def test_message_to_generate_content_response_tool_call_without_arguments(
caplog,
):
"""A tool call carrying no arguments is dispatched, and is not malformed."""
message = ChatCompletionAssistantMessage(
role="assistant",
content=None,
tool_calls=[
ChatCompletionMessageToolCall(
type="function",
id="test_tool_call_id",
function=Function(
name="test_function",
arguments="",
),
)
],
)

with caplog.at_level(
logging.WARNING, logger="google_adk.google.adk.models.lite_llm"
):
response = _message_to_generate_content_response(message)

function_calls = [
part.function_call
for part in response.content.parts
if part.function_call is not None
]
assert len(function_calls) == 1
assert function_calls[0].name == "test_function"
assert function_calls[0].id == "test_tool_call_id"
assert isinstance(function_calls[0].args, dict)
assert not function_calls[0].args
assert "Malformed" not in caplog.text


def test_message_to_generate_content_response_inline_tool_call_text():
message = ChatCompletionAssistantMessage(
role="assistant",
Expand Down