Spaces:
Build error
Build error
Upload app.py
Browse filesadd review part
app.py
CHANGED
@@ -469,6 +469,9 @@ class Reader:
|
|
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)
|
473 |
|
474 |
return markdown.markdown(md_text)
|
@@ -579,8 +582,58 @@ class Reader:
|
|
579 |
for choice in response.choices:
|
580 |
result += choice.message.content
|
581 |
print("summary_result:\n", result)
|
582 |
-
return result
|
583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
def export_to_markdown(self, text, file_name, mode='w'):
|
585 |
# 使用markdown模块的convert方法,将文本转换为html格式
|
586 |
# html = markdown.markdown(text)
|
@@ -611,13 +664,13 @@ def upload_pdf(key, text, file):
|
|
611 |
return sum_info
|
612 |
|
613 |
# 标题
|
614 |
-
title = "
|
615 |
# 描述
|
616 |
description = '''<div align='center'>
|
617 |
|
618 |
Use ChatGPT to summary the papers.
|
619 |
|
620 |
-
|
621 |
|
622 |
</div>
|
623 |
'''
|
|
|
469 |
chat_conclusion_text = self.chat_conclusion(text=text, key=str(key))
|
470 |
htmls.append(chat_conclusion_text)
|
471 |
htmls.append("\n")
|
472 |
+
chat_review_text = self.chat_review(text=text, key=str(key))
|
473 |
+
htmls.append(chat_review_text)
|
474 |
+
htmls.append("\n")
|
475 |
md_text = "\n".join(htmls)
|
476 |
|
477 |
return markdown.markdown(md_text)
|
|
|
582 |
for choice in response.choices:
|
583 |
result += choice.message.content
|
584 |
print("summary_result:\n", result)
|
585 |
+
return result
|
586 |
+
|
587 |
+
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
|
588 |
+
stop=tenacity.stop_after_attempt(5),
|
589 |
+
reraise=True)
|
590 |
+
def chat_review(self, text):
|
591 |
+
openai.api_key = self.chat_api_list[self.cur_api]
|
592 |
+
self.cur_api += 1
|
593 |
+
self.cur_api = 0 if self.cur_api >= len(self.chat_api_list) - 1 else self.cur_api
|
594 |
+
|
595 |
+
response = openai.ChatCompletion.create(
|
596 |
+
model="gpt-3.5-turbo",
|
597 |
+
messages=[
|
598 |
+
{"role": "system",
|
599 |
+
"content": "You are a researcher in the field of [" + self.key_word + "] who is good at reviewing papers using concise statements"},
|
600 |
+
# chatgpt 角色
|
601 |
+
{"role": "assistant",
|
602 |
+
"content": "This is the title, author, link, abstract, introduction, method, and experiments of an English document. I need your help to read and review the following questions: " + text},
|
603 |
+
# 背景知识
|
604 |
+
{"role": "user", "content": """
|
605 |
+
1. summarize according to the following four points.Be sure to use English answers (proper nouns need to be marked in English)
|
606 |
+
- (1):What is the research background of this article?
|
607 |
+
- (2):What are the past methods? What are the problems with them? Is the approach well motivated?
|
608 |
+
- (3):What is the research methodology proposed in this paper?
|
609 |
+
- (4):On what task and what performance is achieved by the methods in this paper? Can the performance support their goals?
|
610 |
+
Follow the format of the output that follows:
|
611 |
+
2. Strengths: \n\n
|
612 |
+
- (1):Background;\n
|
613 |
+
- (2):Main challenges and Motivations;\n
|
614 |
+
- (3):The detail of methods\n
|
615 |
+
- (4):Results.\n\n
|
616 |
+
3. Weakness: \n\n
|
617 |
+
- (1):Motivation;\n
|
618 |
+
- (2):Methods;\n
|
619 |
+
- (3):Novelty\n
|
620 |
+
- (4):Results.\n\n
|
621 |
+
4. Other questions: \n\n
|
622 |
+
- (1):\n
|
623 |
+
- (2):\n
|
624 |
+
- (3):\n
|
625 |
+
- (4):\n\n
|
626 |
+
Be sure to use English answers, statements as concise and academic as possible, do not have too much repetitive information, numerical values using the original numbers, be sure to strictly follow the format, the corresponding content output to xxx, in accordance with \n line feed.
|
627 |
+
"""},
|
628 |
+
]
|
629 |
+
)
|
630 |
+
result = ''
|
631 |
+
for choice in response.choices:
|
632 |
+
result += choice.message.content
|
633 |
+
print("summary_result:\n", result)
|
634 |
+
return result
|
635 |
+
|
636 |
+
|
637 |
def export_to_markdown(self, text, file_name, mode='w'):
|
638 |
# 使用markdown模块的convert方法,将文本转换为html格式
|
639 |
# html = markdown.markdown(text)
|
|
|
664 |
return sum_info
|
665 |
|
666 |
# 标题
|
667 |
+
title = "ChatPaperPlus"
|
668 |
# 描述
|
669 |
description = '''<div align='center'>
|
670 |
|
671 |
Use ChatGPT to summary the papers.
|
672 |
|
673 |
+
Based on [ChatPaper](https://github.com/kaixindelele/ChatPaper), and add review function.
|
674 |
|
675 |
</div>
|
676 |
'''
|