maxidl commited on
Commit
5e173f3
·
1 Parent(s): 32fbbba
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -170,12 +170,12 @@ def process_file(file):
170
 
171
 
172
  @spaces.GPU(duration=60)
173
- def generate(paper_text):
174
  # messages = [
175
  # {"role": "system", "content": "You are a pirate."},
176
  # {"role": "user", "content": paper_text}
177
  # ]
178
- messages = create_messages(REVIEW_FIELDS, paper_text)
179
  input_ids = tokenizer.apply_chat_template(
180
  messages,
181
  add_generation_prompt=True,
@@ -204,18 +204,17 @@ steps = """Placeholder Description"""
204
  with gr.Blocks() as demo:
205
  title = gr.Markdown(title)
206
  steps = gr.Markdown(steps)
207
- instr = gr.Markdown("## Upload your paper as a pdf file")
208
  file_input = gr.File(file_types=[".pdf"], file_count="single")
209
- markdown_field = gr.Textbox(label="Paper Text", max_lines=20, autoscroll=False)
210
- markdown_field = gr.Textbox(label="Review Template", max_lines=20, autoscroll=False, value=REVIEW_FIELDS)
211
- # generate_button = gr.Button("Generate Review", interactive=not markdown_field)
212
- generate_button = gr.Button("Generate Review")
213
- file_input.upload(process_file, file_input, markdown_field)
214
- # markdown_field.change(lambda text: gr.update(interactive=True) if len(text) > 1000 else gr.update(interactive=False), markdown_field, generate_button)
215
 
216
  review_field = gr.Markdown(label="Review")
217
- # generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, markdown_field, review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
218
- generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, markdown_field, review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
219
  demo.title = "Paper Review Generator"
220
 
221
 
 
170
 
171
 
172
  @spaces.GPU(duration=60)
173
+ def generate(paper_text, review_template):
174
  # messages = [
175
  # {"role": "system", "content": "You are a pirate."},
176
  # {"role": "user", "content": paper_text}
177
  # ]
178
+ messages = create_messages(review_template paper_text)
179
  input_ids = tokenizer.apply_chat_template(
180
  messages,
181
  add_generation_prompt=True,
 
204
  with gr.Blocks() as demo:
205
  title = gr.Markdown(title)
206
  steps = gr.Markdown(steps)
207
+ instr = gr.Markdown("## Upload your paper in pdf format")
208
  file_input = gr.File(file_types=[".pdf"], file_count="single")
209
+ paper_text_field= gr.Textbox(label="Paper Text", max_lines=20, autoscroll=False)
210
+ review_template_field = gr.Textbox(label="Review Template", max_lines=20, autoscroll=False, value=REVIEW_FIELDS)
211
+ generate_button = gr.Button("Generate Review", interactive=not paper_text_field)
212
+ # generate_button = gr.Button("Generate Review")
213
+ file_input.upload(process_file, file_input, paper_text_field)
214
+ paper_text_field.change(lambda text: gr.update(interactive=True) if len(text) > 200 else gr.update(interactive=False), paper_text_field, generate_button)
215
 
216
  review_field = gr.Markdown(label="Review")
217
+ generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, [paper_text_field, review_template_field], review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
 
218
  demo.title = "Paper Review Generator"
219
 
220