Update app.py
Browse files
app.py
CHANGED
@@ -203,15 +203,21 @@ def save_feedback(inputs):
|
|
203 |
return "Thanks your advice!"
|
204 |
|
205 |
|
206 |
-
|
207 |
-
|
|
|
|
|
208 |
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
-
def
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
print("You downvoted this prediction: " + data.value["value"])
|
215 |
|
216 |
|
217 |
# Define the FAPM interface
|
@@ -242,6 +248,7 @@ css = """
|
|
242 |
|
243 |
with gr.Blocks(css=css) as demo:
|
244 |
gr.Markdown(description)
|
|
|
245 |
with gr.Tab(label="Protein caption"):
|
246 |
with gr.Row():
|
247 |
with gr.Column():
|
@@ -252,14 +259,13 @@ with gr.Blocks(css=css) as demo:
|
|
252 |
# output_text = gr.Textbox(label="Output Text")
|
253 |
with gr.Accordion('Prediction:', open=True):
|
254 |
output_markdown = gr.Markdown(label="Output")
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
# feedback_btn = gr.Button(value="Submit")
|
263 |
# O14813 train index 127, 266, 738, 1060 test index 4
|
264 |
gr.Examples(
|
265 |
examples=[
|
@@ -277,7 +283,9 @@ with gr.Blocks(css=css) as demo:
|
|
277 |
label='Try examples'
|
278 |
)
|
279 |
submit_btn.click(generate_caption, [input_protein, prompt], [output_markdown])
|
280 |
-
|
|
|
|
|
281 |
|
282 |
demo.launch(debug=True)
|
283 |
|
|
|
203 |
return "Thanks your advice!"
|
204 |
|
205 |
|
206 |
+
feedback_data = []
|
207 |
+
def chatbot_respond(message, history=[]):
|
208 |
+
response = "yes"
|
209 |
+
return response, history + [(message, response)]
|
210 |
|
211 |
+
# Functions to handle like/dislike
|
212 |
+
def upvote(vote_id):
|
213 |
+
feedback_data.append((vote_id, "upvote"))
|
214 |
+
print(f"Current feedback data: {feedback_data}")
|
215 |
+
return "You liked this response"
|
216 |
|
217 |
+
def downvote(vote_id):
|
218 |
+
feedback_data.append((vote_id, "downvote"))
|
219 |
+
print(f"Current feedback data: {feedback_data}")
|
220 |
+
return "You disliked this response"
|
|
|
221 |
|
222 |
|
223 |
# Define the FAPM interface
|
|
|
248 |
|
249 |
with gr.Blocks(css=css) as demo:
|
250 |
gr.Markdown(description)
|
251 |
+
vote_id = gr.State(0)
|
252 |
with gr.Tab(label="Protein caption"):
|
253 |
with gr.Row():
|
254 |
with gr.Column():
|
|
|
259 |
# output_text = gr.Textbox(label="Output Text")
|
260 |
with gr.Accordion('Prediction:', open=True):
|
261 |
output_markdown = gr.Markdown(label="Output")
|
262 |
+
upvote_button = gr.Button("π")
|
263 |
+
downvote_button = gr.Button("π")
|
264 |
+
|
265 |
+
with gr.Column():
|
266 |
+
inputs = gr.Textbox(type="text")
|
267 |
+
feedback_markdown = gr.Markdown(label="Output")
|
268 |
+
feedback_btn = gr.Button(value="Submit")
|
|
|
269 |
# O14813 train index 127, 266, 738, 1060 test index 4
|
270 |
gr.Examples(
|
271 |
examples=[
|
|
|
283 |
label='Try examples'
|
284 |
)
|
285 |
submit_btn.click(generate_caption, [input_protein, prompt], [output_markdown])
|
286 |
+
upvote_button.click(upvote, vote_id, None)
|
287 |
+
downvote_button.click(downvote, vote_id, None)
|
288 |
+
feedback_btn.click(save_feedback, [inputs], [feedback_markdown])
|
289 |
|
290 |
demo.launch(debug=True)
|
291 |
|