Spaces:
Sleeping
Sleeping
added the like button
Browse files
app.py
CHANGED
@@ -55,6 +55,12 @@ with gr.Blocks(theme=theme) as demo:
|
|
55 |
msg = gr.Textbox()
|
56 |
clear = gr.Button("Clear")
|
57 |
chat_history = []
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
def user(user_message, chat_history):
|
60 |
|
@@ -83,6 +89,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
83 |
chat_history.append((user_message, response["answer"]))
|
84 |
return gr.update(value=""), chat_history
|
85 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False)
|
|
|
86 |
clear.click(lambda: None, None, chatbot, queue=False)
|
87 |
|
88 |
if __name__ == "__main__":
|
|
|
55 |
msg = gr.Textbox()
|
56 |
clear = gr.Button("Clear")
|
57 |
chat_history = []
|
58 |
+
|
59 |
+
def vote(data: gr.LikeData):
|
60 |
+
if data.liked:
|
61 |
+
print("You upvoted this response: " + data.value)
|
62 |
+
else:
|
63 |
+
print("You downvoted this reposnse: " + data.value)
|
64 |
|
65 |
def user(user_message, chat_history):
|
66 |
|
|
|
89 |
chat_history.append((user_message, response["answer"]))
|
90 |
return gr.update(value=""), chat_history
|
91 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False)
|
92 |
+
chatbot.like(vote, None, None)
|
93 |
clear.click(lambda: None, None, chatbot, queue=False)
|
94 |
|
95 |
if __name__ == "__main__":
|