Skip to content

Commit 5e48fc9

Browse files
committed
添加本地缓存删除功能
1 parent 2ff8dc7 commit 5e48fc9

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

crazy_functional.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_crazy_functions():
2424
from crazy_functions.对话历史存档 import 对话历史存档
2525
from crazy_functions.对话历史存档 import 载入对话历史存档
2626
from crazy_functions.对话历史存档 import 删除所有本地对话历史记录
27+
from crazy_functions.辅助功能 import 清除缓存
2728

2829
from crazy_functions.批量Markdown翻译 import Markdown英译中
2930
function_plugins = {
@@ -40,7 +41,12 @@ def get_crazy_functions():
4041
"AsButton":False,
4142
"Function": HotReload(删除所有本地对话历史记录)
4243
},
43-
"[测试功能] 解析Jupyter Notebook文件": {
44+
"清除所有缓存文件(请谨慎操作)": {
45+
"Color": "stop",
46+
"AsButton": False, # 加入下拉菜单中
47+
"Function": HotReload(清除缓存)
48+
},
49+
"解析Jupyter Notebook文件": {
4450
"Color": "stop",
4551
"AsButton":False,
4652
"Function": HotReload(解析ipynb文件),
@@ -328,7 +334,7 @@ def get_crazy_functions():
328334
try:
329335
from crazy_functions.Langchain知识库 import 知识库问答
330336
function_plugins.update({
331-
"[功能尚不稳定] 构建知识库(请先上传文件素材)": {
337+
"构建知识库(请先上传文件素材)": {
332338
"Color": "stop",
333339
"AsButton": False,
334340
"AdvancedArgs": True,
@@ -342,7 +348,7 @@ def get_crazy_functions():
342348
try:
343349
from crazy_functions.Langchain知识库 import 读取知识库作答
344350
function_plugins.update({
345-
"[功能尚不稳定] 知识库问答": {
351+
"知识库问答": {
346352
"Color": "stop",
347353
"AsButton": False,
348354
"AdvancedArgs": True,

crazy_functions/辅助回答.py renamed to crazy_functions/辅助功能.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @Author : Spike
44
# @Descr :
55
from toolbox import update_ui
6-
from toolbox import CatchException, report_execption, write_results_to_file
6+
from toolbox import CatchException, report_execption, write_results_to_file, get_log_folder
77
from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
88

99

@@ -25,4 +25,19 @@ def 猜你想问(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
2525
)
2626
chatbot[-1] = (show_say, gpt_say)
2727
history.extend([show_say, gpt_say])
28+
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
29+
30+
31+
@CatchException
32+
def 清除缓存(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
33+
chatbot.append(['清除本地缓存数据', '执行中. 删除 gpt_log & private_upload'])
34+
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
35+
36+
import shutil, os
37+
gpt_log_dir = os.path.join(os.path.dirname(__file__), '..', 'gpt_log')
38+
private_upload_dir = os.path.join(os.path.dirname(__file__), '..', 'private_upload')
39+
shutil.rmtree(gpt_log_dir, ignore_errors=True)
40+
shutil.rmtree(private_upload_dir, ignore_errors=True)
41+
42+
chatbot.append(['清除本地缓存数据', '执行完成'])
2843
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面

0 commit comments

Comments
 (0)