mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix todo tool broken with Gemini 2.0 models. (#140246)
* Change tool name for addlist item * Change to HasListAddItem * extract to function
This commit is contained in:
parent
0bbab63193
commit
c43f6a67d0
@ -276,6 +276,13 @@ class GoogleGenerativeAIConversationEntity(
|
||||
):
|
||||
return await self._async_handle_message(user_input, chat_log)
|
||||
|
||||
def _fix_tool_name(self, tool_name: str) -> str:
|
||||
"""Fix tool name if needed."""
|
||||
# The Gemini 2.0+ tokenizer seemingly has a issue with the HassListAddItem tool
|
||||
# name. This makes sure when it incorrectly changes the name, that we change it
|
||||
# back for HA to call.
|
||||
return tool_name if tool_name != "HasListAddItem" else "HassListAddItem"
|
||||
|
||||
async def _async_handle_message(
|
||||
self,
|
||||
user_input: conversation.ConversationInput,
|
||||
@ -435,7 +442,10 @@ class GoogleGenerativeAIConversationEntity(
|
||||
tool_name = tool_call.name
|
||||
tool_args = _escape_decode(tool_call.args)
|
||||
tool_calls.append(
|
||||
llm.ToolInput(tool_name=tool_name, tool_args=tool_args)
|
||||
llm.ToolInput(
|
||||
tool_name=self._fix_tool_name(tool_name),
|
||||
tool_args=tool_args,
|
||||
)
|
||||
)
|
||||
|
||||
chat_request = _create_google_tool_response_content(
|
||||
|
Loading…
x
Reference in New Issue
Block a user