From 1dd165a3cd1f74b2f643f2b94948b790c6806d55 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Sun, 3 Sep 2023 14:47:22 +0800 Subject: [PATCH] ui layout improve --- crazy_functional.py | 21 ++++------ crazy_functions/虚空终端.py | 81 ++++++++++++++++++++----------------- toolbox.py | 3 +- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/crazy_functional.py b/crazy_functional.py index 05e4466..f06cd40 100644 --- a/crazy_functional.py +++ b/crazy_functional.py @@ -34,9 +34,16 @@ def get_crazy_functions(): from crazy_functions.Latex全文翻译 import Latex中译英 from crazy_functions.Latex全文翻译 import Latex英译中 from crazy_functions.批量Markdown翻译 import Markdown中译英 + from crazy_functions.虚空终端 import 虚空终端 function_plugins = { + "虚空终端": { + "Group": "对话|编程|学术", + "Color": "stop", + "AsButton": True, + "Function": HotReload(虚空终端) + }, "解析整个Python项目": { "Group": "编程", "Color": "stop", @@ -139,7 +146,7 @@ def get_crazy_functions(): "读Tex论文写摘要": { "Group": "学术", "Color": "stop", - "AsButton": True, + "AsButton": False, "Info": "读取Tex论文并写摘要 | 输入参数为路径", "Function": HotReload(读文章写摘要) }, @@ -494,18 +501,6 @@ def get_crazy_functions(): except: print('Load function plugin failed') - try: - from crazy_functions.虚空终端 import 虚空终端 - function_plugins.update({ - "虚空终端": { - "Group": "对话", - "Color": "stop", - "AsButton": True, - "Function": HotReload(虚空终端) - } - }) - except: - print('Load function plugin failed') # try: # from crazy_functions.chatglm微调工具 import 微调数据集生成 diff --git a/crazy_functions/虚空终端.py b/crazy_functions/虚空终端.py index c4f2b2f..cdf0605 100644 --- a/crazy_functions/虚空终端.py +++ b/crazy_functions/虚空终端.py @@ -1,3 +1,48 @@ +""" +Explanation of the Void Terminal Plugin: + +Please describe in natural language what you want to do. + +1. You can open the plugin's dropdown menu to explore various capabilities of this project, and then describe your needs in natural language, for example: +- "Please call the plugin to translate a PDF paper for me. I just uploaded the paper to the upload area." +- "Please use the plugin to translate a PDF paper, with the address being https://www.nature.com/articles/s41586-019-1724-z.pdf." +- "Generate an image with blooming flowers and lush green grass using the plugin." +- "Translate the README using the plugin. The GitHub URL is https://github.com/facebookresearch/co-tracker." +- "Translate an Arxiv paper for me. The Arxiv ID is 1812.10695. Remember to use the plugin and don't do it manually!" +- "I don't like the current interface color. Modify the configuration and change the theme to THEME="High-Contrast"." +- "Could you please explain the structure of the Transformer network?" + +2. If you use keywords like "call the plugin xxx", "modify the configuration xxx", "please", etc., your intention can be recognized more accurately. + +3. Your intention can be recognized more accurately when using powerful models like GPT4. This plugin is relatively new, so please feel free to provide feedback on GitHub. + +4. Now, if you need to process a file, please upload the file (drag the file to the file upload area) or describe the path to the file. + +5. If you don't need to upload a file, you can simply repeat your command again. +""" +explain_msg = """ +## 虚空终端插件说明: + +请用**自然语言**描述您需要做什么。 + +1. 您可以打开插件下拉菜单以了解本项目的各种能力,然后用自然语言描述您的需要,例如: + - 「请调用插件,为我翻译PDF论文,论文我刚刚放到上传区了。」 + - 「请调用插件翻译PDF论文,地址为https://www.nature.com/articles/s41586-019-1724-z.pdf」 + - 「生成一张图片,图中鲜花怒放,绿草如茵,用插件实现。」 + - 「用插件翻译README,Github网址是https://github.com/facebookresearch/co-tracker」 + - 「给爷翻译Arxiv论文,arxiv论文的ID是1812.10695,记得用插件,不要自己瞎搞!」 + - 「我不喜欢当前的界面颜色,修改配置,把主题THEME更换为THEME="High-Contrast"。」 + - 「请问Transformer网络的结构是怎样的?」 + +2. 如果您使用「调用插件xxx」、「修改配置xxx」、「请问」等关键词,您的意图可以被识别的更准确。 + +3. 使用GPT4等强力模型时,您的意图可以被识别的更准确。该插件诞生时间不长,欢迎您前往Github反馈问题。 + +4. 现在,如果需要处理文件,请您上传文件(将文件拖动到文件上传区),或者描述文件所在的路径。 + +5. 如果不需要上传文件,现在您只需要再次重复一次您的指令即可。 +""" + from pydantic import BaseModel, Field from typing import List from toolbox import CatchException, update_ui, gen_time_str @@ -10,10 +55,6 @@ from crazy_functions.vt_fns.vt_state import VoidTerminalState from crazy_functions.vt_fns.vt_modify_config import modify_configuration_hot from crazy_functions.vt_fns.vt_modify_config import modify_configuration_reboot from crazy_functions.vt_fns.vt_call_plugin import execute_plugin -from enum import Enum -import copy, json, pickle, os, sys - - class UserIntention(BaseModel): user_prompt: str = Field(description="the content of user input", default="") @@ -61,37 +102,6 @@ def analyze_intention_with_simple_rules(txt): return is_certain, user_intention - - - - - -explain_msg = """ -## 虚空终端插件说明: - -请用**自然语言**描述您需要做什么。 - -1. 您可以打开插件下拉菜单以了解本项目的各种能力,然后用自然语言描述您的需要,例如: - - 「请调用插件,为我翻译PDF论文,论文我刚刚放到上传区了。」 - - 「请调用插件翻译PDF论文,地址为https://www.nature.com/articles/s41586-019-1724-z.pdf」 - - 「生成一张图片,图中鲜花怒放,绿草如茵,用插件实现。」 - - 「用插件翻译README,Github网址是https://github.com/facebookresearch/co-tracker」 - - 「给爷翻译Arxiv论文,arxiv论文的ID是1812.10695,记得用插件,不要自己瞎搞!」 - - 「我不喜欢当前的界面颜色,修改配置,把主题THEME更换为THEME="High-Contrast"。」 - - 「请问Transformer网络的结构是怎样的?」 - -2. 如果您使用「调用插件xxx」、「修改配置xxx」、「请问」等关键词,您的意图可以被识别的更准确。 - -3. 使用GPT4等强模型时,您的意图可以被识别的更准确。 - -4. 现在,如果需要处理文件,请您上传文件(将文件拖动到文件上传区),或者描述文件所在的路径。 - -5. 如果不需要上传文件,现在您只需要再次重复一次您的指令即可。 -""" - - - - @CatchException def 虚空终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): # 获取当前虚空终端状态 @@ -162,4 +172,3 @@ def 虚空终端主路由(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst return - diff --git a/toolbox.py b/toolbox.py index 0d598d8..1242fab 100644 --- a/toolbox.py +++ b/toolbox.py @@ -492,7 +492,8 @@ def find_recent_files(directory): current_time = time.time() one_minute_ago = current_time - 60 recent_files = [] - + if not os.path.exists(directory): + os.makedirs(directory, exist_ok=True) for filename in os.listdir(directory): file_path = os.path.join(directory, filename) if file_path.endswith('.log'):