Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adanbu committed Nov 3, 2024
2 parents 59d2972 + 5f0e6af commit e12338a
Show file tree
Hide file tree
Showing 24 changed files with 4,865 additions and 120 deletions.
37 changes: 20 additions & 17 deletions email_auto_responder_flow/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
[tool.poetry]
[project]
name = "email_auto_responder_flow"
version = "0.1.0"
description = "email_auto_responder_flow using crewAI"
authors = ["Your Name <you@example.com>"]
authors = [
{ name = "Your Name", email = "you@example.com" },
]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]>=0.76.2,<1.0.0",
"asyncio*",
"langchain-tools>=0.1.34",
"crewai-tools>=0.12.0",
"google-auth-oauthlib>=1.2.1",
"google-api-python-client>=2.145.0",
]

[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = ">=0.67.1,<1.0.0" }
asyncio = "*"
langchain-tools = "^0.1.34"
crewai-tools = "^0.12.0"
google-auth-oauthlib = "^1.2.1"
google-api-python-client = "^2.145.0"

[tool.poetry.scripts]
email_auto_responder_flow = "email_auto_responder_flow.main:main"
run_flow = "email_auto_responder_flow.main:main"
plot_flow = "email_auto_responder_flow.main:plot"
[project.scripts]
kickoff = "email_auto_responder_flow.main:kickoff"
plot = "email_auto_responder_flow.main:plot"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = [
"hatchling",
]
build-backend = "hatchling.build"
15 changes: 3 additions & 12 deletions email_auto_responder_flow/src/email_auto_responder_flow/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
import asyncio
import time
from typing import List

Expand Down Expand Up @@ -45,29 +44,21 @@ def generate_draft_responses(self):
time.sleep(180)


async def run_flow():
def kickoff():
"""
Run the flow.
"""
email_auto_response_flow = EmailAutoResponderFlow()
email_auto_response_flow.kickoff()


async def plot_flow():
def plot_flow():
"""
Plot the flow.
"""
email_auto_response_flow = EmailAutoResponderFlow()
email_auto_response_flow.plot()


def main():
asyncio.run(run_flow())


def plot():
asyncio.run(plot_flow())


if __name__ == "__main__":
main()
kickoff()
40 changes: 21 additions & 19 deletions lead-score-flow/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
[tool.poetry]
[project]
name = "lead_score_flow"
version = "0.1.0"
description = "lead_score_flow using crewAI"
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = ">=0.67.1,<1.0.0" }
asyncio = "*"
langchain-tools = "^0.1.34"
crewai-tools = "^0.12.0"
google-auth-oauthlib = "^1.2.1"
google-api-python-client = "^2.145.0"
pyvis = "^0.3.2"

[tool.poetry.scripts]
lead_score_flow = "lead_score_flow.main:main"
run_flow = "lead_score_flow.main:main"
plot_flow = "lead_score_flow.main:plot"
authors = [
{ name = "Your Name", email = "you@example.com" },
]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]>=0.76.2,<1.0.0",
"asyncio*",
"langchain-tools>=0.1.34",
"crewai-tools>=0.12.0",
"google-auth-oauthlib>=1.2.1",
"google-api-python-client>=2.145.0",
"pyvis>=0.3.2",
]

[project.scripts]
kickoff = "lead_score_flow.main:kickoff"
plot = "lead_score_flow.main:plot"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = [
"hatchling",
]
build-backend = "hatchling.build"
14 changes: 3 additions & 11 deletions lead-score-flow/src/lead_score_flow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,21 @@ async def write_email(candidate):
print(message)


async def run_flow():
def kickoff():
"""
Run the flow.
"""
lead_score_flow = LeadScoreFlow()
lead_score_flow.kickoff()


async def plot_flow():
def plot():
"""
Plot the flow.
"""
lead_score_flow = LeadScoreFlow()
lead_score_flow.plot()


def main():
asyncio.run(run_flow())


def plot():
asyncio.run(plot_flow())


if __name__ == "__main__":
main()
kickoff()
31 changes: 17 additions & 14 deletions meeting_assistant_flow/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[tool.poetry]
[project]
name = "meeting_assistant_flow"
version = "0.1.0"
description = "meeting_assistant_flow using crewAI"
authors = ["Your Name <you@example.com>"]
authors = [
{ name = "Your Name", email = "you@example.com" },
]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]>=0.76.2,<1.0.0",
"asyncio*",
"slack-sdk>=3.33.1",
]

[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = ">=0.67.1,<1.0.0" }
asyncio = "*"
slack-sdk = "^3.33.1"

[tool.poetry.scripts]
meeting_assistant_flow = "meeting_assistant_flow.main:main"
run_flow = "meeting_assistant_flow.main:main"
plot_flow = "meeting_assistant_flow.main:plot"
[project.scripts]
kickoff = "meeting_assistant_flow.main:kickoff"
plot = "meeting_assistant_flow.main:plot"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = [
"hatchling",
]
build-backend = "hatchling.build"
15 changes: 3 additions & 12 deletions meeting_assistant_flow/src/meeting_assistant_flow/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
import asyncio
import csv
import os
from typing import List
Expand Down Expand Up @@ -67,29 +66,21 @@ def send_slack_notification(self):
send_message_to_channel(message)


async def run_flow():
def kickoff():
"""
Run the flow.
"""
meeting_flow = MeetingFlow()
meeting_flow.kickoff()


async def plot_flow():
def plot():
"""
Plot the flow.
"""
meeting_flow = MeetingFlow()
meeting_flow.plot()


def main():
asyncio.run(run_flow())


def plot():
asyncio.run(plot_flow())


if __name__ == "__main__":
main()
kickoff()
3 changes: 3 additions & 0 deletions self_evaluation_loop_flow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
__pycache__/
lib/
80 changes: 80 additions & 0 deletions self_evaluation_loop_flow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Self Evaluation Loop Flow

Welcome to the Self Evaluation Loop Flow project, powered by [crewAI](https://crewai.com). This project showcases a powerful pattern in AI workflows: automatic self-evaluation. By leveraging crewAI's multi-agent system, this flow demonstrates how to set up a Crew that evaluates the responses of other Crews, iterating with feedback to improve results.

## Overview

This flow guides you through setting up an automated self-evaluation system using two main Crews: the `ShakespeareanXPostCrew` and the `XPostReviewCrew`. The process involves the following steps:

1. **Generate Initial Output**: The `ShakespeareanXPostCrew` generates an initial Shakespearean-style post (X post) on a given topic, such as "Flying cars". This post is crafted to be humorous and playful, adhering to specific character limits and style guidelines.

2. **Evaluate Output**: The `XPostReviewCrew` evaluates the generated post to ensure it meets the required criteria, such as character count and absence of emojis. The crew provides feedback on the post's validity and quality.

3. **Iterate with Feedback**: If the post does not meet the criteria, the flow iterates by regenerating the post with the feedback provided. This iterative process continues until the post is valid or a maximum retry limit is reached.

4. **Finalize and Save**: Once the post is validated, it is finalized and saved for further use. If the maximum retry count is exceeded without achieving a valid post, the flow exits with the last generated post and feedback.

This pattern of automatic self-evaluation is crucial for developing robust AI systems that can adapt and improve over time, ensuring high-quality outputs through iterative refinement.

## Installation

Ensure you have Python >=3.10 <=3.13 installed on your system.

To install CrewAI, run the following command:

```bash
pip install crewai
```

This command will install CrewAI and its necessary dependencies, allowing you to start building and managing AI agents efficiently.

### Customizing

**Add your `OPENAI_API_KEY` into the `.env` file**

- Modify `src/flow_self_evalulation_loop/config/agents.yaml` to define your agents.
- Modify `src/flow_self_evalulation_loop/config/tasks.yaml` to define your tasks.
- Modify `src/flow_self_evalulation_loop/crew.py` to add your own logic, tools, and specific arguments.
- Modify `src/flow_self_evalulation_loop/main.py` to add custom inputs for your agents and tasks.

## Running the Project

To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:

```bash
crewai flow kickoff
```


This command initializes the self-evaluation loop flow, assembling the agents and assigning them tasks as defined in your configuration.

The unmodified example will generate a `report.md` file with the output of a research on LLMs in the root folder.

## Understanding Your Flow

The self-evaluation loop flow is composed of 2 Crews. These agents collaborate on a series of tasks, defined in `config/tasks.yaml`, leveraging their collective skills to achieve complex objectives. The `config/agents.yaml` file outlines the capabilities and configurations of each agent in your flow.

This flow is centered around two major Crews: the `ShakespeareanXPostCrew` and the `XPostReviewCrew`. The `ShakespeareanXPostCrew` is responsible for generating a Shakespearean-style post (X post) on a given topic, while the `XPostReviewCrew` evaluates the generated post to ensure it meets specific criteria. The process is iterative, using feedback from the review to refine the post until it is valid or a maximum retry limit is reached.

### Flow Structure

1. **Generate Initial Output**: A Crew generates the initial output based on predefined criteria.

2. **Evaluate Output**: Another Crew evaluates the output, providing feedback on its validity and quality.

3. **Iterate with Feedback**: If necessary, the initial Crew is re-run with feedback to improve the output.

4. **Finalize and Save**: Once validated, the output is saved for further use.

By understanding the flow structure, you can see how multiple Crews are orchestrated to work together, each handling a specific part of the self-evaluation process. This modular approach allows for efficient and scalable automation.

## Support

For support, questions, or feedback regarding the Self Evaluation Loop Flow or crewAI:

- Visit our [documentation](https://docs.crewai.com)
- Reach out to us through our [GitHub repository](https://github.com/joaomdmoura/crewai)
- [Join our Discord](https://discord.com/invite/X4JWnZnxPb)
- [Chat with our docs](https://chatg.pt/DWjSBZn)

Let's create wonders together with the power and simplicity of crewAI.
Loading

0 comments on commit e12338a

Please sign in to comment.