Bostoncake commited on
Commit
b921714
·
1 Parent(s): a557fe1
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +23 -43
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: ChatReviewer
3
  emoji: 💩
4
  colorFrom: red
5
  colorTo: pink
 
1
  ---
2
+ title: ChatAssistant
3
  emoji: 💩
4
  colorFrom: red
5
  colorTo: pink
app.py CHANGED
@@ -15,9 +15,10 @@ import gradio
15
  # 定义Reviewer类
16
  class Reviewer:
17
  # 初始化方法,设置属性
18
- def __init__(self, api, review_format, paper_pdf, language):
19
  self.api = api
20
- self.review_format = review_format
 
21
 
22
  self.language = language
23
  self.paper_pdf = paper_pdf
@@ -40,9 +41,10 @@ class Reviewer:
40
  review_prompt_token = 1000
41
  text_token = len(self.encoding.encode(text))
42
  input_text_index = int(len(text)*(self.max_token_num-review_prompt_token)/(text_token+1))
43
- input_text = "This is the paper for your review:" + text[:input_text_index]
 
44
  messages=[
45
- {"role": "system", "content": "You are a professional reviewer. Now I will give you a paper. You need to give a complete review opinion according to the following requirements and format:"+ self.review_format +" Must be output in {}.".format(self.language)},
46
  {"role": "user", "content": input_text},
47
  ]
48
 
@@ -88,14 +90,14 @@ class Reviewer:
88
  break
89
  return extracted_text
90
 
91
- def main(api, review_format, paper_pdf, language):
92
  start_time = time.time()
93
- if not api or not review_format or not paper_pdf:
94
  return "请输入完整内容!"
95
  # 判断PDF文件
96
  else:
97
  # 创建一个Reader对象
98
- reviewer1 = Reviewer(api, review_format, paper_pdf, language)
99
  # 开始判断是路径还是文件:
100
  comments, total_token_used = reviewer1.review_by_chatgpt(paper_list=paper_pdf)
101
  time_used = time.time() - start_time
@@ -106,17 +108,13 @@ def main(api, review_format, paper_pdf, language):
106
 
107
  ########################################################################################################
108
  # 标题
109
- title = "🤖ChatReviewer🤖"
110
  # 描述
111
 
112
  description = '''<div align='left'>
113
- <img align='right' src='http://i.imgtg.com/2023/03/22/94PLN.png' width="270">
114
- <strong>ChatReviewer是一款基于ChatGPT-3.5的API开发的论文自动评审AI助手。</strong>其用途如下:
115
- ⭐️对论文进行快速总结和评审,提高科研人员的文献阅读和理解的效率,紧跟研究前沿。
116
- ⭐️对自己的论文进行评审,根据ChatReviewer生成的审稿意见进行查漏补缺,进一步提高自己的论文质量。
117
- ⭐️辅助论文审稿,给出参考意见,提高审稿效率和质量。(🈲:禁止直接复制生成的评论用于任何论文审稿工作!)
118
- 如果觉得很卡,可以点击右上角的Duplicate this Space,把ChatReviewer复制到你自己的Space中!
119
- 本项目的[Github](https://github.com/nishiwen1214/ChatReviewer),欢迎Star和Fork,也欢迎大佬赞助让本项目快速成长!💗([获取Api Key](https://chatgpt.cn.obiscr.com/blog/posts/2023/How-to-get-api-key/))
120
  </div>
121
  '''
122
 
@@ -124,31 +122,13 @@ description = '''<div align='left'>
124
  inp = [gradio.inputs.Textbox(label="请输入你的API-key(sk开头的字符串)",
125
  default="",
126
  type='password'),
127
- gradio.inputs.Textbox(lines=5,
128
- label="请输入特定的评审要求和格式(否则为默认格式)",
129
- default="""* Overall Review
130
- Please briefly summarize the main points and contributions of this paper.
131
- xxx
132
- * Paper Strength
133
- Please provide a list of the strengths of this paper, including but not limited to: innovative and practical methodology, insightful empirical findings or in-depth theoretical analysis,
134
- well-structured review of relevant literature, and any other factors that may make the paper valuable to readers. (Maximum length: 2,000 characters)
135
- (1) xxx
136
- (2) xxx
137
- (3) xxx
138
- * Paper Weakness
139
- Please provide a numbered list of your main concerns regarding this paper (so authors could respond to the concerns individually).
140
- These may include, but are not limited to: inadequate implementation details for reproducing the study, limited evaluation and ablation studies for the proposed method,
141
- correctness of the theoretical analysis or experimental results, lack of comparisons or discussions with widely-known baselines in the field, lack of clarity in exposition,
142
- or any other factors that may impede the reader's understanding or benefit from the paper. Please kindly refrain from providing a general assessment of the paper's novelty without providing detailed explanations. (Maximum length: 2,000 characters)
143
- (1) xxx
144
- (2) xxx
145
- (3) xxx
146
- * Questions To Authors And Suggestions For Rebuttal
147
- Please provide a numbered list of specific and clear questions that pertain to the details of the proposed method, evaluation setting, or additional results that would aid in supporting the authors' claims.
148
- The questions should be formulated in a manner that, after the authors have answered them during the rebuttal, it would enable a more thorough assessment of the paper's quality. (Maximum length: 2,000 characters)
149
- *Overall score (1-10)
150
- The paper is scored on a scale of 1-10, with 10 being the full mark, and 6 stands for borderline accept. Then give the reason for your rating.
151
- xxx"""
152
  ),
153
  gradio.inputs.File(label="请上传论文PDF(必填)",type="bytes"),
154
  gradio.inputs.Radio(choices=["English", "Chinese"],
@@ -156,11 +136,11 @@ xxx"""
156
  label="选择输出语言"),
157
  ]
158
 
159
- chat_reviewer_gui = gradio.Interface(fn=main,
160
  inputs=inp,
161
- outputs = [gradio.Textbox(lines=25, label="评审结果"), gradio.Textbox(lines=2, label="资源统计")],
162
  title=title,
163
  description=description)
164
 
165
  # Start server
166
- chat_reviewer_gui .launch(quiet=True, show_api=False)
 
15
  # 定义Reviewer类
16
  class Reviewer:
17
  # 初始化方法,设置属性
18
+ def __init__(self, api, research_field, question, paper_pdf, language):
19
  self.api = api
20
+ self.research_field = research_field
21
+ self.question = question
22
 
23
  self.language = language
24
  self.paper_pdf = paper_pdf
 
41
  review_prompt_token = 1000
42
  text_token = len(self.encoding.encode(text))
43
  input_text_index = int(len(text)*(self.max_token_num-review_prompt_token)/(text_token+1))
44
+ input_text = "This is the paper you are asked to read:" + text[:input_text_index]
45
+ input_text = input_text + "The question from your student is: " + self.question
46
  messages=[
47
+ {"role": "system", "content": "You are a professional researcher in the field of "+self.research_field+". You are the mentor of a student who is new to this field. Now I will give you a paper. You need to help your student to read this paper by instructing him to read the important sections in this paper and answer his questions towards these sections. Please answer in {}.".format(self.language),
48
  {"role": "user", "content": input_text},
49
  ]
50
 
 
90
  break
91
  return extracted_text
92
 
93
+ def main(api, research_field, question, paper_pdf, language):
94
  start_time = time.time()
95
+ if not api or not research_field or not question or not paper_pdf:
96
  return "请输入完整内容!"
97
  # 判断PDF文件
98
  else:
99
  # 创建一个Reader对象
100
+ reviewer1 = Reviewer(api, research_field, question, paper_pdf, language)
101
  # 开始判断是路径还是文件:
102
  comments, total_token_used = reviewer1.review_by_chatgpt(paper_list=paper_pdf)
103
  time_used = time.time() - start_time
 
108
 
109
  ########################################################################################################
110
  # 标题
111
+ title = "ChatAssistant: ChatGPT论文阅读助手"
112
  # 描述
113
 
114
  description = '''<div align='left'>
115
+ <strong>ChatAssistant是一款基于ChatGPT-3.5的API开发的论文阅读助手。</strong>其用途如下:
116
+ ⭐️针对用户对论文的内容所提出的问题,给出相关的解答或学习建议。
117
+ ([获取Api Key](https://chatgpt.cn.obiscr.com/blog/posts/2023/How-to-get-api-key/))
 
 
 
 
118
  </div>
119
  '''
120
 
 
122
  inp = [gradio.inputs.Textbox(label="请输入你的API-key(sk开头的字符串)",
123
  default="",
124
  type='password'),
125
+ gradio.inputs.Textbox(lines=3,
126
+ label="请输入论文的研究方向(语言和输出语言一致)",
127
+ default="""eg. computer science, artificial intelligence and transfer learning"""
128
+ ),
129
+ gradio.inputs.Textbox(lines=3,
130
+ label="请输入你的问题(语言和输出语言一致)。请尽可能地在问题之后概括你想要得到的输出的回答方向。",
131
+ default="""eg. What are the main contributions of this article? Please summarize the technical details in your reply as well."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  ),
133
  gradio.inputs.File(label="请上传论文PDF(必填)",type="bytes"),
134
  gradio.inputs.Radio(choices=["English", "Chinese"],
 
136
  label="选择输出语言"),
137
  ]
138
 
139
+ chat_assistant_gui = gradio.Interface(fn=main,
140
  inputs=inp,
141
+ outputs = [gradio.Textbox(lines=25, label="参考回答"), gradio.Textbox(lines=2, label="资源统计")],
142
  title=title,
143
  description=description)
144
 
145
  # Start server
146
+ chat_assistant_gui.launch(quiet=True, show_api=False)