Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
362b886
1
Parent(s):
51f18f8
feat: 默认隐藏 API 用量显示
Browse files- ChuanhuChatbot.py +2 -2
- config_example.json +4 -1
- modules/config.py +4 -1
ChuanhuChatbot.py
CHANGED
|
@@ -86,9 +86,9 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
| 86 |
label="API-Key",
|
| 87 |
)
|
| 88 |
if multi_api_key:
|
| 89 |
-
usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage_display", elem_classes="insert_block")
|
| 90 |
else:
|
| 91 |
-
usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage_display", elem_classes="insert_block")
|
| 92 |
model_select_dropdown = gr.Dropdown(
|
| 93 |
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
| 94 |
)
|
|
|
|
| 86 |
label="API-Key",
|
| 87 |
)
|
| 88 |
if multi_api_key:
|
| 89 |
+
usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage_display", elem_classes="insert_block", visible=show_api_billing)
|
| 90 |
else:
|
| 91 |
+
usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage_display", elem_classes="insert_block", visible=show_api_billing)
|
| 92 |
model_select_dropdown = gr.Dropdown(
|
| 93 |
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
| 94 |
)
|
config_example.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
| 3 |
|
| 4 |
//== API 配置 ==
|
| 5 |
"openai_api_key": "", // 你的 OpenAI API Key,一般必填,若空缺则需在图形界面中填入API Key
|
| 6 |
-
"sensitive_id": "", // 你 OpenAI 账户的 Sensitive ID,用于查询 API 用量
|
| 7 |
"usage_limit": 120, // 该 OpenAI API Key 的当月限额,单位:美元
|
| 8 |
"google_palm_api_key": "", // 你的 Google PaLM API Key,用于 Google PaLM 对话模型
|
| 9 |
"xmchat_api_key": "", // 你的 xmchat API Key,用于 XMChat 对话模型
|
|
@@ -18,6 +17,10 @@
|
|
| 18 |
"check_update": true, //是否启用检查更新
|
| 19 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
//== 川虎助理设置 ==
|
| 22 |
"default_chuanhu_assistant_model": "gpt-4", //川虎助理使用的模型,可选gpt-3.5-turbo或者gpt-4等
|
| 23 |
"GOOGLE_CSE_ID": "", //谷歌搜索引擎ID,用于川虎助理Pro模式,获取方式请看 https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search
|
|
|
|
| 3 |
|
| 4 |
//== API 配置 ==
|
| 5 |
"openai_api_key": "", // 你的 OpenAI API Key,一般必填,若空缺则需在图形界面中填入API Key
|
|
|
|
| 6 |
"usage_limit": 120, // 该 OpenAI API Key 的当月限额,单位:美元
|
| 7 |
"google_palm_api_key": "", // 你的 Google PaLM API Key,用于 Google PaLM 对话模型
|
| 8 |
"xmchat_api_key": "", // 你的 xmchat API Key,用于 XMChat 对话模型
|
|
|
|
| 17 |
"check_update": true, //是否启用检查更新
|
| 18 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
| 19 |
|
| 20 |
+
//== API 用量 ==
|
| 21 |
+
"show_api_billing": false, //是否显示OpenAI API用量(启用需要填写sensitive_id)
|
| 22 |
+
"sensitive_id": "", // 你 OpenAI 账户的 Sensitive ID,用于查询 API 用量
|
| 23 |
+
|
| 24 |
//== 川虎助理设置 ==
|
| 25 |
"default_chuanhu_assistant_model": "gpt-4", //川虎助理使用的模型,可选gpt-3.5-turbo或者gpt-4等
|
| 26 |
"GOOGLE_CSE_ID": "", //谷歌搜索引擎ID,用于川虎助理Pro模式,获取方式请看 https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search
|
modules/config.py
CHANGED
|
@@ -27,7 +27,8 @@ __all__ = [
|
|
| 27 |
"check_update",
|
| 28 |
"latex_delimiters_set",
|
| 29 |
"hide_history_when_not_logged_in",
|
| 30 |
-
"default_chuanhu_assistant_model"
|
|
|
|
| 31 |
]
|
| 32 |
|
| 33 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
|
@@ -46,6 +47,8 @@ language = os.environ.get("LANGUAGE", lang_config)
|
|
| 46 |
|
| 47 |
hide_history_when_not_logged_in = config.get("hide_history_when_not_logged_in", False)
|
| 48 |
check_update = config.get("check_update", True)
|
|
|
|
|
|
|
| 49 |
|
| 50 |
if os.path.exists("api_key.txt"):
|
| 51 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|
|
|
|
| 27 |
"check_update",
|
| 28 |
"latex_delimiters_set",
|
| 29 |
"hide_history_when_not_logged_in",
|
| 30 |
+
"default_chuanhu_assistant_model",
|
| 31 |
+
"show_api_billing"
|
| 32 |
]
|
| 33 |
|
| 34 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
|
|
|
| 47 |
|
| 48 |
hide_history_when_not_logged_in = config.get("hide_history_when_not_logged_in", False)
|
| 49 |
check_update = config.get("check_update", True)
|
| 50 |
+
show_api_billing = config.get("show_api_billing", False)
|
| 51 |
+
show_api_billing = bool(os.environ.get("SHOW_API_BILLING", show_api_billing))
|
| 52 |
|
| 53 |
if os.path.exists("api_key.txt"):
|
| 54 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|