Skip to content

Commit

Permalink
feat: Add crewai install CLI command (#1203)
Browse files Browse the repository at this point in the history
* feat: Add crewai install CLI command

* feat: Add crewai install to the docs and force now crewai run
  • Loading branch information
pythonbyte committed Aug 17, 2024
1 parent ddda8f6 commit 231a833
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ To install the dependencies for your project, use Poetry:

```shell
$ cd <project_name>
$ poetry lock
$ poetry install
$ crewai install
```

## Running Your Pipeline Project
Expand All @@ -121,12 +120,6 @@ To run your pipeline project, use the following command:
$ crewai run
```

or

```shell
$ poetry run <project_name>
```

This will initialize your pipeline and begin task execution as defined in your `main.py` file.

## Deploying Your Pipeline Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ To install the dependencies for your project, you can use Poetry. First, navigat

```shell
$ cd my_project
$ poetry lock
$ poetry install
$ crewai install
```

This will install the dependencies specified in the `pyproject.toml` file.
Expand Down Expand Up @@ -233,11 +232,6 @@ To run your project, use the following command:
```shell
$ crewai run
```
or
```shell
$ poetry run my_project
```

This will initialize your crew of AI agents and begin task execution as defined in your configuration in the `main.py` file.

### Replay Tasks from Latest Crew Kickoff
Expand Down
11 changes: 9 additions & 2 deletions src/crewai/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
)

from .evaluate_crew import evaluate_crew
from .install_crew import install_crew
from .replay_from_task import replay_task_command
from .reset_memories_command import reset_memories_command
from .run_crew import run_crew
Expand Down Expand Up @@ -165,10 +166,16 @@ def test(n_iterations: int, model: str):
evaluate_crew(n_iterations, model)


@crewai.command()
def install():
"""Install the Crew."""
install_crew()


@crewai.command()
def run():
"""Run the crew."""
click.echo("Running the crew")
"""Run the Crew."""
click.echo("Running the Crew")
run_crew()


Expand Down
21 changes: 21 additions & 0 deletions src/crewai/cli/install_crew.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess

import click


def install_crew() -> None:
"""
Install the crew by running the Poetry command to lock and install.
"""
try:
subprocess.run(["poetry", "lock"], check=True, capture_output=False, text=True)
subprocess.run(
["poetry", "install"], check=True, capture_output=False, text=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)

except Exception as e:
click.echo(f"An unexpected error occurred: {e}", err=True)
11 changes: 2 additions & 9 deletions src/crewai/cli/templates/crew/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ pip install poetry

Next, navigate to your project directory and install the dependencies:

1. First lock the dependencies and then install them:
1. First lock the dependencies and install them by using the CLI command:
```bash
poetry lock
```
```bash
poetry install
crewai install
```
### Customizing

Expand All @@ -37,10 +34,6 @@ To kickstart your crew of AI agents and begin task execution, run this from the
```bash
$ crewai run
```
or
```bash
poetry run {{folder_name}}
```

This command initializes the {{name}} Crew, assembling the agents and assigning them tasks as defined in your configuration.

Expand Down
8 changes: 2 additions & 6 deletions src/crewai/cli/templates/pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ Next, navigate to your project directory and install the dependencies:
1. First lock the dependencies and then install them:

```bash
poetry lock
```

```bash
poetry install
crewai install
```

### Customizing
Expand All @@ -38,7 +34,7 @@ poetry install
To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:

```bash
poetry run {{folder_name}}
crewai run
```

This command initializes the {{name}} Crew, assembling the agents and assigning them tasks as defined in your configuration.
Expand Down
7 changes: 2 additions & 5 deletions src/crewai/cli/templates/pipeline_router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ Next, navigate to your project directory and install the dependencies:

1. First lock the dependencies and then install them:
```bash
poetry lock
```
```bash
poetry install
crewai install
```
### Customizing

Expand All @@ -35,7 +32,7 @@ poetry install
To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:

```bash
poetry run {{folder_name}}
crewai run
```

This command initializes the {{name}} Crew, assembling the agents and assigning them tasks as defined in your configuration.
Expand Down

0 comments on commit 231a833

Please sign in to comment.