Spaces:
Sleeping
Sleeping
File size: 1,195 Bytes
9631045 |
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 |
import gradio as gr
import pandas as pd
import random
df = pd.read_csv('data.csv')
models = df.columns.tolist()
print(models)
models.remove('hash')
models.remove('message')
messages = sorted(df['message'].tolist(), key=len)
messages_select = [(m[:150],m) for m in messages]
def out(message, model1, model2):
row = df[df['message'] == message]
output1 = row[model1].values[0]
output2 = row[model2].values[0]
return message, output1, output2
with gr.Blocks() as iface:
with gr.Row():
drop_message = gr.Dropdown(messages_select, label='Prompt', value=random.choice(messages))
with gr.Row():
drop_model1 = gr.Dropdown(models, label='Model 1', value=random.choice(models))
drop_model2 = gr.Dropdown(models, label='Model 2', value=random.choice(models))
with gr.Row():
btn = gr.Button("Run")
with gr.Row():
out_message = gr.TextArea(label='Prompt')
with gr.Row():
out_model1 = gr.TextArea(label='Output Model 1')
out_model2 = gr.TextArea(label='Output Model 2')
btn.click(out,
inputs=[drop_message, drop_model1, drop_model2],
outputs=[out_message, out_model1, out_model2])
iface.launch() |