ShiwenNi commited on
Commit
4f84118
1 Parent(s): 741f19d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -25,12 +25,12 @@ class Response:
25
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
26
  stop=tenacity.stop_after_attempt(5),
27
  reraise=True)
28
- def chat_response(self):
29
  openai.api_key = self.api
30
  response_prompt_token = 1000
31
- text_token = len(self.encoding.encode(self.comment))
32
- input_text_index = int(len(self.comment)*(self.max_token_num-response_prompt_token)/text_token)
33
- input_text = "This is the review comments:" + self.comment[:input_text_index]
34
  messages=[
35
  {"role": "system", "content": """You are the author, you submitted a paper, and the reviewers gave the review comments.
36
  Please reply with what we have done, not what we will do.
@@ -87,7 +87,7 @@ def main(api, comment, language):
87
  else:
88
  Response1 = Response(api, comment, language)
89
  # 开始判断是路径还是文件:
90
- response, total_token_used = Response1.chat_response()
91
  time_used = time.time() - start_time
92
  output2 ="使用token数:"+ str(total_token_used)+"\n花费时间:"+ str(round(time_used, 2)) +"秒"
93
  return response, output2
 
25
  @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10),
26
  stop=tenacity.stop_after_attempt(5),
27
  reraise=True)
28
+ def chat_response(self, comment):
29
  openai.api_key = self.api
30
  response_prompt_token = 1000
31
+ text_token = len(self.encoding.encode(comment))
32
+ input_text_index = int(len(comment)*(self.max_token_num-response_prompt_token)/text_token)
33
+ input_text = "This is the review comments:" + comment[:input_text_index]
34
  messages=[
35
  {"role": "system", "content": """You are the author, you submitted a paper, and the reviewers gave the review comments.
36
  Please reply with what we have done, not what we will do.
 
87
  else:
88
  Response1 = Response(api, comment, language)
89
  # 开始判断是路径还是文件:
90
+ response, total_token_used = Response1.chat_response(comment)
91
  time_used = time.time() - start_time
92
  output2 ="使用token数:"+ str(total_token_used)+"\n花费时间:"+ str(round(time_used, 2)) +"秒"
93
  return response, output2