yikic commited on
Commit
a8f30da
·
1 Parent(s): 2926ca7

fixed bug

Browse files
Files changed (3) hide show
  1. app.py +3 -2
  2. styles.css +1 -1
  3. utils.py +6 -4
app.py CHANGED
@@ -14,6 +14,7 @@ def first_chap(chapters):
14
  chapters_info = {}
15
  for i in range(len(chapters)):
16
  chapters_info[f'chapter_{i}'] = {'content': chapters[i], 'history': [], 'chapter_idx': i+1}
 
17
  return chapters_info
18
 
19
 
@@ -82,7 +83,7 @@ with gr.Blocks(css='styles.css', theme=gr.themes.Soft()) as demo:
82
 
83
  examples = gr.Examples([['2402.12226'], ['1811.09243'], ['2106.09685']], inputs=[arxiv_id])
84
 
85
- gr.Markdown('step 1️⃣: fill in your **arXiv ID** and click "Initialization"')
86
  wait_mk_0 = gr.Markdown('waiting for initialization...')
87
  btn_0.click(return_chapters, inputs=arxiv_id, outputs=chapters) \
88
  .then(first_chap, inputs=chapters, outputs=iter_chapters) \
@@ -92,7 +93,7 @@ with gr.Blocks(css='styles.css', theme=gr.themes.Soft()) as demo:
92
  @gr.render(triggers=[btn_1.click], inputs=[iter_chapters, idx_1])
93
  def gen_1(iter_chapters, idx_1):
94
  to_markdown_column(iter_chapters, idx_1)
95
- gr.Markdown('step 2️⃣: waiting for the prompt..')
96
  wait_mk_1 = gr.Markdown('waiting for generating chapter 1...')
97
 
98
  @gr.render(triggers=[btn_2.click], inputs=[iter_chapters, idx_2])
 
14
  chapters_info = {}
15
  for i in range(len(chapters)):
16
  chapters_info[f'chapter_{i}'] = {'content': chapters[i], 'history': [], 'chapter_idx': i+1}
17
+ chapters_info[f'chapter_{len(chapters)}'] = {'content': '', 'history': [], 'chapter_idx': len(chapters) + 1}
18
  return chapters_info
19
 
20
 
 
83
 
84
  examples = gr.Examples([['2402.12226'], ['1811.09243'], ['2106.09685']], inputs=[arxiv_id])
85
 
86
+ gr.Markdown('step 1️⃣: fill in your **arXiv ID** and click "Initialization", the progress bar might appear a few seconds later..')
87
  wait_mk_0 = gr.Markdown('waiting for initialization...')
88
  btn_0.click(return_chapters, inputs=arxiv_id, outputs=chapters) \
89
  .then(first_chap, inputs=chapters, outputs=iter_chapters) \
 
93
  @gr.render(triggers=[btn_1.click], inputs=[iter_chapters, idx_1])
94
  def gen_1(iter_chapters, idx_1):
95
  to_markdown_column(iter_chapters, idx_1)
96
+ gr.Markdown('step 2️⃣: waiting for the prompt..(if it tells you that gpu task aborted or error, just retry that button again)')
97
  wait_mk_1 = gr.Markdown('waiting for generating chapter 1...')
98
 
99
  @gr.render(triggers=[btn_2.click], inputs=[iter_chapters, idx_2])
styles.css CHANGED
@@ -30,7 +30,7 @@
30
  #chapter-buttons {
31
  position: fixed;
32
  right: 20px;
33
- bottom: 200px;
34
  width: 50px;
35
  display: flex;
36
  flex-direction: column;
 
30
  #chapter-buttons {
31
  position: fixed;
32
  right: 20px;
33
+ bottom: 250px;
34
  width: 50px;
35
  display: flex;
36
  flex-direction: column;
utils.py CHANGED
@@ -140,7 +140,6 @@ def paper_summarization_0(
140
  chapter_and_history = iter_chapters['chapter_0']
141
  history = chapter_and_history['history']
142
  cur_retry = 0
143
- print(len(iter_chapters))
144
 
145
  paper_content = chapter_and_history['content']
146
  chapter_idx = chapter_and_history['chapter_idx']
@@ -223,7 +222,6 @@ def paper_summarization_1(
223
  chapter_and_history = iter_chapters['chapter_1']
224
  history = chapter_and_history['history']
225
  cur_retry = 0
226
- print(len(iter_chapters))
227
 
228
  paper_content = chapter_and_history['content']
229
  chapter_idx = chapter_and_history['chapter_idx']
@@ -305,6 +303,8 @@ def paper_summarization_2(
305
  ):
306
  chapter_and_history = iter_chapters['chapter_2']
307
  history = chapter_and_history['history']
 
 
308
  cur_retry = 0
309
 
310
  paper_content = chapter_and_history['content']
@@ -389,6 +389,8 @@ def paper_summarization_3(
389
  return iter_chapters, 'that is all'
390
  chapter_and_history = iter_chapters['chapter_3']
391
  history = chapter_and_history['history']
 
 
392
  cur_retry = 0
393
 
394
  paper_content = chapter_and_history['content']
@@ -542,7 +544,7 @@ def paper_summarization_4(
542
  buffer = regenerate_chapter_summary(conversation, tokenizer, model, temperature, top_p, top_k, penalty)
543
 
544
 
545
- @spaces.GPU(duration=120)
546
  def paper_summarization_5(
547
  iter_chapters,
548
  max_section_tokens=500,
@@ -626,7 +628,7 @@ def paper_summarization_5(
626
  buffer = regenerate_chapter_summary(conversation, tokenizer, model, temperature, top_p, top_k, penalty)
627
 
628
 
629
- @spaces.GPU(duration=120)
630
  def paper_summarization_6(
631
  iter_chapters,
632
  max_section_tokens=500,
 
140
  chapter_and_history = iter_chapters['chapter_0']
141
  history = chapter_and_history['history']
142
  cur_retry = 0
 
143
 
144
  paper_content = chapter_and_history['content']
145
  chapter_idx = chapter_and_history['chapter_idx']
 
222
  chapter_and_history = iter_chapters['chapter_1']
223
  history = chapter_and_history['history']
224
  cur_retry = 0
 
225
 
226
  paper_content = chapter_and_history['content']
227
  chapter_idx = chapter_and_history['chapter_idx']
 
303
  ):
304
  chapter_and_history = iter_chapters['chapter_2']
305
  history = chapter_and_history['history']
306
+ if history == []:
307
+ return iter_chapters, "click 'generate chapter 1' first"
308
  cur_retry = 0
309
 
310
  paper_content = chapter_and_history['content']
 
389
  return iter_chapters, 'that is all'
390
  chapter_and_history = iter_chapters['chapter_3']
391
  history = chapter_and_history['history']
392
+ if history == []:
393
+ return iter_chapters, "click 'generate chapter 2' first"
394
  cur_retry = 0
395
 
396
  paper_content = chapter_and_history['content']
 
544
  buffer = regenerate_chapter_summary(conversation, tokenizer, model, temperature, top_p, top_k, penalty)
545
 
546
 
547
+ @spaces.GPU()
548
  def paper_summarization_5(
549
  iter_chapters,
550
  max_section_tokens=500,
 
628
  buffer = regenerate_chapter_summary(conversation, tokenizer, model, temperature, top_p, top_k, penalty)
629
 
630
 
631
+ @spaces.GPU()
632
  def paper_summarization_6(
633
  iter_chapters,
634
  max_section_tokens=500,