recreating executor upon setting new step_callback

This commit is contained in:
João Moura
2024-02-09 01:52:28 -08:00
parent a1e0596450
commit d36c2a74cb
2 changed files with 4 additions and 3 deletions

View File

@@ -175,7 +175,7 @@ class Agent(BaseModel):
"""
self.cache_handler = cache_handler
self.tools_handler = ToolsHandler(cache=self.cache_handler)
self._create_agent_executor()
self.create_agent_executor()
def set_rpm_controller(self, rpm_controller: RPMController) -> None:
"""Set the rpm controller for the agent.
@@ -185,9 +185,9 @@ class Agent(BaseModel):
"""
if not self._rpm_controller:
self._rpm_controller = rpm_controller
self._create_agent_executor()
self.create_agent_executor()
def _create_agent_executor(self) -> None:
def create_agent_executor(self) -> None:
"""Create an agent executor for the agent.
Returns:

View File

@@ -177,6 +177,7 @@ class Crew(BaseModel):
agent.i18n = I18N(language=self.language)
if (self.step_callback) and (not agent.step_callback):
agent.step_callback = self.step_callback
agent.create_agent_executor()
if self.process == Process.sequential:
return self._run_sequential_process()