wangrongsheng commited on
Commit
18943dc
1 Parent(s): d95123f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -397,7 +397,7 @@ class Reader:
397
 
398
  return image_url
399
 
400
- def summary_with_chat(self, paper_list):
401
  htmls = []
402
  for paper_index, paper in enumerate(paper_list):
403
  # 第一步先用title,abs,和introduction进行总结。
@@ -409,7 +409,7 @@ class Reader:
409
  text += list(paper.section_text_dict.values())[0]
410
  max_token = 2500 * 4
411
  text = text[:max_token]
412
- chat_summary_text = self.chat_summary(text=text)
413
  htmls.append(chat_summary_text)
414
 
415
  # TODO 往md文档中插入论文里的像素最大的一张图片,这个方案可以弄的更加智能一些:
@@ -441,7 +441,7 @@ class Reader:
441
  max_token = 2500 * 4
442
  text = summary_text + "\n <Methods>:\n" + method_text
443
  text = text[:max_token]
444
- chat_method_text = self.chat_method(text=text)
445
  htmls.append(chat_method_text)
446
  else:
447
  chat_method_text = ''
@@ -466,7 +466,7 @@ class Reader:
466
  else:
467
  text = summary_text
468
  text = text[:max_token]
469
- chat_conclusion_text = self.chat_conclusion(text=text)
470
  htmls.append(chat_conclusion_text)
471
  htmls.append("\n")
472
  md_text = "\n".join(htmls)
@@ -492,8 +492,8 @@ class Reader:
492
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
493
  stop=tenacity.stop_after_attempt(5),
494
  reraise=True)
495
- def chat_conclusion(self, text):
496
- openai.api_key = self.key
497
  response = openai.ChatCompletion.create(
498
  model="gpt-3.5-turbo",
499
  # prompt需要用英语替换,少占用token。
@@ -523,8 +523,8 @@ class Reader:
523
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
524
  stop=tenacity.stop_after_attempt(5),
525
  reraise=True)
526
- def chat_method(self, text):
527
- openai.api_key = self.key
528
  response = openai.ChatCompletion.create(
529
  model="gpt-3.5-turbo",
530
  messages=[
@@ -556,8 +556,8 @@ class Reader:
556
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
557
  stop=tenacity.stop_after_attempt(5),
558
  reraise=True)
559
- def chat_summary(self, text):
560
- openai.api_key = self.key
561
  response = openai.ChatCompletion.create(
562
  model="gpt-3.5-turbo",
563
  messages=[
 
397
 
398
  return image_url
399
 
400
+ def summary_with_chat(self, paper_list, key):
401
  htmls = []
402
  for paper_index, paper in enumerate(paper_list):
403
  # 第一步先用title,abs,和introduction进行总结。
 
409
  text += list(paper.section_text_dict.values())[0]
410
  max_token = 2500 * 4
411
  text = text[:max_token]
412
+ chat_summary_text = self.chat_summary(text=text, key=str(key))
413
  htmls.append(chat_summary_text)
414
 
415
  # TODO 往md文档中插入论文里的像素最大的一张图片,这个方案可以弄的更加智能一些:
 
441
  max_token = 2500 * 4
442
  text = summary_text + "\n <Methods>:\n" + method_text
443
  text = text[:max_token]
444
+ chat_method_text = self.chat_method(text=text, key=str(key))
445
  htmls.append(chat_method_text)
446
  else:
447
  chat_method_text = ''
 
466
  else:
467
  text = summary_text
468
  text = text[:max_token]
469
+ chat_conclusion_text = self.chat_conclusion(text=text, key=str(key))
470
  htmls.append(chat_conclusion_text)
471
  htmls.append("\n")
472
  md_text = "\n".join(htmls)
 
492
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
493
  stop=tenacity.stop_after_attempt(5),
494
  reraise=True)
495
+ def chat_conclusion(self, text, key):
496
+ openai.api_key = key
497
  response = openai.ChatCompletion.create(
498
  model="gpt-3.5-turbo",
499
  # prompt需要用英语替换,少占用token。
 
523
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
524
  stop=tenacity.stop_after_attempt(5),
525
  reraise=True)
526
+ def chat_method(self, text, key):
527
+ openai.api_key = key
528
  response = openai.ChatCompletion.create(
529
  model="gpt-3.5-turbo",
530
  messages=[
 
556
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
557
  stop=tenacity.stop_after_attempt(5),
558
  reraise=True)
559
+ def chat_summary(self, text, key):
560
+ openai.api_key = key
561
  response = openai.ChatCompletion.create(
562
  model="gpt-3.5-turbo",
563
  messages=[