|
17 | 17 | from collections import deque
|
18 | 18 | from dataclasses import dataclass, replace
|
19 | 19 | from typing import (
|
| 20 | + Awaitable, |
20 | 21 | Callable,
|
21 | 22 | Deque,
|
22 | 23 | Final,
|
@@ -92,7 +93,9 @@ def __init__(
|
92 | 93 | plugins: Optional[List[str]] = None,
|
93 | 94 | max_steps: Optional[int] = None,
|
94 | 95 | first_tools: Optional[Sequence[BaseTool]] = [],
|
95 |
| - first_tools_rejected_callback: Optional[Callable[[BaseTool, List[Message], AgentStep], None]] = None, |
| 96 | + first_tools_rejected_callback: Optional[ |
| 97 | + Callable[[BaseTool, List[Message], AgentStep], Awaitable[None]] |
| 98 | + ] = None, |
96 | 99 | ) -> None:
|
97 | 100 | """Initialize a function agent.
|
98 | 101 |
|
@@ -183,7 +186,7 @@ async def _run(self, prompt: str, files: Optional[Sequence[File]] = None) -> Age
|
183 | 186 | # If tool choice not work, skip this round
|
184 | 187 | _logger.warning(f"Selected tool [{tool.tool_name}] not work")
|
185 | 188 | if self._first_tools_rejected_callback is not None:
|
186 |
| - self._first_tools_rejected_callback(tool, new_messages, curr_step) |
| 189 | + await self._first_tools_rejected_callback(tool, new_messages, curr_step) |
187 | 190 |
|
188 | 191 | while num_steps_taken < self.max_steps:
|
189 | 192 | curr_step, new_messages = await self._step(chat_history)
|
|
0 commit comments