diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 37bd8c62d..d99c19524 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,13 +19,13 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11.9" - name: Install Requirements run: | + set -e pip install poetry - poetry lock && poetry install - name: Run tests - run: poetry run pytest tests + run: poetry run pytest diff --git a/docs/core-concepts/Crews.md b/docs/core-concepts/Crews.md index dec6adfc8..a9b19b26e 100644 --- a/docs/core-concepts/Crews.md +++ b/docs/core-concepts/Crews.md @@ -123,7 +123,7 @@ result = my_crew.kickoff() print(result) ``` -### Different wayt to Kicking Off a Crew +### Different ways to Kicking Off a Crew Once your crew is assembled, initiate the workflow with the appropriate kickoff method. CrewAI provides several methods for better control over the kickoff process: `kickoff()`, `kickoff_for_each()`, `kickoff_async()`, and `kickoff_for_each_async()`. diff --git a/docs/core-concepts/Memory.md b/docs/core-concepts/Memory.md index ce7955e0e..9c9d47be0 100644 --- a/docs/core-concepts/Memory.md +++ b/docs/core-concepts/Memory.md @@ -12,7 +12,7 @@ description: Leveraging memory systems in the crewAI framework to enhance agent | Component | Description | | :------------------- | :----------------------------------------------------------- | | **Short-Term Memory**| Temporarily stores recent interactions and outcomes, enabling agents to recall and utilize information relevant to their current context during the current executions. | -| **Long-Term Memory** | Preserves valuable insights and learnings from past executions, allowing agents to build and refine their knowledge over time. So Agents can remeber what they did right and wrong across multiple executions | +| **Long-Term Memory** | Preserves valuable insights and learnings from past executions, allowing agents to build and refine their knowledge over time. So Agents can remember what they did right and wrong across multiple executions | | **Entity Memory** | Captures and organizes information about entities (people, places, concepts) encountered during tasks, facilitating deeper understanding and relationship mapping. | | **Contextual Memory**| Maintains the context of interactions by combining `ShortTermMemory`, `LongTermMemory`, and `EntityMemory`, aiding in the coherence and relevance of agent responses over a sequence of tasks or a conversation. | diff --git a/docs/core-concepts/Training-Crew.md b/docs/core-concepts/Training-Crew.md index 3e08b1072..1fae7ff4d 100644 --- a/docs/core-concepts/Training-Crew.md +++ b/docs/core-concepts/Training-Crew.md @@ -8,6 +8,7 @@ The training feature in CrewAI allows you to train your AI agents using the comm During training, CrewAI utilizes techniques to optimize the performance of your agents along with human feedback. This helps the agents improve their understanding, decision-making, and problem-solving abilities. +### Training Your Crew Using the CLI To use the training feature, follow these steps: 1. Open your terminal or command prompt. @@ -18,7 +19,26 @@ To use the training feature, follow these steps: crewai train -n ``` -Replace `` with the desired number of training iterations. This determines how many times the agents will go through the training process. +### Training Your Crew Programmatically +To train your crew programmatically, use the following steps: + +1. Define the number of iterations for training. +2. Specify the input parameters for the training process. +3. Execute the training command within a try-except block to handle potential errors. + +```python + n_iterations = 2 + inputs = {"topic": "CrewAI Training"} + + try: + YourCrewName_Crew().crew().train(n_iterations= n_iterations, inputs=inputs) + + except Exception as e: + raise Exception(f"An error occurred while training the crew: {e}") +``` + +!!! note "Replace `` with the desired number of training iterations. This determines how many times the agents will go through the training process." + ### 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. diff --git a/docs/how-to/Create-Custom-Tools.md b/docs/how-to/Create-Custom-Tools.md index e0e91c4f2..c5e260687 100644 --- a/docs/how-to/Create-Custom-Tools.md +++ b/docs/how-to/Create-Custom-Tools.md @@ -51,7 +51,7 @@ To optimize tool performance with caching, define custom caching strategies usin @tool("Tool with Caching") def cached_tool(argument: str) -> str: """Tool functionality description.""" - return "Cachable result" + return "Cacheable result" def my_cache_strategy(arguments: dict, result: str) -> bool: # Define custom caching logic diff --git a/docs/how-to/Creating-a-Crew-and-kick-it-off.md b/docs/how-to/Creating-a-Crew-and-kick-it-off.md index 7b5dd325e..85b1ba506 100644 --- a/docs/how-to/Creating-a-Crew-and-kick-it-off.md +++ b/docs/how-to/Creating-a-Crew-and-kick-it-off.md @@ -79,5 +79,4 @@ manager = Agent( 1. `allow_code_execution`: Enable or disable code execution capabilities for the agent (default is False). 2. `max_execution_time`: Set a maximum execution time (in seconds) for the agent to complete a task. -3. `function_calling_llm`: Specify a separate language model for function calling. -4 \ No newline at end of file +3. `function_calling_llm`: Specify a separate language model for function calling. \ No newline at end of file diff --git a/docs/how-to/Force-Tool-Ouput-as-Result.md b/docs/how-to/Force-Tool-Ouput-as-Result.md new file mode 100644 index 000000000..c40d0af29 --- /dev/null +++ b/docs/how-to/Force-Tool-Ouput-as-Result.md @@ -0,0 +1,31 @@ +--- +title: Forcing Tool Output as Result +description: Learn how to force tool output as the result in of an Agent's task in crewAI. +--- + +## Introduction +In CrewAI, you can force the output of a tool as the result of an agent's task. This feature is useful when you want to ensure that the tool output is captured and returned as the task result, and avoid the agent modifying the output during the task execution. + +## Forcing Tool Output as Result +To force the tool output as the result of an agent's task, you can set the `force_tool_output` parameter to `True` when creating the task. This parameter ensures that the tool output is captured and returned as the task result, without any modifications by the agent. + +Here's an example of how to force the tool output as the result of an agent's task: + +```python +# ... +# Define a custom tool that returns the result as the answer +coding_agent =Agent( + role="Data Scientist", + goal="Product amazing resports on AI", + backstory="You work with data and AI", + tools=[MyCustomTool(result_as_answer=True)], + ) +# ... +``` + +### Workflow in Action + +1. **Task Execution**: The agent executes the task using the tool provided. +2. **Tool Output**: The tool generates the output, which is captured as the task result. +3. **Agent Interaction**: The agent my reflect and take learnings from the tool but the output is not modified. +4. **Result Return**: The tool output is returned as the task result without any modifications. diff --git a/docs/how-to/Start-a-New-CrewAI-Project.md b/docs/how-to/Start-a-New-CrewAI-Project.md new file mode 100644 index 000000000..b34a4cf77 --- /dev/null +++ b/docs/how-to/Start-a-New-CrewAI-Project.md @@ -0,0 +1,137 @@ +--- +title: Starting a New CrewAI Project +description: A comprehensive guide to starting a new CrewAI project, including the latest updates and project setup methods. +--- + +# Starting Your CrewAI Project + +Welcome to the ultimate guide for starting a new CrewAI project. This document will walk you through the steps to create, customize, and run your CrewAI project, ensuring you have everything you need to get started. + +## Prerequisites + +We assume you have already installed CrewAI. If not, please refer to the [installation guide](how-to/Installing-CrewAI.md) to install CrewAI and its dependencies. + +## Creating a New Project + +To create a new project, run the following CLI command: + +```shell +$ crewai create my_project +``` + +This command will create a new project folder with the following structure: + +```shell +my_project/ +├── .gitignore +├── pyproject.toml +├── README.md +└── src/ + └── my_project/ + ├── __init__.py + ├── main.py + ├── crew.py + ├── tools/ + │ ├── custom_tool.py + │ └── __init__.py + └── config/ + ├── agents.yaml + └── tasks.yaml +``` + +You can now start developing your project by editing the files in the `src/my_project` folder. The `main.py` file is the entry point of your project, and the `crew.py` file is where you define your agents and tasks. + +## Customizing Your Project + +To customize your project, you can: +- Modify `src/my_project/config/agents.yaml` to define your agents. +- Modify `src/my_project/config/tasks.yaml` to define your tasks. +- Modify `src/my_project/crew.py` to add your own logic, tools, and specific arguments. +- Modify `src/my_project/main.py` to add custom inputs for your agents and tasks. +- Add your environment variables into the `.env` file. + +### Example: Defining Agents and Tasks + +#### agents.yaml + +```yaml +researcher: + role: > + Job Candidate Researcher + goal: > + Find potential candidates for the job + backstory: > + You are adept at finding the right candidates by exploring various online + resources. Your skill in identifying suitable candidates ensures the best + match for job positions. +``` + +#### tasks.yaml + +```yaml +research_candidates_task: + description: > + Conduct thorough research to find potential candidates for the specified job. + Utilize various online resources and databases to gather a comprehensive list of potential candidates. + Ensure that the candidates meet the job requirements provided. + + Job Requirements: + {job_requirements} + expected_output: > + A list of 10 potential candidates with their contact information and brief profiles highlighting their suitability. +``` + +## Installing Dependencies + +To install the dependencies for your project, you can use Poetry. First, navigate to your project directory: + +```shell +$ cd my_project +$ poetry lock +$ poetry install +``` + +This will install the dependencies specified in the `pyproject.toml` file. + +## Interpolating Variables + +Any variable interpolated in your `agents.yaml` and `tasks.yaml` files like `{variable}` will be replaced by the value of the variable in the `main.py` file. + +#### agents.yaml + +```yaml +research_task: + description: > + Conduct a thorough research about the customer and competitors in the context + of {customer_domain}. + Make sure you find any interesting and relevant information given the + current year is 2024. + expected_output: > + A complete report on the customer and their customers and competitors, + including their demographics, preferences, market positioning and audience engagement. +``` + +#### main.py + +```python +# main.py +def run(): + inputs = { + "customer_domain": "crewai.com" + } + MyProjectCrew(inputs).crew().kickoff(inputs=inputs) +``` + +## Running Your Project + +To run your project, use the following command: + +```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. + +## Deploying Your Project + +The easiest way to deploy your crew is through [CrewAI+](https://www.crewai.com/crewaiplus), where you can deploy your crew in a few clicks. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index eccf8831a..66b4a7a37 100644 --- a/docs/index.md +++ b/docs/index.md @@ -48,6 +48,11 @@ Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By

How-To Guides