1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Google Gen AI: Increase max iterations for AI Task (#162600)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Paulus Schoutsen
2026-02-11 15:55:37 -05:00
committed by GitHub
parent 1c3f24c78f
commit 5331cd99c6
2 changed files with 6 additions and 2 deletions

View File

@@ -80,7 +80,10 @@ class GoogleGenerativeAITaskEntity(
) -> ai_task.GenDataTaskResult: ) -> ai_task.GenDataTaskResult:
"""Handle a generate data task.""" """Handle a generate data task."""
await self._async_handle_chat_log( await self._async_handle_chat_log(
chat_log, task.structure, default_max_tokens=RECOMMENDED_AI_TASK_MAX_TOKENS chat_log,
task.structure,
default_max_tokens=RECOMMENDED_AI_TASK_MAX_TOKENS,
max_iterations=1000,
) )
if not isinstance(chat_log.content[-1], conversation.AssistantContent): if not isinstance(chat_log.content[-1], conversation.AssistantContent):

View File

@@ -486,6 +486,7 @@ class GoogleGenerativeAILLMBaseEntity(Entity):
chat_log: conversation.ChatLog, chat_log: conversation.ChatLog,
structure: vol.Schema | None = None, structure: vol.Schema | None = None,
default_max_tokens: int | None = None, default_max_tokens: int | None = None,
max_iterations: int = MAX_TOOL_ITERATIONS,
) -> None: ) -> None:
"""Generate an answer for the chat log.""" """Generate an answer for the chat log."""
options = self.subentry.data options = self.subentry.data
@@ -602,7 +603,7 @@ class GoogleGenerativeAILLMBaseEntity(Entity):
) )
# To prevent infinite loops, we limit the number of iterations # To prevent infinite loops, we limit the number of iterations
for _iteration in range(MAX_TOOL_ITERATIONS): for _iteration in range(max_iterations):
try: try:
chat_response_generator = await chat.send_message_stream( chat_response_generator = await chat.send_message_stream(
message=chat_request message=chat_request