FaiazAI commited on
Commit
1aa5be2
·
verified ·
1 Parent(s): 66093cb

Upload 15 files

Browse files
debate_contest/__init__.py ADDED
File without changes
debate_contest/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (222 Bytes). View file
 
debate_contest/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (212 Bytes). View file
 
debate_contest/__pycache__/crew.cpython-311.pyc ADDED
Binary file (3.16 kB). View file
 
debate_contest/__pycache__/crew.cpython-312.pyc ADDED
Binary file (2.35 kB). View file
 
debate_contest/__pycache__/main.cpython-311.pyc ADDED
Binary file (559 Bytes). View file
 
debate_contest/__pycache__/main.cpython-312.pyc ADDED
Binary file (3.17 kB). View file
 
debate_contest/config/agents.yaml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ debator_contestant1:
2
+
3
+ role: >
4
+ A compelling debating contestant.
5
+
6
+ goal: >
7
+
8
+ Present a clear argument either in favour or against the motion. The motion is {motion}.
9
+
10
+ backstory: >
11
+
12
+ You are an experienced debator who has a knack in giving concise yet convincing arguments.
13
+
14
+ The motion is {motion}.
15
+
16
+ model: groq/llama-3.1-70b-versatile
17
+
18
+
19
+ debator_contestant2:
20
+
21
+ role: >
22
+ A compelling debating contestant.
23
+
24
+ goal: >
25
+
26
+ Present a clear argument either in favour or against the motion. The motion is {motion}.
27
+
28
+ backstory: >
29
+
30
+ You are an experienced debator who has a knack in giving concise yet convincing arguments.
31
+
32
+ The motion is {motion}.
33
+
34
+ model: gemini-2.0-flash
35
+
36
+ judge:
37
+
38
+ role: >
39
+ The one who decides the winner of the debate based on the arguments delivered.
40
+
41
+ goal: >
42
+
43
+ Given arguments for and against this motion : {motion},
44
+
45
+ decide which side is more appealing and convincing, only purely based on the arguments delivered.
46
+
47
+ backstory: >
48
+ You are a very honest and fair judge who has a reputation for reviewing
49
+
50
+ arguements without bringing in your own personal views on them, thus making decisions
51
+
52
+ solely based on the merits and pros of the arguments.
53
+
54
+ The motion is: {motion}.
55
+
56
+ model: openai/gpt-4o
debate_contest/config/tasks.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ propose_motion:
2
+
3
+ description: >
4
+ You are proposing the motion: {motion}.
5
+ Come up with an argument in favour of the motion.
6
+ Be as convincing as possible.
7
+
8
+ expected_output: >
9
+ Your clear arguments in favour of the motion, in a very bold and concise manner.
10
+
11
+ agent: debator_contestant1
12
+
13
+ output_file: output/motion_proposal.md
14
+
15
+
16
+ oppose_motion:
17
+
18
+ description: >
19
+ You are opposing the motion: {motion}.
20
+ Come up with an argument against the motion.
21
+ Be as convincing as possible.
22
+
23
+ expected_output: >
24
+ Your clear arguments against the motion, in a very bold and concise manner.
25
+
26
+ agent: debator_contestant2
27
+
28
+ output_file: output/motion_opposal.md
29
+
30
+ review:
31
+
32
+ description: >
33
+
34
+ Review the arguments delivered by the debators, and conculde which side is more convincing and justifying.
35
+
36
+ expected_output: >
37
+
38
+ You decide which side is more convincing, and why.
39
+
40
+ agent: judge
41
+
42
+ output_file: output/motion_review.md
debate_contest/crew.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent, Crew, Process, Task
2
+
3
+ from crewai.project import CrewBase, agent, crew, task
4
+
5
+ from crewai.agents.agent_builder.base_agent import BaseAgent
6
+
7
+ from typing import List
8
+
9
+ @CrewBase
10
+ class DebateContest():
11
+ """DebateContest crew"""
12
+
13
+ agents_config = 'config/agents.yaml'
14
+
15
+ tasks_config = 'config/tasks.yaml'
16
+
17
+
18
+ @agent
19
+ def debator_contestant1(self) -> Agent:
20
+ return Agent(
21
+
22
+ config = self.agents_config['debator_contestant1'],
23
+
24
+ verbose = True
25
+ )
26
+
27
+ @agent
28
+ def debator_contestant2(self)-> Agent:
29
+
30
+ return Agent(
31
+
32
+ config = self.agents_config['debator_contestant2'],
33
+
34
+ verbose = True
35
+
36
+ )
37
+
38
+ @agent
39
+ def judge(self) -> Agent:
40
+
41
+ return Agent(
42
+
43
+ config = self.agents_config['judge'],
44
+
45
+ verbose = True
46
+ )
47
+
48
+
49
+ @task
50
+ def propose_motion(self) -> Task:
51
+
52
+ return Task(
53
+
54
+ config = self.tasks_config['propose_motion']
55
+
56
+ )
57
+
58
+ @task
59
+ def oppose_motion(self) -> Task:
60
+
61
+ return Task(
62
+
63
+ config = self.tasks_config['oppose_motion']
64
+
65
+ )
66
+
67
+
68
+ @task
69
+ def review(self) -> Task:
70
+
71
+ return Task(
72
+
73
+ config = self.tasks_config['review']
74
+
75
+ )
76
+
77
+ @crew
78
+ def crew(self) -> Crew:
79
+
80
+ """Creates the DebateContest crew"""
81
+
82
+ return Crew(
83
+
84
+ agents=self.agents,
85
+
86
+ tasks=self.tasks,
87
+
88
+ process=Process.sequential,
89
+
90
+ verbose=True,
91
+
92
+ )
debate_contest/debate_user_interface/__pycache__/gradio_ui.cpython-311.pyc ADDED
Binary file (4.55 kB). View file
 
debate_contest/debate_user_interface/favicon_img.png ADDED
debate_contest/debate_user_interface/gradio_ui.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from fpdf import FPDF
4
+
5
+ import os
6
+
7
+ from datetime import datetime
8
+
9
+ from debate_contest.crew import DebateContest
10
+
11
+ def execute_debate(motion):
12
+
13
+ debate_inputs = {
14
+
15
+ 'motion' : motion
16
+ }
17
+
18
+ try:
19
+
20
+ result = DebateContest().crew().kickoff(inputs = debate_inputs)
21
+
22
+ if hasattr(result, 'raw'):
23
+
24
+ output_data = result.raw
25
+
26
+ elif hasattr(result, 'output'):
27
+
28
+ output_data = result.output
29
+
30
+ else:
31
+
32
+ output_data = str(result)
33
+
34
+ for_verdict = f"Pro side argument for: {motion}\n\n{output_data}"
35
+
36
+ against_verdict = f"Con side argument for: {motion}\n\n{output_data}"
37
+
38
+ final_judge_verdict = f"Judge's verdict for: {motion}\n\n{output_data}"
39
+
40
+ full_debate_transcript = (
41
+
42
+ f"AI Debate Transcript\n\n"
43
+
44
+ f"Motion\n{motion}\n\n"
45
+
46
+ f"Pro side\n{for_verdict}\n\n"
47
+
48
+ f"Con side\n{against_verdict}\n\n"
49
+
50
+ f"Judge's final verdict\n{final_judge_verdict}"
51
+
52
+ )
53
+
54
+ debate_transcript_pdf_filename = f"DebateTranscript_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
55
+
56
+ pdf_path = os.path.join('output', debate_transcript_pdf_filename)
57
+
58
+ os.makedirs('output', exist_ok=True)
59
+
60
+ generate_debate_transcript_pdf = FPDF()
61
+
62
+ generate_debate_transcript_pdf.add_page()
63
+
64
+ generate_debate_transcript_pdf.set_auto_page_break(auto = True, margin = 15)
65
+
66
+ generate_debate_transcript_pdf.set_font("Arial", size = 12)
67
+
68
+ for line in full_debate_transcript.split('\n'):
69
+
70
+ generate_debate_transcript_pdf.multi_cell(0, 10, line)
71
+
72
+ generate_debate_transcript_pdf.output(pdf_path)
73
+
74
+ return (
75
+
76
+ f"🎙️ For verdict\n{for_verdict}",
77
+
78
+ f"🎙️ Against verdict\n{against_verdict}",
79
+
80
+ f"🧑‍⚖️ Judge's final verdict\n{final_judge_verdict}",
81
+
82
+ pdf_path
83
+ )
84
+
85
+ except Exception as exception:
86
+
87
+ error_msg = f"Error: {exception}"
88
+
89
+ return (error_msg, error_msg, error_msg, None)
90
+
91
+ def launch_gradio_app():
92
+
93
+ favicon_path = "debate_user_interface/favicon_img.png"
94
+
95
+ with gr.Blocks(title = "AI Debating Engine", theme=gr.themes.Soft(primary_hue="slate", neutral_hue="slate")) as ui_demo:
96
+
97
+ gr.Markdown("🧠 AI Debate Battle Arena")
98
+
99
+ motion_input = gr.Textbox(
100
+
101
+ label = "Enter any motion topic and let the AI titans decode it out!",
102
+
103
+ placeholder = "e.g., Should AI be the next World wide web?",
104
+
105
+ lines = 2
106
+
107
+ )
108
+
109
+ submit_button = gr.Button("🔥Begin🔥!")
110
+
111
+ for_output = gr.Markdown()
112
+
113
+ against_output = gr.Markdown()
114
+
115
+ verdict_output = gr.Markdown()
116
+
117
+ debate_transcript_pdf_file = gr.File(
118
+
119
+ label = "📄 Download Debate Transcript",
120
+
121
+ interactive = True
122
+
123
+ )
124
+
125
+ submit_button.click(
126
+
127
+ fn = execute_debate,
128
+
129
+ inputs = [motion_input],
130
+
131
+ outputs = [for_output, against_output, verdict_output, debate_transcript_pdf_file]
132
+
133
+ )
134
+
135
+ ui_demo.launch()
136
+
137
+
debate_contest/tools/__init__.py ADDED
File without changes
debate_contest/tools/custom_tool.py ADDED
@@ -0,0 +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."