-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1 of self evaluation loop with flows working
- Loading branch information
1 parent
156b290
commit 71f0f20
Showing
22 changed files
with
4,815 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
__pycache__/ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# {{crew_name}} Crew | ||
|
||
Welcome to the {{crew_name}} Crew project, powered by [crewAI](https://crewai.com). This template is designed to help you set up a multi-agent AI system with ease, leveraging the powerful and flexible framework provided by crewAI. Our goal is to enable your agents to collaborate effectively on complex tasks, maximizing their collective intelligence and capabilities. | ||
|
||
## Installation | ||
|
||
Ensure you have Python >=3.10 <=3.13 installed on your system. This project uses [UV](https://docs.astral.sh/uv/) for dependency management and package handling, offering a seamless setup and execution experience. | ||
|
||
First, if you haven't already, install uv: | ||
|
||
```bash | ||
pip install uv | ||
``` | ||
|
||
Next, navigate to your project directory and install the dependencies: | ||
|
||
(Optional) Lock the dependencies and install them by using the CLI command: | ||
```bash | ||
crewai install | ||
``` | ||
|
||
### 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 args | ||
- 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 run | ||
``` | ||
|
||
This command initializes the flow-self-evalulation-loop Crew, assembling the agents and assigning them tasks as defined in your configuration. | ||
|
||
This example, unmodified, will run the create a `report.md` file with the output of a research on LLMs in the root folder. | ||
|
||
## Understanding Your Crew | ||
|
||
The flow-self-evalulation-loop Crew is composed of multiple AI agents, each with unique roles, goals, and tools. 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 crew. | ||
|
||
## Support | ||
|
||
For support, questions, or feedback regarding the {{crew_name}} Crew 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. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[project] | ||
name = "self_evaluation_loop_flow" | ||
version = "0.1.0" | ||
description = "self-evalulation-loop-flow using crewAI" | ||
authors = [{ name = "Your Name", email = "you@example.com" }] | ||
requires-python = ">=3.10,<=3.13" | ||
dependencies = [ | ||
"crewai[tools]>=0.76.2,<1.0.0", | ||
] | ||
|
||
[project.scripts] | ||
kickoff = "self_evaluation_loop_flow.main:kickoff" | ||
plot = "self_evaluation_loop_flow.main:plot" | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
10 changes: 10 additions & 0 deletions
10
...ulation_loop_flow/src/self_evaluation_loop_flow/crews/shakespeare_crew/config/agents.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
shakespearean_bard: | ||
role: > | ||
Shakespearean Bard | ||
goal: > | ||
Craft sarcastic and playful hot takes in the style of Shakespeare. | ||
Ensure that all responses fit within 280 characters and contain no emojis. | ||
backstory: > | ||
Thou art a witty bard, renowned for turning the mundane into the | ||
magnificent with thy playful jests and biting sarcasm. Armed with wit and | ||
wisdom, thou dost revel in the creation of humorous quips most pleasing to the ear. |
12 changes: 12 additions & 0 deletions
12
...lulation_loop_flow/src/self_evaluation_loop_flow/crews/shakespeare_crew/config/tasks.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
write_x_post: | ||
description: > | ||
Given the topic '{topic}', compose a humorous hot take in the style of Shakespeare. | ||
The tone should be sarcastic and playful. The final short form social media post | ||
must be over 200 characters and not exceed 280 characters, and emojis are strictly forbidden. | ||
Please incorporate the following feedback if present: | ||
{feedback} | ||
expected_output: > | ||
A witty, Shakespearean hot take between 200 and 280 characters [Inclusive]. | ||
agent: shakespearean_bard | ||
|
34 changes: 34 additions & 0 deletions
34
...lation_loop_flow/src/self_evaluation_loop_flow/crews/shakespeare_crew/shakespeare_crew.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from crewai import Agent, Crew, Process, Task | ||
from crewai.project import CrewBase, agent, crew, task | ||
from self_evaluation_loop_flow.tools.CharacterCounterTool import CharacterCounterTool | ||
|
||
|
||
@CrewBase | ||
class ShakespeareanXPostCrew: | ||
"""Shakespearean X Post Crew""" | ||
|
||
agents_config = "config/agents.yaml" | ||
tasks_config = "config/tasks.yaml" | ||
|
||
@agent | ||
def shakespearean_bard(self) -> Agent: | ||
return Agent( | ||
config=self.agents_config["shakespearean_bard"], | ||
tools=[CharacterCounterTool()], | ||
) | ||
|
||
@task | ||
def write_x_post(self) -> Task: | ||
return Task( | ||
config=self.tasks_config["write_x_post"], | ||
) | ||
|
||
@crew | ||
def crew(self) -> Crew: | ||
"""Creates the Shakespearean X Post Crew""" | ||
return Crew( | ||
agents=self.agents, # Automatically created by the @agent decorator | ||
tasks=self.tasks, # Automatically created by the @task decorator | ||
process=Process.sequential, | ||
verbose=True, | ||
) |
10 changes: 10 additions & 0 deletions
10
...ation_loop_flow/src/self_evaluation_loop_flow/crews/x_post_review_crew/config/agents.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
x_post_verifier: | ||
role: > | ||
X Post Verifier | ||
goal: > | ||
Ensure that any X post meets the strict guidelines: | ||
it must be under 280 characters, contain no emojis, and be free of additional commentary. | ||
backstory: > | ||
You are a careful reviewer, skilled at understanding the core message of a post. | ||
Your job is to maintain the clarity and brevity of the post by ensuring it contains no emojis, | ||
unnecessary commentary, or excessive verbosity. |
30 changes: 30 additions & 0 deletions
30
...lation_loop_flow/src/self_evaluation_loop_flow/crews/x_post_review_crew/config/tasks.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
verify_x_post: | ||
description: > | ||
Verify that the given X post meets the following criteria: | ||
- It is between 200 and 280 characters inclusive. | ||
- It contains no emojis. | ||
- It contains only the post itself, without additional commentary. | ||
The post should follow the 1-3-1 rule: | ||
- 1 bold statement to hook the reader | ||
- 3 lines of supporting information | ||
- 1 sentence to summarize the post | ||
Additionally, if you believe there are any issues with the post | ||
or ways it could be improved, such as the structure of the post, | ||
rhythm, word choice, please provide feedback. | ||
If any of the criteria are not met, the post is considered invalid. | ||
Provide actionable changes about what is wrong and what actions | ||
need to be taken to fix the post. | ||
Your final response must include: | ||
- Valid: True/False | ||
- Feedback: Provide commentary if the post fails any of the criteria. | ||
X Post to Verify: | ||
{x_post} | ||
expected_output: > | ||
Pass: True/False | ||
Feedback: Commentary here if failed. | ||
agent: x_post_verifier |
43 changes: 43 additions & 0 deletions
43
...on_loop_flow/src/self_evaluation_loop_flow/crews/x_post_review_crew/x_post_review_crew.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Optional | ||
|
||
from crewai import Agent, Crew, Process, Task | ||
from crewai.project import CrewBase, agent, crew, task | ||
from pydantic import BaseModel | ||
from self_evaluation_loop_flow.tools.CharacterCounterTool import CharacterCounterTool | ||
|
||
|
||
class XPostVerification(BaseModel): | ||
valid: bool | ||
feedback: Optional[str] | ||
|
||
|
||
@CrewBase | ||
class XPostReviewCrew: | ||
"""X Post Review Crew""" | ||
|
||
agents_config = "config/agents.yaml" | ||
tasks_config = "config/tasks.yaml" | ||
|
||
@agent | ||
def x_post_verifier(self) -> Agent: | ||
return Agent( | ||
config=self.agents_config["x_post_verifier"], | ||
tools=[CharacterCounterTool()], | ||
) | ||
|
||
@task | ||
def verify_x_post(self) -> Task: | ||
return Task( | ||
config=self.tasks_config["verify_x_post"], | ||
output_pydantic=XPostVerification, | ||
) | ||
|
||
@crew | ||
def crew(self) -> Crew: | ||
"""Creates the X Post Review Crew""" | ||
return Crew( | ||
agents=self.agents, | ||
tasks=self.tasks, | ||
process=Process.sequential, | ||
verbose=True, | ||
) |
Oops, something went wrong.