Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
3646bb0
1
Parent(s):
4283a5e
增加了一个config选项,用于控制是否在用户未登录时展示历史对话记录
Browse files- config_example.json +1 -0
- modules/config.py +3 -0
- modules/utils.py +2 -2
config_example.json
CHANGED
@@ -12,6 +12,7 @@
|
|
12 |
"render_latex": false,
|
13 |
"users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
|
14 |
"local_embedding": false, //是否在本地编制索引
|
|
|
15 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
16 |
"advance_docs": {
|
17 |
"pdf": {
|
|
|
12 |
"render_latex": false,
|
13 |
"users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
|
14 |
"local_embedding": false, //是否在本地编制索引
|
15 |
+
"hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
|
16 |
"default_model": "gpt-3.5-turbo", // 默认模型
|
17 |
"advance_docs": {
|
18 |
"pdf": {
|
modules/config.py
CHANGED
@@ -23,6 +23,7 @@ __all__ = [
|
|
23 |
"server_name",
|
24 |
"server_port",
|
25 |
"share",
|
|
|
26 |
]
|
27 |
|
28 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
@@ -36,6 +37,8 @@ else:
|
|
36 |
lang_config = config.get("language", "auto")
|
37 |
language = os.environ.get("LANGUAGE", lang_config)
|
38 |
|
|
|
|
|
39 |
if os.path.exists("api_key.txt"):
|
40 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|
41 |
with open("api_key.txt", "r") as f:
|
|
|
23 |
"server_name",
|
24 |
"server_port",
|
25 |
"share",
|
26 |
+
"hide_history_when_not_logged_in"
|
27 |
]
|
28 |
|
29 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
|
|
37 |
lang_config = config.get("language", "auto")
|
38 |
language = os.environ.get("LANGUAGE", lang_config)
|
39 |
|
40 |
+
hide_history_when_not_logged_in = config.get("hide_history_when_not_logged_in", False)
|
41 |
+
|
42 |
if os.path.exists("api_key.txt"):
|
43 |
logging.info("检测到api_key.txt文件,正在进行迁移...")
|
44 |
with open("api_key.txt", "r") as f:
|
modules/utils.py
CHANGED
@@ -25,7 +25,7 @@ import pandas as pd
|
|
25 |
|
26 |
from modules.presets import *
|
27 |
from . import shared
|
28 |
-
from modules.config import retrieve_proxy
|
29 |
|
30 |
if TYPE_CHECKING:
|
31 |
from typing import TypedDict
|
@@ -286,7 +286,7 @@ def get_file_names(dir, plain=False, filetypes=[".json"]):
|
|
286 |
|
287 |
def get_history_names(plain=False, user_name=""):
|
288 |
logging.debug(f"从用户 {user_name} 中获取历史记录文件名列表")
|
289 |
-
if user_name == "":
|
290 |
return ""
|
291 |
else:
|
292 |
return get_file_names(os.path.join(HISTORY_DIR, user_name), plain)
|
|
|
25 |
|
26 |
from modules.presets import *
|
27 |
from . import shared
|
28 |
+
from modules.config import retrieve_proxy, hide_history_when_not_logged_in
|
29 |
|
30 |
if TYPE_CHECKING:
|
31 |
from typing import TypedDict
|
|
|
286 |
|
287 |
def get_history_names(plain=False, user_name=""):
|
288 |
logging.debug(f"从用户 {user_name} 中获取历史记录文件名列表")
|
289 |
+
if user_name == "" and hide_history_when_not_logged_in:
|
290 |
return ""
|
291 |
else:
|
292 |
return get_file_names(os.path.join(HISTORY_DIR, user_name), plain)
|