Spaces:
Runtime error
Runtime error
hanzla javaid commited on
Commit Β·
e9d2334
1
Parent(s): 97e6085
test
Browse files
app.py
CHANGED
|
@@ -37,10 +37,9 @@ def chat(message, history, model1, model2):
|
|
| 37 |
|
| 38 |
def vote(direction, history):
|
| 39 |
if history:
|
| 40 |
-
|
| 41 |
vote_text = f"\n\nUser voted: {'π' if direction == 'up' else 'π'}"
|
| 42 |
-
|
| 43 |
-
return history[:-1] + [updated_interaction]
|
| 44 |
return history
|
| 45 |
|
| 46 |
|
|
@@ -51,7 +50,7 @@ with gr.Blocks() as demo:
|
|
| 51 |
model1_dropdown = gr.Dropdown(choices=models, label="Model 1", value=models[0])
|
| 52 |
model2_dropdown = gr.Dropdown(choices=models, label="Model 2", value=models[1])
|
| 53 |
|
| 54 |
-
chatbot = gr.Chatbot()
|
| 55 |
msg = gr.Textbox(label="Your message")
|
| 56 |
clear = gr.Button("Clear")
|
| 57 |
|
|
@@ -60,7 +59,7 @@ with gr.Blocks() as demo:
|
|
| 60 |
downvote = gr.Button("π Downvote")
|
| 61 |
|
| 62 |
msg.submit(chat, [msg, chatbot, model1_dropdown, model2_dropdown], chatbot)
|
| 63 |
-
clear.click(lambda:
|
| 64 |
upvote.click(vote, ["up", chatbot], chatbot)
|
| 65 |
downvote.click(vote, ["down", chatbot], chatbot)
|
| 66 |
|
|
|
|
| 37 |
|
| 38 |
def vote(direction, history):
|
| 39 |
if history:
|
| 40 |
+
last_message = history[-1]
|
| 41 |
vote_text = f"\n\nUser voted: {'π' if direction == 'up' else 'π'}"
|
| 42 |
+
last_message["content"] += vote_text
|
|
|
|
| 43 |
return history
|
| 44 |
|
| 45 |
|
|
|
|
| 50 |
model1_dropdown = gr.Dropdown(choices=models, label="Model 1", value=models[0])
|
| 51 |
model2_dropdown = gr.Dropdown(choices=models, label="Model 2", value=models[1])
|
| 52 |
|
| 53 |
+
chatbot = gr.Chatbot(label="Chat History", type="messages")
|
| 54 |
msg = gr.Textbox(label="Your message")
|
| 55 |
clear = gr.Button("Clear")
|
| 56 |
|
|
|
|
| 59 |
downvote = gr.Button("π Downvote")
|
| 60 |
|
| 61 |
msg.submit(chat, [msg, chatbot, model1_dropdown, model2_dropdown], chatbot)
|
| 62 |
+
clear.click(lambda: [], None, chatbot, queue=False)
|
| 63 |
upvote.click(vote, ["up", chatbot], chatbot)
|
| 64 |
downvote.click(vote, ["down", chatbot], chatbot)
|
| 65 |
|