diff --git a/docs/core-concepts/Training-Crew.md b/docs/core-concepts/Training-Crew.md index 01fef7c5b..3e08b1072 100644 --- a/docs/core-concepts/Training-Crew.md +++ b/docs/core-concepts/Training-Crew.md @@ -20,18 +20,9 @@ crewai train -n Replace `` with the desired number of training iterations. This determines how many times the agents will go through the training process. -Remember to also replace the placeholder inputs with the actual values you want to use on the main.py file in the `train` function. - -```python -def train(): - """ - Train the crew for a given number of iterations. - """ - inputs = {"topic": "AI LLMs"} - try: - ProjectCreationCrew().crew().train(n_iterations=int(sys.argv[1]), inputs=inputs) - ... -``` +### Key Points to Note: +- **Positive Integer Requirement:** Ensure that the number of iterations (`n_iterations`) is a positive integer. The code will raise a `ValueError` if this condition is not met. +- **Error Handling:** The code handles subprocess errors and unexpected exceptions, providing error messages to the user. It is important to note that the training process may take some time, depending on the complexity of your agents and will also require your feedback on each iteration. diff --git a/docs/how-to/Kickoff-async.md b/docs/how-to/Kickoff-async.md index e69de29bb..e8386288a 100644 --- a/docs/how-to/Kickoff-async.md +++ b/docs/how-to/Kickoff-async.md @@ -0,0 +1,40 @@ +--- +title: Kickoff Async +description: Kickoff a Crew Asynchronously +--- + +## Introduction +CrewAI provides the ability to kickoff a crew asynchronously, allowing you to start the crew execution in a non-blocking manner. This feature is particularly useful when you want to run multiple crews concurrently or when you need to perform other tasks while the crew is executing. + +## Asynchronous Crew Execution +To kickoff a crew asynchronously, use the `kickoff_async()` method. This method initiates the crew execution in a separate thread, allowing the main thread to continue executing other tasks. + +Here's an example of how to kickoff a crew asynchronously: + +```python +from crewai import Crew, Agent, Task + +# Create an agent with code execution enabled +coding_agent = Agent( + role="Python Data Analyst", + goal="Analyze data and provide insights using Python", + backstory="You are an experienced data analyst with strong Python skills.", + allow_code_execution=True +) + +# Create a task that requires code execution +data_analysis_task = Task( + description="Analyze the given dataset and calculate the average age of participants. Ages: {ages}", + agent=coding_agent +) + +# Create a crew and add the task +analysis_crew = Crew( + agents=[coding_agent], + tasks=[data_analysis_task] +) + +# Execute the crew +result = analysis_crew.kickoff_async(inputs={"ages": [25, 30, 35, 40, 45]}) +``` + diff --git a/docs/how-to/Kickoff-for-each.md b/docs/how-to/Kickoff-for-each.md index e69de29bb..daacb9830 100644 --- a/docs/how-to/Kickoff-for-each.md +++ b/docs/how-to/Kickoff-for-each.md @@ -0,0 +1,45 @@ +--- +title: Kickoff For Each +description: Kickoff a Crew for a List +--- + +## Introduction +CrewAI provides the ability to kickoff a crew for each item in a list, allowing you to execute the crew for each item in the list. This feature is particularly useful when you need to perform the same set of tasks for multiple items. + +## Kicking Off a Crew for Each Item +To kickoff a crew for each item in a list, use the `kickoff_for_each()` method. This method executes the crew for each item in the list, allowing you to process multiple items efficiently. + +Here's an example of how to kickoff a crew for each item in a list: + +```python +from crewai import Crew, Agent, Task + +# Create an agent with code execution enabled +coding_agent = Agent( + role="Python Data Analyst", + goal="Analyze data and provide insights using Python", + backstory="You are an experienced data analyst with strong Python skills.", + allow_code_execution=True +) + +# Create a task that requires code execution +data_analysis_task = Task( + description="Analyze the given dataset and calculate the average age of participants. Ages: {ages}", + agent=coding_agent +) + +# Create a crew and add the task +analysis_crew = Crew( + agents=[coding_agent], + tasks=[data_analysis_task] +) + +datasets = [ + { "ages": [25, 30, 35, 40, 45] }, + { "ages": [20, 25, 30, 35, 40] }, + { "ages": [30, 35, 40, 45, 50] } +] + +# Execute the crew +result = analysis_crew.kickoff_for_each(inputs=datasets) +```