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! ''') 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("πŸ‘† 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 = "Temprature") textbox.submit( fn = arena.gen_output, inputs = [temp_slider, textbox], outputs = [chatbox1, chatbox2] ) submit_button.click( fn = arena.gen_output, inputs = [temp_slider, textbox], outputs = [chatbox1, chatbox2] ) 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") as data_tab: 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. ''') gr.Interface( fn = score.df_show, inputs = None, outputs=gr.Dataframe(type="pandas", label="Scoreboard", headers = ["","",""]), live = True, allow_flagging = "never", clear_btn = None ) app.launch()