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:
@@ -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):
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user