Spaces:
Sleeping
Sleeping
Chuan Hu
commited on
Commit
•
d8bce62
1
Parent(s):
fcf354f
Update ChuanhuChatbot.py
Browse files- ChuanhuChatbot.py +3 -0
ChuanhuChatbot.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import openai
|
4 |
import os
|
5 |
import sys
|
|
|
6 |
# import markdown
|
7 |
|
8 |
my_api_key = "" # 在这里输入你的 API 密钥
|
@@ -133,6 +134,8 @@ def set_apikey(new_api_key, myKey):
|
|
133 |
try:
|
134 |
get_response(update_system(initial_prompt), [{"role": "user", "content": "test"}], new_api_key)
|
135 |
except:
|
|
|
|
|
136 |
return "无效的api-key", myKey
|
137 |
encryption_str = "验证成功,api-key已做遮挡处理:" + new_api_key[:4] + "..." + new_api_key[-4:]
|
138 |
return encryption_str, new_api_key
|
|
|
3 |
import openai
|
4 |
import os
|
5 |
import sys
|
6 |
+
import traceback
|
7 |
# import markdown
|
8 |
|
9 |
my_api_key = "" # 在这里输入你的 API 密钥
|
|
|
134 |
try:
|
135 |
get_response(update_system(initial_prompt), [{"role": "user", "content": "test"}], new_api_key)
|
136 |
except:
|
137 |
+
traceback.print_exc()
|
138 |
+
print("API key校验失败,请检查API key是否正确,或者检查网络是否畅通。")
|
139 |
return "无效的api-key", myKey
|
140 |
encryption_str = "验证成功,api-key已做遮挡处理:" + new_api_key[:4] + "..." + new_api_key[-4:]
|
141 |
return encryption_str, new_api_key
|