File size: 1,685 Bytes
a0126dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a5dbae
a0126dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from dotenv import load_dotenv
import gradio as gr
from src.debate.crew import Debate

PROPOSITION_DEFAULT = "### Arguments in favor\n\n_Arguments in favor will appear here_"
OPPOSITION_DEFAULT = "### Arguments against\n\n_Arguments against will appear here_"
DECISION_DEFAULT = "### The Judge's Decision\n\n_Decision will appear here_"

def debate_motion(motion):
    debate = Debate()
    crew = debate.crew()
    inputs = {
        'motion': motion
    }
    results = crew.kickoff(inputs=inputs)
    print("Results: ", results)
    proposition = debate.my_proposition_task.output.raw
    opposition = debate.my_opposition_task.output.raw
    decision = debate.my_judge_task.output.raw

    yield proposition, opposition, decision


if __name__ == "__main__":
    load_dotenv(override=True)
    with gr.Blocks(theme=gr.themes.Soft()) as demo:
        motion = gr.Text(
            label="Motion",
            value="Being Vegan is better for the environment",
            submit_btn="Start Debate",
            placeholder="Enter a motion to debate",
        )

        with gr.Column():
            with gr.Row(equal_height=True):
                proposition = gr.Markdown(
                    value=PROPOSITION_DEFAULT,
                    container=True,
                )

                opposition = gr.Markdown(
                    value=OPPOSITION_DEFAULT,
                    container=True,
                )

            decision = gr.Markdown(
                value=DECISION_DEFAULT,
                container=True,
            )

        motion.submit(
            debate_motion, inputs=[motion], outputs=[proposition, opposition, decision]
        )
    demo.launch()