Skip to content

Commit

Permalink
添加本地缓存删除功能
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-sky committed Aug 16, 2023
1 parent 2ff8dc7 commit 5e48fc9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 9 additions & 3 deletions crazy_functional.py
Expand Up @@ -24,6 +24,7 @@ def get_crazy_functions():
from crazy_functions.对话历史存档 import 对话历史存档
from crazy_functions.对话历史存档 import 载入对话历史存档
from crazy_functions.对话历史存档 import 删除所有本地对话历史记录
from crazy_functions.辅助功能 import 清除缓存

from crazy_functions.批量Markdown翻译 import Markdown英译中
function_plugins = {
Expand All @@ -40,7 +41,12 @@ def get_crazy_functions():
"AsButton":False,
"Function": HotReload(删除所有本地对话历史记录)
},
"[测试功能] 解析Jupyter Notebook文件": {
"清除所有缓存文件(请谨慎操作)": {
"Color": "stop",
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(清除缓存)
},
"解析Jupyter Notebook文件": {
"Color": "stop",
"AsButton":False,
"Function": HotReload(解析ipynb文件),
Expand Down Expand Up @@ -328,7 +334,7 @@ def get_crazy_functions():
try:
from crazy_functions.Langchain知识库 import 知识库问答
function_plugins.update({
"[功能尚不稳定] 构建知识库(请先上传文件素材)": {
"构建知识库(请先上传文件素材)": {
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True,
Expand All @@ -342,7 +348,7 @@ def get_crazy_functions():
try:
from crazy_functions.Langchain知识库 import 读取知识库作答
function_plugins.update({
"[功能尚不稳定] 知识库问答": {
"知识库问答": {
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True,
Expand Down
Expand Up @@ -3,7 +3,7 @@
# @Author : Spike
# @Descr :
from toolbox import update_ui
from toolbox import CatchException, report_execption, write_results_to_file
from toolbox import CatchException, report_execption, write_results_to_file, get_log_folder
from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive


Expand All @@ -25,4 +25,19 @@ def 猜你想问(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
)
chatbot[-1] = (show_say, gpt_say)
history.extend([show_say, gpt_say])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面


@CatchException
def 清除缓存(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
chatbot.append(['清除本地缓存数据', '执行中. 删除 gpt_log & private_upload'])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面

import shutil, os
gpt_log_dir = os.path.join(os.path.dirname(__file__), '..', 'gpt_log')
private_upload_dir = os.path.join(os.path.dirname(__file__), '..', 'private_upload')
shutil.rmtree(gpt_log_dir, ignore_errors=True)
shutil.rmtree(private_upload_dir, ignore_errors=True)

chatbot.append(['清除本地缓存数据', '执行完成'])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面

0 comments on commit 5e48fc9

Please sign in to comment.