Spaces:
Sleeping
Sleeping
feat: 可以使用配置文件控制默认自动命名行为
Browse files- ChuanhuChatbot.py +1 -1
- config_example.json +1 -0
- modules/config.py +4 -2
ChuanhuChatbot.py
CHANGED
@@ -376,7 +376,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
376 |
choices=HISTORY_NAME_METHODS,
|
377 |
multiselect=False,
|
378 |
interactive=True,
|
379 |
-
value=HISTORY_NAME_METHODS[
|
380 |
)
|
381 |
single_turn_checkbox = gr.Checkbox(label=i18n(
|
382 |
"单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
|
|
|
376 |
choices=HISTORY_NAME_METHODS,
|
377 |
multiselect=False,
|
378 |
interactive=True,
|
379 |
+
value=HISTORY_NAME_METHODS[chat_name_method_index],
|
380 |
)
|
381 |
single_turn_checkbox = gr.Checkbox(label=i18n(
|
382 |
"单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
|
config_example.json
CHANGED
@@ -32,6 +32,7 @@
|
|
32 |
"hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
|
33 |
"check_update": true, //是否启用检查更新
|
34 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
|
|
35 |
"bot_avatar": "default", // 机器人头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
36 |
"user_avatar": "default", // 用户头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
37 |
|
|
|
32 |
"hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
|
33 |
"check_update": true, //是否启用检查更新
|
34 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
35 |
+
"chat_name_method_index": 0, // 选择对话名称的方法。0: 使用日期时间命名;1: 使用第一条提问命名,2: 使用模型自动总结
|
36 |
"bot_avatar": "default", // 机器人头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
37 |
"user_avatar": "default", // 用户头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
38 |
|
modules/config.py
CHANGED
@@ -27,7 +27,8 @@ __all__ = [
|
|
27 |
"latex_delimiters_set",
|
28 |
"hide_history_when_not_logged_in",
|
29 |
"default_chuanhu_assistant_model",
|
30 |
-
"show_api_billing"
|
|
|
31 |
]
|
32 |
|
33 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
@@ -50,6 +51,7 @@ hide_history_when_not_logged_in = config.get(
|
|
50 |
check_update = config.get("check_update", True)
|
51 |
show_api_billing = config.get("show_api_billing", False)
|
52 |
show_api_billing = bool(os.environ.get("SHOW_API_BILLING", show_api_billing))
|
|
|
53 |
|
54 |
if os.path.exists("api_key.txt"):
|
55 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|
@@ -288,4 +290,4 @@ elif bot_avatar == "default":
|
|
288 |
if user_avatar == "" or user_avatar == "none" or user_avatar is None:
|
289 |
user_avatar = None
|
290 |
elif user_avatar == "default":
|
291 |
-
user_avatar = "web_assets/user.png"
|
|
|
27 |
"latex_delimiters_set",
|
28 |
"hide_history_when_not_logged_in",
|
29 |
"default_chuanhu_assistant_model",
|
30 |
+
"show_api_billing",
|
31 |
+
"chat_name_method_index",
|
32 |
]
|
33 |
|
34 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
|
|
51 |
check_update = config.get("check_update", True)
|
52 |
show_api_billing = config.get("show_api_billing", False)
|
53 |
show_api_billing = bool(os.environ.get("SHOW_API_BILLING", show_api_billing))
|
54 |
+
chat_name_method_index = config.get("chat_name_method_index", 0)
|
55 |
|
56 |
if os.path.exists("api_key.txt"):
|
57 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|
|
|
290 |
if user_avatar == "" or user_avatar == "none" or user_avatar is None:
|
291 |
user_avatar = None
|
292 |
elif user_avatar == "default":
|
293 |
+
user_avatar = "web_assets/user.png"
|