Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/crewai/agents/crew_agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,32 @@ def _handle_crew_training_output(
color="red",
)

if self.ask_for_human_input and human_feedback is not None:
training_data = {
"initial_output": result.output,
"human_feedback": human_feedback,
"agent": agent_id,
"agent_role": self.agent.role,
}
if self.crew is not None and hasattr(self.crew, "_train_iteration"):
train_iteration = self.crew._train_iteration
if isinstance(train_iteration, int):
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:
self._logger.log(
"error",
"Crew is None or does not have _train_iteration attribute.",
color="red",
)

def _format_prompt(self, prompt: str, inputs: Dict[str, str]) -> str:
prompt = prompt.replace("{input}", inputs["input"])
prompt = prompt.replace("{tool_names}", inputs["tool_names"])
Expand Down
10 changes: 7 additions & 3 deletions src/crewai/cli/run_crew.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess

import click
import tomllib


def run_crew() -> None:
Expand All @@ -9,13 +10,16 @@ def run_crew() -> None:
"""
command = ["uv", "run", "run_crew"]
try:
subprocess.run(command, capture_output=True, text=True, check=True)
subprocess.run(command, capture_output=False, text=True, check=True)

except subprocess.CalledProcessError as e:
click.echo(f"An error occurred while running the crew: {e}", err=True)
click.echo(e.output, err=True, nl=True)
click.echo(e.stderr, err=True, nl=True)
if "table found" in e.stderr:

with open("pyproject.toml", "rb") as f:
data = tomllib.load(f)

if data.get("tool", {}).get("poetry"):
click.secho(
"It's possible that you are using an old version of crewAI that uses poetry, please run `crewai update` to update your pyproject.toml to use uv.",
fg="yellow",
Expand Down