Compare commits

...

3 Commits

Author SHA1 Message Date
Lorenze Jay
a9e7bf6727 adding index + 1 so its in order 2024-07-12 15:10:07 -07:00
Lorenze Jay
f39bce18a9 created cli command for listing completed tasks ids 2024-07-12 15:08:53 -07:00
Lorenze Jay
96af6027bd fixing changes 2024-07-12 13:53:40 -07:00
3 changed files with 42 additions and 1 deletions

View File

@@ -164,7 +164,7 @@ Kickoffs will now create a `crew_tasks_ouput.json` file with the output of the t
### Replaying from specific task Using the CLI
To use the replay_from_tasks feature, follow these steps:
To use the replay feature, follow these steps:
1. Open your terminal or command prompt.
2. Navigate to the directory where your CrewAI project is located.

View File

@@ -5,6 +5,7 @@ import pkg_resources
from .create_crew import create_crew
from .train_crew import train_crew
from .replay_from_task import replay_task_command
from .list_task_outputs import show_task_outputs
@click.group()
@@ -71,5 +72,11 @@ def replay(task_id: str) -> None:
click.echo(f"An error occurred while replaying: {e}", err=True)
@crewai.command()
def list_completed_tasks_ids():
"""List all task outputs saved from crew_tasks_output.json."""
show_task_outputs()
if __name__ == "__main__":
crewai()

View File

@@ -0,0 +1,34 @@
import subprocess
import click
from pathlib import Path
import json
def show_task_outputs() -> None:
"""
Replay the crew execution from a specific task.
Args:
task_id (str): The ID of the task to replay from.
"""
try:
file_path = Path("crew_tasks_output.json")
if not file_path.exists():
click.echo("crew_tasks_output.json not found.")
return
with open(file_path, "r") as f:
tasks = json.load(f)
for index, task in enumerate(tasks):
click.echo(f"Task {index + 1}: {task['task_id']}")
click.echo(f"Description: {task['output']['description']}")
click.echo("---")
except subprocess.CalledProcessError as e:
click.echo(f"An error occurred while replaying the task: {e}", err=True)
click.echo(e.output, err=True)
except Exception as e:
click.echo(f"An unexpected error occurred: {e}", err=True)