Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .github/workflows/update_space.yml +28 -28
- .gitignore +4 -4
- README.md +60 -60
- app.py +53 -53
- knowledge/user_preference.txt +4 -4
- src/debate/config/agents.yaml +22 -22
- src/debate/config/tasks.yaml +23 -23
- src/debate/crew.py +78 -78
- src/debate/main.py +67 -67
- src/debate/tools/custom_tool.py +19 -19
.github/workflows/update_space.yml
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
name: Run Python script
|
2 |
-
|
3 |
-
on:
|
4 |
-
push:
|
5 |
-
branches:
|
6 |
-
- main
|
7 |
-
|
8 |
-
jobs:
|
9 |
-
build:
|
10 |
-
runs-on: ubuntu-latest
|
11 |
-
|
12 |
-
steps:
|
13 |
-
- name: Checkout
|
14 |
-
uses: actions/checkout@v2
|
15 |
-
|
16 |
-
- name: Set up Python
|
17 |
-
uses: actions/setup-python@v2
|
18 |
-
with:
|
19 |
-
python-version: '3.9'
|
20 |
-
|
21 |
-
- name: Install Gradio
|
22 |
-
run: python -m pip install gradio
|
23 |
-
|
24 |
-
- name: Log in to Hugging Face
|
25 |
-
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
-
|
27 |
-
- name: Deploy to Spaces
|
28 |
-
run: gradio deploy
|
|
|
1 |
+
name: Run Python script
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Set up Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: '3.9'
|
20 |
+
|
21 |
+
- name: Install Gradio
|
22 |
+
run: python -m pip install gradio
|
23 |
+
|
24 |
+
- name: Log in to Hugging Face
|
25 |
+
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
+
|
27 |
+
- name: Deploy to Spaces
|
28 |
+
run: gradio deploy
|
.gitignore
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
.env
|
2 |
-
__pycache__/
|
3 |
-
.DS_Store
|
4 |
-
/output/
|
5 |
.venv/
|
|
|
1 |
+
.env
|
2 |
+
__pycache__/
|
3 |
+
.DS_Store
|
4 |
+
/output/
|
5 |
.venv/
|
README.md
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
---
|
2 |
-
title: debate
|
3 |
-
app_file: app.py
|
4 |
-
sdk: gradio
|
5 |
-
sdk_version: 5.38.0
|
6 |
-
---
|
7 |
-
# Debate Crew
|
8 |
-
|
9 |
-
Welcome to the Debate 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.
|
10 |
-
|
11 |
-
## Installation
|
12 |
-
|
13 |
-
Ensure you have Python >=3.10 <3.14 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.
|
14 |
-
|
15 |
-
First, if you haven't already, install uv:
|
16 |
-
|
17 |
-
```bash
|
18 |
-
pip install uv
|
19 |
-
```
|
20 |
-
|
21 |
-
Next, navigate to your project directory and install the dependencies:
|
22 |
-
|
23 |
-
(Optional) Lock the dependencies and install them by using the CLI command:
|
24 |
-
```bash
|
25 |
-
crewai install
|
26 |
-
```
|
27 |
-
### Customizing
|
28 |
-
|
29 |
-
**Add your `OPENAI_API_KEY` into the `.env` file**
|
30 |
-
|
31 |
-
- Modify `src/debate/config/agents.yaml` to define your agents
|
32 |
-
- Modify `src/debate/config/tasks.yaml` to define your tasks
|
33 |
-
- Modify `src/debate/crew.py` to add your own logic, tools and specific args
|
34 |
-
- Modify `src/debate/main.py` to add custom inputs for your agents and tasks
|
35 |
-
|
36 |
-
## Running the Project
|
37 |
-
|
38 |
-
To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:
|
39 |
-
|
40 |
-
```bash
|
41 |
-
$ crewai run
|
42 |
-
```
|
43 |
-
|
44 |
-
This command initializes the debate Crew, assembling the agents and assigning them tasks as defined in your configuration.
|
45 |
-
|
46 |
-
This example, unmodified, will run the create a `report.md` file with the output of a research on LLMs in the root folder.
|
47 |
-
|
48 |
-
## Understanding Your Crew
|
49 |
-
|
50 |
-
The debate 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.
|
51 |
-
|
52 |
-
## Support
|
53 |
-
|
54 |
-
For support, questions, or feedback regarding the Debate Crew or crewAI.
|
55 |
-
- Visit our [documentation](https://docs.crewai.com)
|
56 |
-
- Reach out to us through our [GitHub repository](https://github.com/joaomdmoura/crewai)
|
57 |
-
- [Join our Discord](https://discord.com/invite/X4JWnZnxPb)
|
58 |
-
- [Chat with our docs](https://chatg.pt/DWjSBZn)
|
59 |
-
|
60 |
-
Let's create wonders together with the power and simplicity of crewAI.
|
|
|
1 |
+
---
|
2 |
+
title: debate
|
3 |
+
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 5.38.0
|
6 |
+
---
|
7 |
+
# Debate Crew
|
8 |
+
|
9 |
+
Welcome to the Debate 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.
|
10 |
+
|
11 |
+
## Installation
|
12 |
+
|
13 |
+
Ensure you have Python >=3.10 <3.14 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.
|
14 |
+
|
15 |
+
First, if you haven't already, install uv:
|
16 |
+
|
17 |
+
```bash
|
18 |
+
pip install uv
|
19 |
+
```
|
20 |
+
|
21 |
+
Next, navigate to your project directory and install the dependencies:
|
22 |
+
|
23 |
+
(Optional) Lock the dependencies and install them by using the CLI command:
|
24 |
+
```bash
|
25 |
+
crewai install
|
26 |
+
```
|
27 |
+
### Customizing
|
28 |
+
|
29 |
+
**Add your `OPENAI_API_KEY` into the `.env` file**
|
30 |
+
|
31 |
+
- Modify `src/debate/config/agents.yaml` to define your agents
|
32 |
+
- Modify `src/debate/config/tasks.yaml` to define your tasks
|
33 |
+
- Modify `src/debate/crew.py` to add your own logic, tools and specific args
|
34 |
+
- Modify `src/debate/main.py` to add custom inputs for your agents and tasks
|
35 |
+
|
36 |
+
## Running the Project
|
37 |
+
|
38 |
+
To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:
|
39 |
+
|
40 |
+
```bash
|
41 |
+
$ crewai run
|
42 |
+
```
|
43 |
+
|
44 |
+
This command initializes the debate Crew, assembling the agents and assigning them tasks as defined in your configuration.
|
45 |
+
|
46 |
+
This example, unmodified, will run the create a `report.md` file with the output of a research on LLMs in the root folder.
|
47 |
+
|
48 |
+
## Understanding Your Crew
|
49 |
+
|
50 |
+
The debate 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.
|
51 |
+
|
52 |
+
## Support
|
53 |
+
|
54 |
+
For support, questions, or feedback regarding the Debate Crew or crewAI.
|
55 |
+
- Visit our [documentation](https://docs.crewai.com)
|
56 |
+
- Reach out to us through our [GitHub repository](https://github.com/joaomdmoura/crewai)
|
57 |
+
- [Join our Discord](https://discord.com/invite/X4JWnZnxPb)
|
58 |
+
- [Chat with our docs](https://chatg.pt/DWjSBZn)
|
59 |
+
|
60 |
+
Let's create wonders together with the power and simplicity of crewAI.
|
app.py
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
from dotenv import load_dotenv
|
2 |
-
import gradio as gr
|
3 |
-
from src.debate.crew import Debate
|
4 |
-
|
5 |
-
PROPOSITION_DEFAULT = "### Arguments in favor\n\n_Arguments in favor will appear here_"
|
6 |
-
OPPOSITION_DEFAULT = "### Arguments against\n\n_Arguments against will appear here_"
|
7 |
-
DECISION_DEFAULT = "### The Judge's Decision\n\n_Decision will appear here_"
|
8 |
-
|
9 |
-
def debate_motion(motion):
|
10 |
-
debate = Debate()
|
11 |
-
crew = debate.crew()
|
12 |
-
inputs = {
|
13 |
-
'motion': motion
|
14 |
-
}
|
15 |
-
results = crew.kickoff(inputs=inputs)
|
16 |
-
print("Results: ", results)
|
17 |
-
proposition = debate.my_proposition_task.output.raw
|
18 |
-
opposition = debate.my_opposition_task.output.raw
|
19 |
-
decision = debate.my_judge_task.output.raw
|
20 |
-
|
21 |
-
yield proposition, opposition, decision
|
22 |
-
|
23 |
-
|
24 |
-
if __name__ == "__main__":
|
25 |
-
load_dotenv(override=True)
|
26 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
27 |
-
motion = gr.Text(
|
28 |
-
label="Motion",
|
29 |
-
value="Being Vegan is better for the environment",
|
30 |
-
submit_btn="Start Debate",
|
31 |
-
)
|
32 |
-
|
33 |
-
with gr.Column():
|
34 |
-
with gr.Row(equal_height=True):
|
35 |
-
proposition = gr.Markdown(
|
36 |
-
value=PROPOSITION_DEFAULT,
|
37 |
-
container=True,
|
38 |
-
)
|
39 |
-
|
40 |
-
opposition = gr.Markdown(
|
41 |
-
value=OPPOSITION_DEFAULT,
|
42 |
-
container=True,
|
43 |
-
)
|
44 |
-
|
45 |
-
decision = gr.Markdown(
|
46 |
-
value=DECISION_DEFAULT,
|
47 |
-
container=True,
|
48 |
-
)
|
49 |
-
|
50 |
-
motion.submit(
|
51 |
-
debate_motion, inputs=[motion], outputs=[proposition, opposition, decision]
|
52 |
-
)
|
53 |
-
demo.launch()
|
|
|
1 |
+
from dotenv import load_dotenv
|
2 |
+
import gradio as gr
|
3 |
+
from src.debate.crew import Debate
|
4 |
+
|
5 |
+
PROPOSITION_DEFAULT = "### Arguments in favor\n\n_Arguments in favor will appear here_"
|
6 |
+
OPPOSITION_DEFAULT = "### Arguments against\n\n_Arguments against will appear here_"
|
7 |
+
DECISION_DEFAULT = "### The Judge's Decision\n\n_Decision will appear here_"
|
8 |
+
|
9 |
+
def debate_motion(motion):
|
10 |
+
debate = Debate()
|
11 |
+
crew = debate.crew()
|
12 |
+
inputs = {
|
13 |
+
'motion': motion
|
14 |
+
}
|
15 |
+
results = crew.kickoff(inputs=inputs)
|
16 |
+
print("Results: ", results)
|
17 |
+
proposition = debate.my_proposition_task.output.raw
|
18 |
+
opposition = debate.my_opposition_task.output.raw
|
19 |
+
decision = debate.my_judge_task.output.raw
|
20 |
+
|
21 |
+
yield proposition, opposition, decision
|
22 |
+
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
load_dotenv(override=True)
|
26 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
27 |
+
motion = gr.Text(
|
28 |
+
label="Motion",
|
29 |
+
value="Being Vegan is better for the environment",
|
30 |
+
submit_btn="Start Debate",
|
31 |
+
)
|
32 |
+
|
33 |
+
with gr.Column():
|
34 |
+
with gr.Row(equal_height=True):
|
35 |
+
proposition = gr.Markdown(
|
36 |
+
value=PROPOSITION_DEFAULT,
|
37 |
+
container=True,
|
38 |
+
)
|
39 |
+
|
40 |
+
opposition = gr.Markdown(
|
41 |
+
value=OPPOSITION_DEFAULT,
|
42 |
+
container=True,
|
43 |
+
)
|
44 |
+
|
45 |
+
decision = gr.Markdown(
|
46 |
+
value=DECISION_DEFAULT,
|
47 |
+
container=True,
|
48 |
+
)
|
49 |
+
|
50 |
+
motion.submit(
|
51 |
+
debate_motion, inputs=[motion], outputs=[proposition, opposition, decision]
|
52 |
+
)
|
53 |
+
demo.launch()
|
knowledge/user_preference.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
User name is John Doe.
|
2 |
-
User is an AI Engineer.
|
3 |
-
User is interested in AI Agents.
|
4 |
-
User is based in San Francisco, California.
|
|
|
1 |
+
User name is John Doe.
|
2 |
+
User is an AI Engineer.
|
3 |
+
User is interested in AI Agents.
|
4 |
+
User is based in San Francisco, California.
|
src/debate/config/agents.yaml
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
debate_agent:
|
2 |
-
role: >
|
3 |
-
Senior Debater
|
4 |
-
goal: >
|
5 |
-
Present a clear argument either in favor of or against the motion. The motion is: {motion}
|
6 |
-
backstory: >
|
7 |
-
You are an expert debater. You are able to debate any motion with a high level of skill. You are able to use evidence to support your arguments and to refute the arguments of your opponent.
|
8 |
-
|
9 |
-
judge_agent:
|
10 |
-
role: >
|
11 |
-
Judge
|
12 |
-
goal: >
|
13 |
-
Judge the debate and decide the winner based on the evidence
|
14 |
-
backstory: >
|
15 |
-
You are a judge. You are able to judge the debate and decide the winner. You are able to use the evidence to support your decision. the motion is: {motion}
|
16 |
-
criteria: >
|
17 |
-
The debate is judged based on the following criteria:
|
18 |
-
- The quality of the arguments
|
19 |
-
- The quality of the evidence
|
20 |
-
- The quality of the rebuttal
|
21 |
-
- The quality of the closing argument
|
22 |
-
|
|
|
1 |
+
debate_agent:
|
2 |
+
role: >
|
3 |
+
Senior Debater
|
4 |
+
goal: >
|
5 |
+
Present a clear argument either in favor of or against the motion. The motion is: {motion}
|
6 |
+
backstory: >
|
7 |
+
You are an expert debater. You are able to debate any motion with a high level of skill. You are able to use evidence to support your arguments and to refute the arguments of your opponent.
|
8 |
+
|
9 |
+
judge_agent:
|
10 |
+
role: >
|
11 |
+
Judge
|
12 |
+
goal: >
|
13 |
+
Judge the debate and decide the winner based on the evidence
|
14 |
+
backstory: >
|
15 |
+
You are a judge. You are able to judge the debate and decide the winner. You are able to use the evidence to support your decision. the motion is: {motion}
|
16 |
+
criteria: >
|
17 |
+
The debate is judged based on the following criteria:
|
18 |
+
- The quality of the arguments
|
19 |
+
- The quality of the evidence
|
20 |
+
- The quality of the rebuttal
|
21 |
+
- The quality of the closing argument
|
22 |
+
|
src/debate/config/tasks.yaml
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
proposition_task:
|
2 |
-
description: >
|
3 |
-
Your job is to argue for the motion: {motion}
|
4 |
-
expected_output: >
|
5 |
-
Present your arguments in a concise manner arguing for the {motion}
|
6 |
-
agent: debate_agent
|
7 |
-
output_key: proposition
|
8 |
-
|
9 |
-
opposition_task:
|
10 |
-
description: >
|
11 |
-
Your job is to argue against the motion: {motion}
|
12 |
-
expected_output: >
|
13 |
-
Present your arguments in a concise manner arguing against the {motion}
|
14 |
-
agent: debate_agent
|
15 |
-
output_key: opposition
|
16 |
-
|
17 |
-
judge_task:
|
18 |
-
description: >
|
19 |
-
Review the arguments for and against the motion: {motion} and decide the winner.
|
20 |
-
expected_output: >
|
21 |
-
Decide the winner of the debate based on the arguments presented
|
22 |
-
agent: judge_agent
|
23 |
-
output_key: decision
|
|
|
1 |
+
proposition_task:
|
2 |
+
description: >
|
3 |
+
Your job is to argue for the motion: {motion}
|
4 |
+
expected_output: >
|
5 |
+
Present your arguments in a concise manner arguing for the {motion}
|
6 |
+
agent: debate_agent
|
7 |
+
output_key: proposition
|
8 |
+
|
9 |
+
opposition_task:
|
10 |
+
description: >
|
11 |
+
Your job is to argue against the motion: {motion}
|
12 |
+
expected_output: >
|
13 |
+
Present your arguments in a concise manner arguing against the {motion}
|
14 |
+
agent: debate_agent
|
15 |
+
output_key: opposition
|
16 |
+
|
17 |
+
judge_task:
|
18 |
+
description: >
|
19 |
+
Review the arguments for and against the motion: {motion} and decide the winner.
|
20 |
+
expected_output: >
|
21 |
+
Decide the winner of the debate based on the arguments presented
|
22 |
+
agent: judge_agent
|
23 |
+
output_key: decision
|
src/debate/crew.py
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
from crewai import Agent, Crew, Process, Task
|
2 |
-
from crewai.project import CrewBase, agent, crew, task
|
3 |
-
from crewai.agents.agent_builder.base_agent import BaseAgent
|
4 |
-
from typing import List
|
5 |
-
|
6 |
-
# If you want to run a snippet of code before or after the crew starts,
|
7 |
-
# you can use the @before_kickoff and @after_kickoff decorators
|
8 |
-
# https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators
|
9 |
-
|
10 |
-
|
11 |
-
@CrewBase
|
12 |
-
class Debate:
|
13 |
-
"""Debate crew"""
|
14 |
-
|
15 |
-
agents: List[BaseAgent]
|
16 |
-
tasks: List[Task]
|
17 |
-
|
18 |
-
# Learn more about YAML configuration files here:
|
19 |
-
# Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
|
20 |
-
# Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended
|
21 |
-
|
22 |
-
# If you would like to add tools to your agents, you can learn more about it here:
|
23 |
-
# https://docs.crewai.com/concepts/agents#agent-tools
|
24 |
-
@agent
|
25 |
-
def debate_agent(self) -> Agent:
|
26 |
-
return Agent(
|
27 |
-
config=self.agents_config["debate_agent"], # type: ignore[index]
|
28 |
-
verbose=True,
|
29 |
-
)
|
30 |
-
|
31 |
-
@agent
|
32 |
-
def judge_agent(self) -> Agent:
|
33 |
-
return Agent(
|
34 |
-
config=self.agents_config["judge_agent"], # type: ignore[index]
|
35 |
-
verbose=True,
|
36 |
-
)
|
37 |
-
|
38 |
-
@task
|
39 |
-
def proposition_task(self) -> Task:
|
40 |
-
self.my_proposition_task = Task(
|
41 |
-
config=self.tasks_config["proposition_task"], # type: ignore[index]
|
42 |
-
output_key="proposition",
|
43 |
-
markdown=True
|
44 |
-
)
|
45 |
-
return self.my_proposition_task
|
46 |
-
|
47 |
-
@task
|
48 |
-
def opposition_task(self) -> Task:
|
49 |
-
self.my_opposition_task = Task(
|
50 |
-
config=self.tasks_config["opposition_task"], # type: ignore[index]
|
51 |
-
output_key="opposition",
|
52 |
-
markdown=True
|
53 |
-
)
|
54 |
-
return self.my_opposition_task
|
55 |
-
|
56 |
-
@task
|
57 |
-
def judge_task(self) -> Task:
|
58 |
-
self.my_judge_task = Task(
|
59 |
-
config=self.tasks_config["judge_task"], # type: ignore[index]
|
60 |
-
output_file="output/decision.md",
|
61 |
-
output_key="decision",
|
62 |
-
markdown=True
|
63 |
-
)
|
64 |
-
return self.my_judge_task
|
65 |
-
|
66 |
-
@crew
|
67 |
-
def crew(self) -> Crew:
|
68 |
-
"""Creates the Debate crew"""
|
69 |
-
# To learn how to add knowledge sources to your crew, check out the documentation:
|
70 |
-
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge
|
71 |
-
|
72 |
-
return Crew(
|
73 |
-
agents=self.agents, # Automatically created by the @agent decorator
|
74 |
-
tasks=self.tasks, # Automatically created by the @task decorator
|
75 |
-
process=Process.sequential,
|
76 |
-
verbose=True,
|
77 |
-
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
|
78 |
-
)
|
|
|
1 |
+
from crewai import Agent, Crew, Process, Task
|
2 |
+
from crewai.project import CrewBase, agent, crew, task
|
3 |
+
from crewai.agents.agent_builder.base_agent import BaseAgent
|
4 |
+
from typing import List
|
5 |
+
|
6 |
+
# If you want to run a snippet of code before or after the crew starts,
|
7 |
+
# you can use the @before_kickoff and @after_kickoff decorators
|
8 |
+
# https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators
|
9 |
+
|
10 |
+
|
11 |
+
@CrewBase
|
12 |
+
class Debate:
|
13 |
+
"""Debate crew"""
|
14 |
+
|
15 |
+
agents: List[BaseAgent]
|
16 |
+
tasks: List[Task]
|
17 |
+
|
18 |
+
# Learn more about YAML configuration files here:
|
19 |
+
# Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
|
20 |
+
# Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended
|
21 |
+
|
22 |
+
# If you would like to add tools to your agents, you can learn more about it here:
|
23 |
+
# https://docs.crewai.com/concepts/agents#agent-tools
|
24 |
+
@agent
|
25 |
+
def debate_agent(self) -> Agent:
|
26 |
+
return Agent(
|
27 |
+
config=self.agents_config["debate_agent"], # type: ignore[index]
|
28 |
+
verbose=True,
|
29 |
+
)
|
30 |
+
|
31 |
+
@agent
|
32 |
+
def judge_agent(self) -> Agent:
|
33 |
+
return Agent(
|
34 |
+
config=self.agents_config["judge_agent"], # type: ignore[index]
|
35 |
+
verbose=True,
|
36 |
+
)
|
37 |
+
|
38 |
+
@task
|
39 |
+
def proposition_task(self) -> Task:
|
40 |
+
self.my_proposition_task = Task(
|
41 |
+
config=self.tasks_config["proposition_task"], # type: ignore[index]
|
42 |
+
output_key="proposition",
|
43 |
+
markdown=True
|
44 |
+
)
|
45 |
+
return self.my_proposition_task
|
46 |
+
|
47 |
+
@task
|
48 |
+
def opposition_task(self) -> Task:
|
49 |
+
self.my_opposition_task = Task(
|
50 |
+
config=self.tasks_config["opposition_task"], # type: ignore[index]
|
51 |
+
output_key="opposition",
|
52 |
+
markdown=True
|
53 |
+
)
|
54 |
+
return self.my_opposition_task
|
55 |
+
|
56 |
+
@task
|
57 |
+
def judge_task(self) -> Task:
|
58 |
+
self.my_judge_task = Task(
|
59 |
+
config=self.tasks_config["judge_task"], # type: ignore[index]
|
60 |
+
output_file="output/decision.md",
|
61 |
+
output_key="decision",
|
62 |
+
markdown=True
|
63 |
+
)
|
64 |
+
return self.my_judge_task
|
65 |
+
|
66 |
+
@crew
|
67 |
+
def crew(self) -> Crew:
|
68 |
+
"""Creates the Debate crew"""
|
69 |
+
# To learn how to add knowledge sources to your crew, check out the documentation:
|
70 |
+
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge
|
71 |
+
|
72 |
+
return Crew(
|
73 |
+
agents=self.agents, # Automatically created by the @agent decorator
|
74 |
+
tasks=self.tasks, # Automatically created by the @task decorator
|
75 |
+
process=Process.sequential,
|
76 |
+
verbose=True,
|
77 |
+
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
|
78 |
+
)
|
src/debate/main.py
CHANGED
@@ -1,67 +1,67 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
import sys
|
3 |
-
import warnings
|
4 |
-
|
5 |
-
from datetime import datetime
|
6 |
-
|
7 |
-
from debate.crew import Debate
|
8 |
-
|
9 |
-
warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")
|
10 |
-
|
11 |
-
# This main file is intended to be a way for you to run your
|
12 |
-
# crew locally, so refrain from adding unnecessary logic into this file.
|
13 |
-
# Replace with inputs you want to test with, it will automatically
|
14 |
-
# interpolate any tasks and agents information
|
15 |
-
|
16 |
-
def run():
|
17 |
-
"""
|
18 |
-
Run the crew.
|
19 |
-
"""
|
20 |
-
inputs = {
|
21 |
-
'motion': 'Being Vegan is better for the environment'
|
22 |
-
}
|
23 |
-
|
24 |
-
try:
|
25 |
-
Debate().crew().kickoff(inputs=inputs)
|
26 |
-
except Exception as e:
|
27 |
-
raise Exception(f"An error occurred while running the crew: {e}")
|
28 |
-
|
29 |
-
|
30 |
-
def train():
|
31 |
-
"""
|
32 |
-
Train the crew for a given number of iterations.
|
33 |
-
"""
|
34 |
-
inputs = {
|
35 |
-
"topic": "AI LLMs",
|
36 |
-
'current_year': str(datetime.now().year)
|
37 |
-
}
|
38 |
-
try:
|
39 |
-
Debate().crew().train(n_iterations=int(sys.argv[1]), filename=sys.argv[2], inputs=inputs)
|
40 |
-
|
41 |
-
except Exception as e:
|
42 |
-
raise Exception(f"An error occurred while training the crew: {e}")
|
43 |
-
|
44 |
-
def replay():
|
45 |
-
"""
|
46 |
-
Replay the crew execution from a specific task.
|
47 |
-
"""
|
48 |
-
try:
|
49 |
-
Debate().crew().replay(task_id=sys.argv[1])
|
50 |
-
|
51 |
-
except Exception as e:
|
52 |
-
raise Exception(f"An error occurred while replaying the crew: {e}")
|
53 |
-
|
54 |
-
def test():
|
55 |
-
"""
|
56 |
-
Test the crew execution and returns the results.
|
57 |
-
"""
|
58 |
-
inputs = {
|
59 |
-
"topic": "AI LLMs",
|
60 |
-
"current_year": str(datetime.now().year)
|
61 |
-
}
|
62 |
-
|
63 |
-
try:
|
64 |
-
Debate().crew().test(n_iterations=int(sys.argv[1]), eval_llm=sys.argv[2], inputs=inputs)
|
65 |
-
|
66 |
-
except Exception as e:
|
67 |
-
raise Exception(f"An error occurred while testing the crew: {e}")
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
import sys
|
3 |
+
import warnings
|
4 |
+
|
5 |
+
from datetime import datetime
|
6 |
+
|
7 |
+
from debate.crew import Debate
|
8 |
+
|
9 |
+
warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")
|
10 |
+
|
11 |
+
# This main file is intended to be a way for you to run your
|
12 |
+
# crew locally, so refrain from adding unnecessary logic into this file.
|
13 |
+
# Replace with inputs you want to test with, it will automatically
|
14 |
+
# interpolate any tasks and agents information
|
15 |
+
|
16 |
+
def run():
|
17 |
+
"""
|
18 |
+
Run the crew.
|
19 |
+
"""
|
20 |
+
inputs = {
|
21 |
+
'motion': 'Being Vegan is better for the environment'
|
22 |
+
}
|
23 |
+
|
24 |
+
try:
|
25 |
+
Debate().crew().kickoff(inputs=inputs)
|
26 |
+
except Exception as e:
|
27 |
+
raise Exception(f"An error occurred while running the crew: {e}")
|
28 |
+
|
29 |
+
|
30 |
+
def train():
|
31 |
+
"""
|
32 |
+
Train the crew for a given number of iterations.
|
33 |
+
"""
|
34 |
+
inputs = {
|
35 |
+
"topic": "AI LLMs",
|
36 |
+
'current_year': str(datetime.now().year)
|
37 |
+
}
|
38 |
+
try:
|
39 |
+
Debate().crew().train(n_iterations=int(sys.argv[1]), filename=sys.argv[2], inputs=inputs)
|
40 |
+
|
41 |
+
except Exception as e:
|
42 |
+
raise Exception(f"An error occurred while training the crew: {e}")
|
43 |
+
|
44 |
+
def replay():
|
45 |
+
"""
|
46 |
+
Replay the crew execution from a specific task.
|
47 |
+
"""
|
48 |
+
try:
|
49 |
+
Debate().crew().replay(task_id=sys.argv[1])
|
50 |
+
|
51 |
+
except Exception as e:
|
52 |
+
raise Exception(f"An error occurred while replaying the crew: {e}")
|
53 |
+
|
54 |
+
def test():
|
55 |
+
"""
|
56 |
+
Test the crew execution and returns the results.
|
57 |
+
"""
|
58 |
+
inputs = {
|
59 |
+
"topic": "AI LLMs",
|
60 |
+
"current_year": str(datetime.now().year)
|
61 |
+
}
|
62 |
+
|
63 |
+
try:
|
64 |
+
Debate().crew().test(n_iterations=int(sys.argv[1]), eval_llm=sys.argv[2], inputs=inputs)
|
65 |
+
|
66 |
+
except Exception as e:
|
67 |
+
raise Exception(f"An error occurred while testing the crew: {e}")
|
src/debate/tools/custom_tool.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
from crewai.tools import BaseTool
|
2 |
-
from typing import Type
|
3 |
-
from pydantic import BaseModel, Field
|
4 |
-
|
5 |
-
|
6 |
-
class MyCustomToolInput(BaseModel):
|
7 |
-
"""Input schema for MyCustomTool."""
|
8 |
-
argument: str = Field(..., description="Description of the argument.")
|
9 |
-
|
10 |
-
class MyCustomTool(BaseTool):
|
11 |
-
name: str = "Name of my tool"
|
12 |
-
description: str = (
|
13 |
-
"Clear description for what this tool is useful for, your agent will need this information to use it."
|
14 |
-
)
|
15 |
-
args_schema: Type[BaseModel] = MyCustomToolInput
|
16 |
-
|
17 |
-
def _run(self, argument: str) -> str:
|
18 |
-
# Implementation goes here
|
19 |
-
return "this is an example of a tool output, ignore it and move along."
|
|
|
1 |
+
from crewai.tools import BaseTool
|
2 |
+
from typing import Type
|
3 |
+
from pydantic import BaseModel, Field
|
4 |
+
|
5 |
+
|
6 |
+
class MyCustomToolInput(BaseModel):
|
7 |
+
"""Input schema for MyCustomTool."""
|
8 |
+
argument: str = Field(..., description="Description of the argument.")
|
9 |
+
|
10 |
+
class MyCustomTool(BaseTool):
|
11 |
+
name: str = "Name of my tool"
|
12 |
+
description: str = (
|
13 |
+
"Clear description for what this tool is useful for, your agent will need this information to use it."
|
14 |
+
)
|
15 |
+
args_schema: Type[BaseModel] = MyCustomToolInput
|
16 |
+
|
17 |
+
def _run(self, argument: str) -> str:
|
18 |
+
# Implementation goes here
|
19 |
+
return "this is an example of a tool output, ignore it and move along."
|