Spaces:
Sleeping
Sleeping
File size: 3,802 Bytes
2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 2ba71b5 a59e2c4 |
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import gradio as gr
from prompt_parser import Parse_Prompt
from scoreboard import Score
import warnings
warnings.filterwarnings("ignore")
arena = Parse_Prompt()
score = Score()
with gr.Blocks(fill_height=True) as app:
with gr.Tab("πͺ Battle Field"):
gr.Markdown('''## βοΈ LLM: Large Language Mayhem
- Voting should be fair and based on the performance of the models.
- No cheating or manipulating the outcomes.
- Press π² Random to change the models.
- Everything else except the Random button will only clear the screen, model being the same.
- Have fun and enjoy the language mayhem!
- Warrior names will be visible after your first query (after random also you will have to give a query to see changes)
- Don't See Warrior names before voting
''')
with gr.Row():
with gr.Accordion("π₯· Warriors", open=False):
gr.Dataframe([[model] for model in arena.models], col_count=1, headers=["π₯·"])
with gr.Group():
with gr.Row():
with gr.Column():
chatbox1 = gr.Chatbot(label="Warrior A", show_copy_button=True)
with gr.Column():
chatbox2 = gr.Chatbot(label="Warrior B", show_copy_button=True)
textbox = gr.Textbox(show_label=False, placeholder="π Enter your prompt")
with gr.Row():
with gr.Accordion("π₯· Current Warriors", open=False):
with gr.Row():
war1 = gr.Textbox(arena.model1, interactive=False, show_label=False)
war2 = gr.Textbox(arena.model2, interactive=False, show_label=False)
with gr.Row():
with gr.Accordion("π Vote", open=False):
with gr.Row():
vote_a = gr.ClearButton([textbox, chatbox1, chatbox2], value="π Warrior A Wins")
vote_b = gr.ClearButton([textbox, chatbox1, chatbox2], value="π Warrior B Wins")
vote_tie = gr.ClearButton([textbox, chatbox1, chatbox2], value="π€ Both Won")
submit_button = gr.Button("Submit")
with gr.Row():
new_round = gr.ClearButton([textbox, chatbox1, chatbox2], value="π²New Roundπ²")
clear = gr.ClearButton([textbox, chatbox1, chatbox2], value="π§Ή Clear")
with gr.Row():
with gr.Accordion("π© Parameters", open=False):
temp_slider = gr.Slider(0, 1, value=0.7, step=0.1, label="Temperature")
# Event bindings
textbox.submit(fn=arena.gen_output, inputs=[temp_slider, textbox], outputs=[chatbox1, chatbox2])
textbox.submit(fn=arena.current_model1, outputs=war1)
textbox.submit(fn=arena.current_model2, outputs=war2)
submit_button.click(fn=arena.gen_output, inputs=[temp_slider, textbox], outputs=[chatbox1, chatbox2])
submit_button.click(fn=arena.current_model1, outputs=war1)
submit_button.click(fn=arena.current_model2, outputs=war2)
vote_a.click(fn=lambda: score.update(arena.model1, score.df))
vote_b.click(fn=lambda: score.update(arena.model2, score.df))
vote_tie.click(fn=arena.change_models)
new_round.click(fn=arena.change_models)
clear.click(fn=arena.clear_history)
with gr.Tab("π― Score Board"):
gr.Markdown('''## βοΈ LLM: Large Language Mayhem
- Voting should be fair and based on the performance of the models.
- No cheating or manipulating the outcomes.
- Click on Generate button to Update the π― Scoreboard.
''')
scoreboard = gr.Dataframe(type="pandas", label="Scoreboard", headers=["", "", ""])
generate_button = gr.Button("Generate")
generate_button.click(fn=score.df_show, outputs=scoreboard)
# Launch the app with sharing enabled
app.launch(share=True)
|