Sameercodes commited on
Commit
a59e2c4
Β·
verified Β·
1 Parent(s): 2ba71b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -85
app.py CHANGED
@@ -8,104 +8,79 @@ warnings.filterwarnings("ignore")
8
  arena = Parse_Prompt()
9
  score = Score()
10
 
11
- with gr.Blocks(fill_height = True) as app:
12
  with gr.Tab("πŸͺ– Battle Field"):
13
  gr.Markdown('''## βš”οΈ LLM: Large Language Mayhem
14
- - Voting should be fair and based on the performance of the models.
15
- - No cheating or manipulating the outcomes.
16
- - Press 🎲 Random to change the models.
17
- - Everything else except the Random button will only clear the screen, model being the same.
18
- - Have fun and enjoy the language mayhem!
19
- - Warrior names will be visible after your first query (after random also you will have to give a query to see changes)
20
- - Don't See Warrior names before voting
21
- ''')
 
22
  with gr.Row():
23
- with gr.Accordion("πŸ₯· Warriors", open = False):
24
- gr.Dataframe([[model] for model in arena.models], col_count = 1, headers = ["πŸ₯·"])
 
25
  with gr.Group():
26
  with gr.Row():
27
  with gr.Column():
28
- chatbox1 = gr.Chatbot(label = "Warrior A", show_copy_button = True)
29
  with gr.Column():
30
- chatbox2 = gr.Chatbot(label = "Warrior B", show_copy_button = True)
31
- textbox = gr.Textbox(show_label = False, placeholder = "πŸ‘‰ Enter your prompt")
 
 
32
  with gr.Row():
33
- with gr.Accordion("πŸ₯· Current Warriors",open = False):
34
  with gr.Row():
35
- war1= gr.Textbox(arena.model1, interactive= False, show_label=False)
36
- war2 = gr.Textbox(arena.model2, interactive= False, show_label= False)
 
37
  with gr.Row():
38
- with gr.Accordion("πŸ‘† Vote", open = False):
39
  with gr.Row():
40
- vote_a = gr.ClearButton([textbox, chatbox1, chatbox2], value = "πŸ‘ˆ Warrior A Wins")
41
- vote_b = gr.ClearButton([textbox, chatbox1, chatbox2], value = "πŸ‘‰ Warrior B Wins")
42
- vote_tie = gr.ClearButton([textbox, chatbox1, chatbox2], value = "🀝 Both Won")
43
 
44
  submit_button = gr.Button("Submit")
 
45
  with gr.Row():
46
- new_round = gr.ClearButton( [textbox, chatbox1, chatbox2], value = "🎲New Round🎲")
47
- clear = gr.ClearButton([textbox, chatbox1, chatbox2], value = "🧹 Clear")
 
48
  with gr.Row():
49
- with gr.Accordion("πŸ”© Parameters", open = False):
50
- temp_slider = gr.Slider(0,1,value = 0.7, step=0.1, label = "Temprature")
51
-
52
- textbox.submit(
53
- fn = arena.gen_output,
54
- inputs = [temp_slider, textbox],
55
- outputs = [chatbox1, chatbox2]
56
- )
57
- textbox.submit(
58
- fn = arena.current_model2,
59
- outputs = war2
60
- )
61
- textbox.submit(
62
- fn = arena.current_model1,
63
- outputs = war1
64
- )
65
- submit_button.click(
66
- fn = arena.gen_output,
67
- inputs = [temp_slider, textbox],
68
- outputs = [chatbox1, chatbox2]
69
- )
70
- submit_button.click(
71
- fn = arena.current_model1,
72
- outputs = war1
73
- )
74
- submit_button.click(
75
- fn = arena.current_model2,
76
- outputs = war2
77
- )
78
- vote_a.click(
79
- fn=lambda: score.update(arena.model1, score.df)
80
- )
81
- vote_b.click(
82
- fn = lambda: score.update(arena.model2, score.df)
83
- )
84
- vote_tie.click(
85
- fn = arena.change_models
86
- )
87
- new_round.click(
88
- fn = arena.change_models
89
- )
90
- clear.click(
91
- fn = arena.clear_history
92
- )
93
-
94
- with gr.Tab("πŸ’― Score Board") as data_tab:
95
  gr.Markdown('''## βš”οΈ LLM: Large Language Mayhem
96
- - Voting should be fair and based on the performance of the models.
97
- - No cheating or manipulating the outcomes.
98
- - Click on Generate button to Update the πŸ’― Scoreboard.
99
- ''')
100
- gr.Interface(
101
- fn = score.df_show,
102
- inputs = None,
103
- outputs=gr.Dataframe(type="pandas", label="Scoreboard", headers = ["","",""]),
104
- live = True,
105
- allow_flagging = "never",
106
- clear_btn = None
107
-
108
- )
109
-
110
-
111
- app.launch()
 
8
  arena = Parse_Prompt()
9
  score = Score()
10
 
11
+ with gr.Blocks(fill_height=True) as app:
12
  with gr.Tab("πŸͺ– Battle Field"):
13
  gr.Markdown('''## βš”οΈ LLM: Large Language Mayhem
14
+ - Voting should be fair and based on the performance of the models.
15
+ - No cheating or manipulating the outcomes.
16
+ - Press 🎲 Random to change the models.
17
+ - Everything else except the Random button will only clear the screen, model being the same.
18
+ - Have fun and enjoy the language mayhem!
19
+ - Warrior names will be visible after your first query (after random also you will have to give a query to see changes)
20
+ - Don't See Warrior names before voting
21
+ ''')
22
+
23
  with gr.Row():
24
+ with gr.Accordion("πŸ₯· Warriors", open=False):
25
+ gr.Dataframe([[model] for model in arena.models], col_count=1, headers=["πŸ₯·"])
26
+
27
  with gr.Group():
28
  with gr.Row():
29
  with gr.Column():
30
+ chatbox1 = gr.Chatbot(label="Warrior A", show_copy_button=True)
31
  with gr.Column():
32
+ chatbox2 = gr.Chatbot(label="Warrior B", show_copy_button=True)
33
+
34
+ textbox = gr.Textbox(show_label=False, placeholder="πŸ‘‰ Enter your prompt")
35
+
36
  with gr.Row():
37
+ with gr.Accordion("πŸ₯· Current Warriors", open=False):
38
  with gr.Row():
39
+ war1 = gr.Textbox(arena.model1, interactive=False, show_label=False)
40
+ war2 = gr.Textbox(arena.model2, interactive=False, show_label=False)
41
+
42
  with gr.Row():
43
+ with gr.Accordion("πŸ‘† Vote", open=False):
44
  with gr.Row():
45
+ vote_a = gr.ClearButton([textbox, chatbox1, chatbox2], value="πŸ‘ˆ Warrior A Wins")
46
+ vote_b = gr.ClearButton([textbox, chatbox1, chatbox2], value="πŸ‘‰ Warrior B Wins")
47
+ vote_tie = gr.ClearButton([textbox, chatbox1, chatbox2], value="🀝 Both Won")
48
 
49
  submit_button = gr.Button("Submit")
50
+
51
  with gr.Row():
52
+ new_round = gr.ClearButton([textbox, chatbox1, chatbox2], value="🎲New Round🎲")
53
+ clear = gr.ClearButton([textbox, chatbox1, chatbox2], value="🧹 Clear")
54
+
55
  with gr.Row():
56
+ with gr.Accordion("πŸ”© Parameters", open=False):
57
+ temp_slider = gr.Slider(0, 1, value=0.7, step=0.1, label="Temperature")
58
+
59
+ # Event bindings
60
+ textbox.submit(fn=arena.gen_output, inputs=[temp_slider, textbox], outputs=[chatbox1, chatbox2])
61
+ textbox.submit(fn=arena.current_model1, outputs=war1)
62
+ textbox.submit(fn=arena.current_model2, outputs=war2)
63
+
64
+ submit_button.click(fn=arena.gen_output, inputs=[temp_slider, textbox], outputs=[chatbox1, chatbox2])
65
+ submit_button.click(fn=arena.current_model1, outputs=war1)
66
+ submit_button.click(fn=arena.current_model2, outputs=war2)
67
+
68
+ vote_a.click(fn=lambda: score.update(arena.model1, score.df))
69
+ vote_b.click(fn=lambda: score.update(arena.model2, score.df))
70
+ vote_tie.click(fn=arena.change_models)
71
+
72
+ new_round.click(fn=arena.change_models)
73
+ clear.click(fn=arena.clear_history)
74
+
75
+ with gr.Tab("πŸ’― Score Board"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  gr.Markdown('''## βš”οΈ LLM: Large Language Mayhem
77
+ - Voting should be fair and based on the performance of the models.
78
+ - No cheating or manipulating the outcomes.
79
+ - Click on Generate button to Update the πŸ’― Scoreboard.
80
+ ''')
81
+ scoreboard = gr.Dataframe(type="pandas", label="Scoreboard", headers=["", "", ""])
82
+ generate_button = gr.Button("Generate")
83
+ generate_button.click(fn=score.df_show, outputs=scoreboard)
84
+
85
+ # Launch the app with sharing enabled
86
+ app.launch(share=True)