Spaces:
Runtime error
Runtime error
修改token数可能超过4097的报错
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ class Reviewer:
|
|
20 |
|
21 |
self.language = language
|
22 |
|
23 |
-
self.max_token_num =
|
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",
|