mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
pleasing the types gods
This commit is contained in:
@@ -102,6 +102,10 @@ class Agent(BaseAgent):
|
|||||||
default=True,
|
default=True,
|
||||||
description="Keep messages under the context window size by summarizing content.",
|
description="Keep messages under the context window size by summarizing content.",
|
||||||
)
|
)
|
||||||
|
max_iter: int = Field(
|
||||||
|
default=15,
|
||||||
|
description="Maximum number of iterations for an agent to execute a task before giving it's best answer",
|
||||||
|
)
|
||||||
max_retry_limit: int = Field(
|
max_retry_limit: int = Field(
|
||||||
default=2,
|
default=2,
|
||||||
description="Maximum number of retries for an agent to execute a task when an error occurs.",
|
description="Maximum number of retries for an agent to execute a task when an error occurs.",
|
||||||
|
|||||||
@@ -226,11 +226,17 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
):
|
):
|
||||||
training_data = CrewTrainingHandler(TRAINING_DATA_FILE).load()
|
training_data = CrewTrainingHandler(TRAINING_DATA_FILE).load()
|
||||||
if training_data.get(agent_id):
|
if training_data.get(agent_id):
|
||||||
# type: ignore[union-attr]
|
if self.crew is not None and hasattr(self.crew, "_train_iteration"):
|
||||||
training_data[agent_id][self.crew._train_iteration][
|
training_data[agent_id][self.crew._train_iteration][
|
||||||
"improved_output"
|
"improved_output"
|
||||||
] = result.output
|
] = result.output
|
||||||
CrewTrainingHandler(TRAINING_DATA_FILE).save(training_data)
|
CrewTrainingHandler(TRAINING_DATA_FILE).save(training_data)
|
||||||
|
else:
|
||||||
|
self._logger.log(
|
||||||
|
"error",
|
||||||
|
"Invalid crew or missing _train_iteration attribute.",
|
||||||
|
color="red",
|
||||||
|
)
|
||||||
|
|
||||||
if self.ask_for_human_input and human_feedback is not None:
|
if self.ask_for_human_input and human_feedback is not None:
|
||||||
training_data = {
|
training_data = {
|
||||||
@@ -239,15 +245,22 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
"agent": agent_id,
|
"agent": agent_id,
|
||||||
"agent_role": self.agent.role,
|
"agent_role": self.agent.role,
|
||||||
}
|
}
|
||||||
# type: ignore[union-attr]
|
if self.crew is not None and hasattr(self.crew, "_train_iteration"):
|
||||||
if isinstance(self.crew._train_iteration, int):
|
train_iteration = self.crew._train_iteration
|
||||||
CrewTrainingHandler(TRAINING_DATA_FILE).append(
|
if isinstance(train_iteration, int):
|
||||||
self.crew._train_iteration, agent_id, training_data
|
CrewTrainingHandler(TRAINING_DATA_FILE).append(
|
||||||
)
|
train_iteration, agent_id, training_data
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self._logger.log(
|
||||||
|
"error",
|
||||||
|
"Invalid train iteration type. Expected int.",
|
||||||
|
color="red",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self._logger.log(
|
self._logger.log(
|
||||||
"error",
|
"error",
|
||||||
"Invalid train iteration type. Expected int.",
|
"Crew is None or does not have _train_iteration attribute.",
|
||||||
color="red",
|
color="red",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user