ShiwenNi commited on
Commit
61ec197
1 Parent(s): ac6c166

修改token数可能超过4097的报错

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -20,7 +20,7 @@ class Reviewer:
20
 
21
  self.language = language
22
 
23
- self.max_token_num = 4096
24
  self.encoding = tiktoken.get_encoding("gpt2")
25
 
26
 
@@ -60,6 +60,9 @@ class Reviewer:
60
  except:
61
  pass
62
  text += 'Abstract: ' + paper_Abstract
 
 
 
63
  openai.api_key = self.api
64
  messages = [
65
  {"role": "system",
 
20
 
21
  self.language = language
22
 
23
+ self.max_token_num = 4097
24
  self.encoding = tiktoken.get_encoding("gpt2")
25
 
26
 
 
60
  except:
61
  pass
62
  text += 'Abstract: ' + paper_Abstract
63
+ text_token = len(self.encoding.encode(text))
64
+ input_text_index = int(len(text)*(self.max_token_num-1000)/text_token)
65
+ text = text[:input_text_index]
66
  openai.api_key = self.api
67
  messages = [
68
  {"role": "system",