oliverwang15 commited on
Commit
0670cf4
1 Parent(s): 35c1e05

updates on the new prompt and better features

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. backend.py +5 -5
app.py CHANGED
@@ -44,7 +44,7 @@ with gr.Blocks(theme="dark") as demo:
44
  gr.Markdown(f'<center><p>The answer to your question is :</p></center>')
45
  question_box = gr.Textbox(label='Question')
46
  answer_box = gr.Textbox(label='Answer')
47
- reference_box = gr.Textbox(label='Reference')
48
 
49
  highlighted_text = gr.outputs.HTML(label="Highlighted Text")
50
  with gr.Row():
@@ -103,7 +103,7 @@ with gr.Blocks(theme="dark") as demo:
103
  btn_submit_txt.click(
104
  backend.process_file,
105
  inputs=[file, questions, openai_key],
106
- outputs=[question_box, answer_box, reference_box, highlighted_text, correct_answer, correct_reference],
107
  )
108
 
109
  btn_submit_correctness.click( # TODO
@@ -115,12 +115,12 @@ with gr.Blocks(theme="dark") as demo:
115
  # Switch question button
116
  btn_last_question.click(
117
  backend.process_last,
118
- outputs=[question_box, answer_box, reference_box, highlighted_text, correct_answer, correct_reference, save_results, answer_correct, reference_correct],
119
  )
120
 
121
  btn_next_question.click(
122
  backend.process_next,
123
- outputs=[question_box, answer_box, reference_box, highlighted_text, correct_answer, correct_reference, save_results, answer_correct, reference_correct],
124
  )
125
 
126
  # Download button
 
44
  gr.Markdown(f'<center><p>The answer to your question is :</p></center>')
45
  question_box = gr.Textbox(label='Question')
46
  answer_box = gr.Textbox(label='Answer')
47
+ # reference_box = gr.Textbox(label='Reference')
48
 
49
  highlighted_text = gr.outputs.HTML(label="Highlighted Text")
50
  with gr.Row():
 
103
  btn_submit_txt.click(
104
  backend.process_file,
105
  inputs=[file, questions, openai_key],
106
+ outputs=[question_box, answer_box, highlighted_text, correct_answer, correct_reference],
107
  )
108
 
109
  btn_submit_correctness.click( # TODO
 
115
  # Switch question button
116
  btn_last_question.click(
117
  backend.process_last,
118
+ outputs=[question_box, answer_box, highlighted_text, correct_answer, correct_reference, save_results, answer_correct, reference_correct],
119
  )
120
 
121
  btn_next_question.click(
122
  backend.process_next,
123
+ outputs=[question_box, answer_box, highlighted_text, correct_answer, correct_reference, save_results, answer_correct, reference_correct],
124
  )
125
 
126
  # Download button
backend.py CHANGED
@@ -75,7 +75,7 @@ class Backend:
75
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
76
  self.highlighted_out = '\n'.join(self.highlighted_out)
77
 
78
- return question, self.answer, self.highlighted_out, highlighted_out_html, self.answer, self.highlighted_out
79
 
80
  def process_results(self, answer_correct, correct_answer, reference_correct, correct_reference):
81
  if not hasattr(self, 'clicked_correct_answer'):
@@ -122,7 +122,7 @@ class Backend:
122
 
123
  if self.curret_question >= self.totel_question:
124
  # self.curret_question -= 1
125
- return "No more questions!", "No more questions!", "No more questions!", "No more questions!", 'No more questions!', 'No more questions!', 'Still need to click the button above to save the results', None, None
126
  else:
127
  res = self.gpt_result[f'Question {self.curret_question + 1}']
128
  question = self.questions[self.curret_question]
@@ -130,7 +130,7 @@ class Backend:
130
  self.highlighted_out = res['original sentences']
131
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
132
  self.highlighted_out = '\n'.join(self.highlighted_out)
133
- return question, self.answer,self.highlighted_out, highlighted_out_html, 'Please judge on the generated answer', 'Please judge on the generated answer', 'Still need to click the button above to save the results', None, None
134
 
135
  def process_last(self):
136
  self.curret_question -= 1
@@ -142,7 +142,7 @@ class Backend:
142
 
143
  if self.curret_question < 0:
144
  # self.curret_question += 1
145
- return "No more questions!", "No more questions!", "No more questions!", "No more questions!", 'No more questions!', 'No more questions!', 'Still need to click the button above to save the results', None, None
146
  else:
147
  res = self.gpt_result[f'Question {self.curret_question + 1}']
148
  question = self.questions[self.curret_question]
@@ -150,7 +150,7 @@ class Backend:
150
  self.highlighted_out = res['original sentences']
151
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
152
  self.highlighted_out = '\n'.join(self.highlighted_out)
153
- return question, self.answer, self.highlighted_out, highlighted_out_html, 'Please judge on the generated answer', 'Please judge on the generated answer', 'Still need to click the button above to save the results', None, None
154
 
155
  def download_answer(self, path = './tmp', name = 'answer.xlsx'):
156
  os.makedirs(path, exist_ok = True)
 
75
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
76
  self.highlighted_out = '\n'.join(self.highlighted_out)
77
 
78
+ return question, self.answer, highlighted_out_html, self.answer, self.highlighted_out
79
 
80
  def process_results(self, answer_correct, correct_answer, reference_correct, correct_reference):
81
  if not hasattr(self, 'clicked_correct_answer'):
 
122
 
123
  if self.curret_question >= self.totel_question:
124
  # self.curret_question -= 1
125
+ return "No more questions!", "No more questions!", "No more questions!", 'No more questions!', 'No more questions!', 'Still need to click the button above to save the results', None, None
126
  else:
127
  res = self.gpt_result[f'Question {self.curret_question + 1}']
128
  question = self.questions[self.curret_question]
 
130
  self.highlighted_out = res['original sentences']
131
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
132
  self.highlighted_out = '\n'.join(self.highlighted_out)
133
+ return question, self.answer, highlighted_out_html, 'Please judge on the generated answer', 'Please judge on the generated answer', 'Still need to click the button above to save the results', None, None
134
 
135
  def process_last(self):
136
  self.curret_question -= 1
 
142
 
143
  if self.curret_question < 0:
144
  # self.curret_question += 1
145
+ return "No more questions!", "No more questions!", "No more questions!", 'No more questions!', 'No more questions!', 'Still need to click the button above to save the results', None, None
146
  else:
147
  res = self.gpt_result[f'Question {self.curret_question + 1}']
148
  question = self.questions[self.curret_question]
 
150
  self.highlighted_out = res['original sentences']
151
  highlighted_out_html = self.highlight_text(self.text, self.highlighted_out)
152
  self.highlighted_out = '\n'.join(self.highlighted_out)
153
+ return question, self.answer, highlighted_out_html, 'Please judge on the generated answer', 'Please judge on the generated answer', 'Still need to click the button above to save the results', None, None
154
 
155
  def download_answer(self, path = './tmp', name = 'answer.xlsx'):
156
  os.makedirs(path, exist_ok = True)