mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Replace dot with underscores for NamespacedTool and ActionTool (#147764)
This commit is contained in:
parent
23773759ea
commit
3151713a34
@ -331,7 +331,7 @@ class NamespacedTool(Tool):
|
||||
def __init__(self, namespace: str, tool: Tool) -> None:
|
||||
"""Init the class."""
|
||||
self.namespace = namespace
|
||||
self.name = f"{namespace}.{tool.name}"
|
||||
self.name = f"{namespace}__{tool.name}"
|
||||
self.description = tool.description
|
||||
self.parameters = tool.parameters
|
||||
self.tool = tool
|
||||
@ -915,7 +915,7 @@ class ActionTool(Tool):
|
||||
"""Init the class."""
|
||||
self._domain = domain
|
||||
self._action = action
|
||||
self.name = f"{domain}.{action}"
|
||||
self.name = f"{domain}__{action}"
|
||||
# Note: _get_cached_action_parameters only works for services which
|
||||
# add their description directly to the service description cache.
|
||||
# This is not the case for most services, but it is for scripts.
|
||||
|
@ -1542,18 +1542,18 @@ This is prompt 2
|
||||
"""
|
||||
)
|
||||
assert [(tool.name, tool.description) for tool in instance.tools] == [
|
||||
("api-1.Tool_1", "Description 1"),
|
||||
("api-2.Tool_2", "Description 2"),
|
||||
("api-1__Tool_1", "Description 1"),
|
||||
("api-2__Tool_2", "Description 2"),
|
||||
]
|
||||
|
||||
# The test tool returns back the provided arguments so we can verify
|
||||
# the original tool is invoked with the correct tool name and args.
|
||||
result = await instance.async_call_tool(
|
||||
llm.ToolInput(tool_name="api-1.Tool_1", tool_args={"arg1": "value1"})
|
||||
llm.ToolInput(tool_name="api-1__Tool_1", tool_args={"arg1": "value1"})
|
||||
)
|
||||
assert result == {"result": {"Tool_1": {"arg1": "value1"}}}
|
||||
|
||||
result = await instance.async_call_tool(
|
||||
llm.ToolInput(tool_name="api-2.Tool_2", tool_args={"arg2": "value2"})
|
||||
llm.ToolInput(tool_name="api-2__Tool_2", tool_args={"arg2": "value2"})
|
||||
)
|
||||
assert result == {"result": {"Tool_2": {"arg2": "value2"}}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user