lihuayong commited on
Commit
dc009cb
1 Parent(s): e4add67

lhy: update openai models 2023-11-06

Browse files
Files changed (1) hide show
  1. modules/presets.py +79 -76
modules/presets.py CHANGED
@@ -15,8 +15,8 @@ LLAMA_INFERENCER = None
15
  INITIAL_SYSTEM_PROMPT = "You are a helpful assistant."
16
  API_HOST = "api.openai.com"
17
  COMPLETION_URL = "https://api.openai.com/v1/chat/completions"
18
- BALANCE_API_URL="https://api.openai.com/dashboard/billing/credit_grants"
19
- USAGE_API_URL="https://api.openai.com/dashboard/billing/usage"
20
  HISTORY_DIR = Path("history")
21
  HISTORY_DIR = "history"
22
  TEMPLATES_DIR = "templates"
@@ -31,23 +31,25 @@ PROXY_ERROR_MSG = i18n("代理错误,无法获取对话。") # 代理错误
31
  SSL_ERROR_PROMPT = i18n("SSL错误,无法获取对话。") # SSL 错误
32
  NO_APIKEY_MSG = i18n("API key为空,请检查是否输入正确。") # API key 长度不足 51 位
33
  NO_INPUT_MSG = i18n("请输入对话内容。") # 未输入对话内容
34
- BILLING_NOT_APPLICABLE_MSG = i18n("账单信息不适用") # 本地运行的模型返回的账单信息
35
 
36
  TIMEOUT_STREAMING = 60 # 流式对话时的超时时间
37
  TIMEOUT_ALL = 200 # 非流式对话时的超时时间
38
  ENABLE_STREAMING_OPTION = True # 是否启用选择选择是否实时显示回答的勾选框
39
  HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
40
- CONCURRENT_COUNT = 100 # 允许同时使用的用户数量
41
 
42
  SIM_K = 5
43
  INDEX_QUERY_TEMPRATURE = 1.0
44
 
45
  CHUANHU_TITLE = i18n("川虎Chat 🚀")
46
 
47
- CHUANHU_DESCRIPTION = i18n("由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本")
48
-
49
 
50
  ONLINE_MODELS = [
 
 
51
  "gpt-3.5-turbo",
52
  "gpt-3.5-turbo-16k",
53
  "gpt-3.5-turbo-0301",
@@ -97,6 +99,8 @@ for dir_name in os.listdir("models"):
97
  MODELS.append(dir_name)
98
 
99
  MODEL_TOKEN_LIMIT = {
 
 
100
  "gpt-3.5-turbo": 4096,
101
  "gpt-3.5-turbo-16k": 16384,
102
  "gpt-3.5-turbo-0301": 4096,
@@ -109,9 +113,9 @@ MODEL_TOKEN_LIMIT = {
109
  "gpt-4-32k-0613": 32768
110
  }
111
 
112
- TOKEN_OFFSET = 1000 # 模型的token上限减去这个值,得到软上限。到达软上限之后,自动尝试减少token占用。
113
- DEFAULT_TOKEN_LIMIT = 3000 # 默认的token上限
114
- REDUCE_TOKEN_FACTOR = 0.5 # 与模型token上限想乘,得到目标token数。减少token占用时,将token占用减少到目标token数以下。
115
 
116
  REPLY_LANGUAGES = [
117
  "简体中文",
@@ -124,7 +128,6 @@ REPLY_LANGUAGES = [
124
  "跟随问题语言(不稳定)"
125
  ]
126
 
127
-
128
  WEBSEARCH_PTOMPT_TEMPLATE = """\
129
  Web search results:
130
 
@@ -172,69 +175,69 @@ CONCISE SUMMARY IN 中文:"""
172
  ALREADY_CONVERTED_MARK = "<!-- ALREADY CONVERTED BY PARSER. -->"
173
 
174
  small_and_beautiful_theme = gr.themes.Soft(
175
- primary_hue=gr.themes.Color(
176
- c50="#EBFAF2",
177
- c100="#CFF3E1",
178
- c200="#A8EAC8",
179
- c300="#77DEA9",
180
- c400="#3FD086",
181
- c500="#02C160",
182
- c600="#06AE56",
183
- c700="#05974E",
184
- c800="#057F45",
185
- c900="#04673D",
186
- c950="#2E5541",
187
- name="small_and_beautiful",
188
- ),
189
- secondary_hue=gr.themes.Color(
190
- c50="#576b95",
191
- c100="#576b95",
192
- c200="#576b95",
193
- c300="#576b95",
194
- c400="#576b95",
195
- c500="#576b95",
196
- c600="#576b95",
197
- c700="#576b95",
198
- c800="#576b95",
199
- c900="#576b95",
200
- c950="#576b95",
201
- ),
202
- neutral_hue=gr.themes.Color(
203
- name="gray",
204
- c50="#f6f7f8",
205
- # c100="#f3f4f6",
206
- c100="#F2F2F2",
207
- c200="#e5e7eb",
208
- c300="#d1d5db",
209
- c400="#B2B2B2",
210
- c500="#808080",
211
- c600="#636363",
212
- c700="#515151",
213
- c800="#393939",
214
- # c900="#272727",
215
- c900="#2B2B2B",
216
- c950="#171717",
217
- ),
218
- radius_size=gr.themes.sizes.radius_sm,
219
- ).set(
220
- # button_primary_background_fill="*primary_500",
221
- button_primary_background_fill_dark="*primary_600",
222
- # button_primary_background_fill_hover="*primary_400",
223
- # button_primary_border_color="*primary_500",
224
- button_primary_border_color_dark="*primary_600",
225
- button_primary_text_color="wihte",
226
- button_primary_text_color_dark="white",
227
- button_secondary_background_fill="*neutral_100",
228
- button_secondary_background_fill_hover="*neutral_50",
229
- button_secondary_background_fill_dark="*neutral_900",
230
- button_secondary_text_color="*neutral_800",
231
- button_secondary_text_color_dark="white",
232
- # background_fill_primary="#F7F7F7",
233
- # background_fill_primary_dark="#1F1F1F",
234
- # block_title_text_color="*primary_500",
235
- block_title_background_fill_dark="*primary_900",
236
- block_label_background_fill_dark="*primary_900",
237
- input_background_fill="#F6F6F6",
238
- chatbot_code_background_color="*neutral_950",
239
- chatbot_code_background_color_dark="*neutral_950",
240
- )
 
15
  INITIAL_SYSTEM_PROMPT = "You are a helpful assistant."
16
  API_HOST = "api.openai.com"
17
  COMPLETION_URL = "https://api.openai.com/v1/chat/completions"
18
+ BALANCE_API_URL = "https://api.openai.com/dashboard/billing/credit_grants"
19
+ USAGE_API_URL = "https://api.openai.com/dashboard/billing/usage"
20
  HISTORY_DIR = Path("history")
21
  HISTORY_DIR = "history"
22
  TEMPLATES_DIR = "templates"
 
31
  SSL_ERROR_PROMPT = i18n("SSL错误,无法获取对话。") # SSL 错误
32
  NO_APIKEY_MSG = i18n("API key为空,请检查是否输入正确。") # API key 长度不足 51 位
33
  NO_INPUT_MSG = i18n("请输入对话内容。") # 未输入对话内容
34
+ BILLING_NOT_APPLICABLE_MSG = i18n("账单信息不适用") # 本地运行的模型返回的账单信息
35
 
36
  TIMEOUT_STREAMING = 60 # 流式对话时的超时时间
37
  TIMEOUT_ALL = 200 # 非流式对话时的超时时间
38
  ENABLE_STREAMING_OPTION = True # 是否启用选择选择是否实时显示回答的勾选框
39
  HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
40
+ CONCURRENT_COUNT = 100 # 允许同时使用的用户数量
41
 
42
  SIM_K = 5
43
  INDEX_QUERY_TEMPRATURE = 1.0
44
 
45
  CHUANHU_TITLE = i18n("川虎Chat 🚀")
46
 
47
+ CHUANHU_DESCRIPTION = i18n(
48
+ "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本")
49
 
50
  ONLINE_MODELS = [
51
+ "gpt-3.5-turbo-1106",
52
+ "gpt-4-1106-preview",
53
  "gpt-3.5-turbo",
54
  "gpt-3.5-turbo-16k",
55
  "gpt-3.5-turbo-0301",
 
99
  MODELS.append(dir_name)
100
 
101
  MODEL_TOKEN_LIMIT = {
102
+ "gpt-3.5-turbo-1106": 16385,
103
+ "gpt-4-1106-preview": 128000,
104
  "gpt-3.5-turbo": 4096,
105
  "gpt-3.5-turbo-16k": 16384,
106
  "gpt-3.5-turbo-0301": 4096,
 
113
  "gpt-4-32k-0613": 32768
114
  }
115
 
116
+ TOKEN_OFFSET = 1000 # 模型的token上限减去这个值,得到软上限。到达软上限之后,自动尝试减少token占用。
117
+ DEFAULT_TOKEN_LIMIT = 3000 # 默认的token上限
118
+ REDUCE_TOKEN_FACTOR = 0.5 # 与模型token上限想乘,得到目标token数。减少token占用时,将token占用减少到目标token数以下。
119
 
120
  REPLY_LANGUAGES = [
121
  "简体中文",
 
128
  "跟随问题语言(不稳定)"
129
  ]
130
 
 
131
  WEBSEARCH_PTOMPT_TEMPLATE = """\
132
  Web search results:
133
 
 
175
  ALREADY_CONVERTED_MARK = "<!-- ALREADY CONVERTED BY PARSER. -->"
176
 
177
  small_and_beautiful_theme = gr.themes.Soft(
178
+ primary_hue=gr.themes.Color(
179
+ c50="#EBFAF2",
180
+ c100="#CFF3E1",
181
+ c200="#A8EAC8",
182
+ c300="#77DEA9",
183
+ c400="#3FD086",
184
+ c500="#02C160",
185
+ c600="#06AE56",
186
+ c700="#05974E",
187
+ c800="#057F45",
188
+ c900="#04673D",
189
+ c950="#2E5541",
190
+ name="small_and_beautiful",
191
+ ),
192
+ secondary_hue=gr.themes.Color(
193
+ c50="#576b95",
194
+ c100="#576b95",
195
+ c200="#576b95",
196
+ c300="#576b95",
197
+ c400="#576b95",
198
+ c500="#576b95",
199
+ c600="#576b95",
200
+ c700="#576b95",
201
+ c800="#576b95",
202
+ c900="#576b95",
203
+ c950="#576b95",
204
+ ),
205
+ neutral_hue=gr.themes.Color(
206
+ name="gray",
207
+ c50="#f6f7f8",
208
+ # c100="#f3f4f6",
209
+ c100="#F2F2F2",
210
+ c200="#e5e7eb",
211
+ c300="#d1d5db",
212
+ c400="#B2B2B2",
213
+ c500="#808080",
214
+ c600="#636363",
215
+ c700="#515151",
216
+ c800="#393939",
217
+ # c900="#272727",
218
+ c900="#2B2B2B",
219
+ c950="#171717",
220
+ ),
221
+ radius_size=gr.themes.sizes.radius_sm,
222
+ ).set(
223
+ # button_primary_background_fill="*primary_500",
224
+ button_primary_background_fill_dark="*primary_600",
225
+ # button_primary_background_fill_hover="*primary_400",
226
+ # button_primary_border_color="*primary_500",
227
+ button_primary_border_color_dark="*primary_600",
228
+ button_primary_text_color="wihte",
229
+ button_primary_text_color_dark="white",
230
+ button_secondary_background_fill="*neutral_100",
231
+ button_secondary_background_fill_hover="*neutral_50",
232
+ button_secondary_background_fill_dark="*neutral_900",
233
+ button_secondary_text_color="*neutral_800",
234
+ button_secondary_text_color_dark="white",
235
+ # background_fill_primary="#F7F7F7",
236
+ # background_fill_primary_dark="#1F1F1F",
237
+ # block_title_text_color="*primary_500",
238
+ block_title_background_fill_dark="*primary_900",
239
+ block_label_background_fill_dark="*primary_900",
240
+ input_background_fill="#F6F6F6",
241
+ chatbot_code_background_color="*neutral_950",
242
+ chatbot_code_background_color_dark="*neutral_950",
243
+ )