diff --git a/docs/translate_english.json b/docs/translate_english.json index 91ffaa8..91eba9d 100644 --- a/docs/translate_english.json +++ b/docs/translate_english.json @@ -2443,48 +2443,75 @@ "├── CODE_HIGHLIGHT 代码高亮": "├── CODE_HIGHLIGHT Code highlighting", "记得用插件": "Remember to use the plugin", "谨慎操作": "Handle with caution", - "请检查PDF是否损坏": "#", - "执行成功了": "#", - "请在输入框内填写需求": "#", - "结果": "#", - "开始干正事": "#", - "次代码生成尝试": "#", - "代码生成结束": "#", - "Nougat解析论文失败": "#", - "受到google限制": "#", - "收尾": "#", - "结果是一个有效文件": "#", - "然后再次点击该插件": "#", - "用插件实现」": "#", - "文件路径": "#", - "仅供测试": "#", - "将csv文件转excel表格": "#", - "开始执行": "#", - "测试": "#", - "睡一会防止触发google反爬虫": "#", - "某段话的整个句子": "#", - "使用tex格式公式 测试2 给出柯西不等式": "#", - "找不到本地项目或无法处理": "#", - "交换图像的蓝色通道和红色通道": "#", - "第三步": "#", - "返回给定的url解析出的arxiv_id": "#", - "裁剪图像": "#", - "已经被记忆": "#", - "无法从bing获取信息!": "#", - "可能触发了google反爬虫机制": "#", - "检索文章的历史版本的题目": "#", - "请配置讯飞星火大模型的XFYUN_APPID": "#", - "执行失败了": "#", - "需要花费较长时间下载NOUGAT参数": "#", - "请检查": "#", - "写入": "#", - "下个句子中已经说完的部分": "#", - "精准翻译PDF文档": "#", - "解析python源代码项目": "#", - "首先在arxiv上搜索": "#", - "错误追踪": "#", - "结果是一个字符串": "#", - "由 test_on_sentence_end": "#", - "获取文章摘要": "#", - "受到bing限制": "#" + "private_upload里面的文件名在解压zip后容易出现乱码": "The file name inside private_upload is prone to garbled characters after unzipping", + "直接返回报错": "Direct return error", + "临时的上传文件夹位置": "Temporary upload folder location", + "使用latex格式 测试3 写出麦克斯韦方程组": "Write Maxwell's equations using latex format for test 3", + "这是一张图片": "This is an image", + "没有发现任何近期上传的文件": "No recent uploaded files found", + "如url未成功匹配返回None": "Return None if the URL does not match successfully", + "如果有Latex环境": "If there is a Latex environment", + "第一次运行时": "When running for the first time", + "创建工作路径": "Create a working directory", + "向": "To", + "执行中. 删除数据": "Executing. Deleting data", + "CodeInterpreter开源版": "CodeInterpreter open source version", + "建议选择更稳定的接口": "It is recommended to choose a more stable interface", + "现在您点击任意函数插件时": "Now when you click on any function plugin", + "请使用“LatexEnglishCorrection+高亮”插件": "Please use the 'LatexEnglishCorrection+Highlight' plugin", + "安装完成": "Installation completed", + "记得用插件!」": "Remember to use the plugin!", + "结论": "Conclusion", + "无法下载资源": "Unable to download resources", + "首先排除一个one-api没有done数据包的第三方Bug情形": "First exclude a third-party bug where one-api does not have a done data package", + "知识库中添加文件": "Add files to the knowledge base", + "处理重名的章节": "Handling duplicate chapter names", + "先上传文件素材": "Upload file materials first", + "无法从google获取信息!": "Unable to retrieve information from Google!", + "展示如下": "Display as follows", + "「把Arxiv论文翻译成中文PDF": "Translate Arxiv papers into Chinese PDF", + "论文我刚刚放到上传区了」": "I just put the paper in the upload area", + "正在下载Gradio主题": "Downloading Gradio themes", + "再运行此插件": "Run this plugin again", + "记录近期文件": "Record recent files", + "粗心检查": "Careful check", + "更多主题": "More themes", + "//huggingface.co/spaces/gradio/theme-gallery 可选": "//huggingface.co/spaces/gradio/theme-gallery optional", + "由 test_on_result_chg": "By test_on_result_chg", + "所有问询记录将自动保存在本地目录./": "All inquiry records will be automatically saved in the local directory ./", + "正在解析论文": "Analyzing the paper", + "逐个文件转移到目标路径": "Move each file to the target path", + "最多重试5次": "Retry up to 5 times", + "日志文件夹的位置": "Location of the log folder", + "我们暂时无法解析此PDF文档": "We are temporarily unable to parse this PDF document", + "文件检索": "File retrieval", + "/**/chatGPT对话历史*.html": "/**/chatGPT conversation history*.html", + "非OpenAI官方接口返回了错误": "Non-OpenAI official interface returned an error", + "如果在Arxiv上匹配失败": "If the match fails on Arxiv", + "文件进入知识库后可长期保存": "Files can be saved for a long time after entering the knowledge base", + "您可以再次重试": "You can try again", + "整理文件集合": "Organize file collection", + "检测到有缺陷的非OpenAI官方接口": "Detected defective non-OpenAI official interface", + "此插件不调用Latex": "This plugin does not call Latex", + "移除过时的旧文件从而节省空间&保护隐私": "Remove outdated old files to save space & protect privacy", + "代码我刚刚打包拖到上传区了」": "I just packed the code and dragged it to the upload area", + "将图像转为灰度图像": "Convert the image to grayscale", + "待排除": "To be excluded", + "请勿修改": "Please do not modify", + "crazy_functions/代码重写为全英文_多线程.py": "crazy_functions/code rewritten to all English_multi-threading.py", + "开发中": "Under development", + "请查阅Gradio主题商店": "Please refer to the Gradio theme store", + "输出消息": "Output message", + "其他情况": "Other situations", + "获取文献失败": "Failed to retrieve literature", + "可以通过再次调用本插件的方式": "You can use this plugin again by calling it", + "保留下半部分": "Keep the lower half", + "排除问题": "Exclude the problem", + "知识库": "Knowledge base", + "ParsePDF失败": "ParsePDF failed", + "向知识库追加更多文档": "Append more documents to the knowledge base", + "此处待注入的知识库名称id": "The knowledge base name ID to be injected here", + "您需要构建知识库后再运行此插件": "You need to build the knowledge base before running this plugin", + "判定是否为公式 | 测试1 写出洛伦兹定律": "Determine whether it is a formula | Test 1 write out the Lorentz law", + "构建知识库后": "After building the knowledge base" } \ No newline at end of file diff --git a/main.py b/main.py index aedbcfc..ff4bc78 100644 --- a/main.py +++ b/main.py @@ -184,7 +184,7 @@ def main(): # 函数插件-固定按钮区 for k in plugins: if not plugins[k].get("AsButton", True): continue - click_handle = plugins[k]["Button"].click(ArgsGeneralWrapper(plugins[k]["Function"]), [*input_combo, gr.State(PORT)], output_combo) + click_handle = plugins[k]["Button"].click(ArgsGeneralWrapper(plugins[k]["Function"]), [*input_combo], output_combo) click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot]) cancel_handles.append(click_handle) # 函数插件-下拉菜单与随变按钮的互动 @@ -204,7 +204,7 @@ def main(): def route(request: gr.Request, k, *args, **kwargs): if k in [r"打开插件列表", r"请先从插件列表中选择"]: return yield from ArgsGeneralWrapper(plugins[k]["Function"])(request, *args, **kwargs) - click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo) + click_handle = switchy_bt.click(route,[switchy_bt, *input_combo], output_combo) click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot]) cancel_handles.append(click_handle) # 终止按钮的回调函数注册 diff --git a/toolbox.py b/toolbox.py index 947044f..ccc3664 100644 --- a/toolbox.py +++ b/toolbox.py @@ -79,14 +79,23 @@ def ArgsGeneralWrapper(f): } chatbot_with_cookie = ChatBotWithCookies(cookies) chatbot_with_cookie.write_list(chatbot) + if cookies.get('lock_plugin', None) is None: # 正常状态 - yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, *args) + if len(args) == 0: # 插件通道 + yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, request) + else: # 对话通道 + yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, *args) else: - # 处理个别特殊插件的锁定状态 + # 处理少数情况下的特殊插件的锁定状态 module, fn_name = cookies['lock_plugin'].split('->') f_hot_reload = getattr(importlib.import_module(module, fn_name), fn_name) yield from f_hot_reload(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, request) + # 判断一下用户是否错误地通过对话通道进入,如果是,则进行提醒 + final_cookies = chatbot_with_cookie.get_cookies() + if len(args) == 0 and 'files_to_promote' in final_cookies and len(final_cookies['files_to_promote']) > 0: + chatbot_with_cookie.append(["检测到**滞留的缓存文档**,请及时处理。", "请及时点击“**保存当前对话**”获取所有滞留文档。"]) + yield from update_ui(chatbot_with_cookie, final_cookies['history'], msg="检测到被滞留的缓存文档") return decorated @@ -96,7 +105,8 @@ def update_ui(chatbot, history, msg='正常', **kwargs): # 刷新界面 """ assert isinstance(chatbot, ChatBotWithCookies), "在传递chatbot的过程中不要将其丢弃。必要时, 可用clear将其清空, 然后用for+append循环重新赋值。" cookies = chatbot.get_cookies() - + # 备份一份History作为记录 + cookies.update({'history': history}) # 解决插件锁定时的界面显示问题 if cookies.get('lock_plugin', None): label = cookies.get('llm_model', "") + " | " + "正在锁定插件" + cookies.get('lock_plugin', None)