Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _format_assistant_message(message: ChatMessageContent) -> Message:
assistant_message["tool_calls"] = [
{
"function": {
"name": tool_call.function_name,
"name": tool_call.name or tool_call.function_name,
"arguments": tool_call.arguments
if isinstance(tool_call.arguments, Mapping)
else json.loads(tool_call.arguments or "{}"),
Expand Down
14 changes: 14 additions & 0 deletions python/tests/unit/connectors/ai/ollama/services/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ def test_message_converters_assistant_with_tool_calls() -> None:
)


def test_message_converters_assistant_tool_calls_keep_plugin_name() -> None:
"""Test assistant tool calls are sent back with the fully qualified name used in the tool definitions."""
tool_call_1 = FunctionCallContent(name="Weather-get_weather", arguments={"city": "Paris"})
tool_call_2 = FunctionCallContent(plugin_name="Time", function_name="get_time", arguments='{"zone": "Tokyo"}')
content = ChatMessageContent(role=AuthorRole.ASSISTANT, items=[tool_call_1, tool_call_2])

result = MESSAGE_CONVERTERS[AuthorRole.ASSISTANT](content)

assert [tool_call["function"]["name"] for tool_call in result["tool_calls"]] == [
"Weather-get_weather",
"Time-get_time",
]


def test_message_converters_tool_with_result() -> None:
"""Test tool message with a FunctionResultContent, verifying the message content is set."""
# Arrange
Expand Down
Loading