5m4ck3r commited on
Commit
7206095
1 Parent(s): f6722ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -241,6 +241,19 @@ def save_data_to_database(qlist, input_passage):
241
  dataset_mng.add_to_dataset(to_save, token)
242
  gr.Info("Data saved to dataset")
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  def edit_question_and_answer(real_question, Newquestion, Newanswer, qlist):
245
  if not isinstance(qlist, list):
246
  qlist = ast.literal_eval(qlist)
@@ -310,6 +323,10 @@ with gr.Blocks() as demo:
310
  edit_answer_input = gr.Textbox(label="New Answer", placeholder="New Answer (Optional)")
311
  edit_qna_button = gr.Button("Edit Q&A")
312
  edit_qna_button.click(edit_question_and_answer, inputs=[edit_question_real, edit_question_input, edit_answer_input, text_output_qna_json], outputs=[text_output_qna, text_output_qna_json])
 
 
 
 
313
 
314
  with gr.Tab("Evaluate"):
315
  gr.Markdown("# Evaluate Texts")
 
241
  dataset_mng.add_to_dataset(to_save, token)
242
  gr.Info("Data saved to dataset")
243
 
244
+ def add_new_question(new_question, new_answer, qlist):
245
+ if qlist == None:
246
+ qlist = []
247
+ if not isinstance(qlist, list):
248
+ qlist = ast.literal_eval(qlist)
249
+ qlist.append(
250
+ {
251
+ "question" : new_question,
252
+ "answer" : new_answer
253
+ }
254
+ )
255
+ return generate_qna_html(qlist), qlist
256
+
257
  def edit_question_and_answer(real_question, Newquestion, Newanswer, qlist):
258
  if not isinstance(qlist, list):
259
  qlist = ast.literal_eval(qlist)
 
323
  edit_answer_input = gr.Textbox(label="New Answer", placeholder="New Answer (Optional)")
324
  edit_qna_button = gr.Button("Edit Q&A")
325
  edit_qna_button.click(edit_question_and_answer, inputs=[edit_question_real, edit_question_input, edit_answer_input, text_output_qna_json], outputs=[text_output_qna, text_output_qna_json])
326
+ new_question_input = gr.Textbox(label="New Question", placeholder="New question")
327
+ new_answer = gr.Textbox(label="New Answer", placeholder="New Answer")
328
+ button = gr.Button("Add Q&A")
329
+ button.click(add_new_question, inputs=[new_question_input, new_answer], outputs=[text_output_qna, text_output_qna_json])
330
 
331
  with gr.Tab("Evaluate"):
332
  gr.Markdown("# Evaluate Texts")