Spaces:
Sleeping
Sleeping
Update app.py
Browse filesvote is or not like
app.py
CHANGED
|
@@ -52,7 +52,11 @@ def reset_user_input():
|
|
| 52 |
|
| 53 |
def reset_state():
|
| 54 |
return [], []
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as rxbot:
|
| 57 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
| 58 |
state = gr.State([])
|
|
@@ -65,8 +69,8 @@ with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as r
|
|
| 65 |
submit_btn.click(answer, [txt, state], [chatbot, state])
|
| 66 |
submit_btn.click(reset_user_input, [], [txt])
|
| 67 |
# clear = gr.ClearButton([txt, chatbot])
|
| 68 |
-
|
| 69 |
-
|
| 70 |
rxbot.queue().launch(share=True)
|
| 71 |
|
| 72 |
|
|
|
|
| 52 |
|
| 53 |
def reset_state():
|
| 54 |
return [], []
|
| 55 |
+
def vote(data: gr.LikeData):
|
| 56 |
+
if data.liked:
|
| 57 |
+
print("You upvoted this response: " + data.value)
|
| 58 |
+
else:
|
| 59 |
+
print("You downvoted this response: " + data.value)
|
| 60 |
with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as rxbot:
|
| 61 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
| 62 |
state = gr.State([])
|
|
|
|
| 69 |
submit_btn.click(answer, [txt, state], [chatbot, state])
|
| 70 |
submit_btn.click(reset_user_input, [], [txt])
|
| 71 |
# clear = gr.ClearButton([txt, chatbot])
|
| 72 |
+
chatbot.like(vote, None, None)
|
| 73 |
+
|
| 74 |
rxbot.queue().launch(share=True)
|
| 75 |
|
| 76 |
|