diff --git a/__main__.py b/__main__.py index ec93935..8adc54c 100644 --- a/__main__.py +++ b/__main__.py @@ -395,8 +395,8 @@ def check_proxy_free(): time.sleep(5) if __name__ == '__main__': - # PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT - PORT = 7891 if WEB_PORT <= 0 else WEB_PORT + PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT + # PORT = 7891 if WEB_PORT <= 0 else WEB_PORT check_proxy_free() ChatBot().main() gr.close_all() diff --git a/crazy_functional.py b/crazy_functional.py index d80a58f..3ee5202 100644 --- a/crazy_functional.py +++ b/crazy_functional.py @@ -118,11 +118,11 @@ def get_crazy_functions(): "Function": HotReload(解析项目本身), "AsButton": False, # 加入下拉菜单中 }, - "[老旧的Demo] 把本项目源代码切换成全英文": { - # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 - "AsButton": False, # 加入下拉菜单中 - "Function": HotReload(全项目切换英文) - }, + # "[老旧的Demo] 把本项目源代码切换成全英文": { + # # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 + # "AsButton": False, # 加入下拉菜单中 + # "Function": HotReload(全项目切换英文) + # }, "[插件demo] 历史上的今天": { # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 "Function": HotReload(高阶功能模板函数) diff --git a/crazy_functions/理解Jupyter.py b/crazy_functions/理解Jupyter.py new file mode 100644 index 0000000..5158465 --- /dev/null +++ b/crazy_functions/理解Jupyter.py @@ -0,0 +1,30 @@ +#! .\venv\ +# encoding: utf-8 +# @Time : 2023/5/23 +# @Author : Spike +# @Descr : +import json +from toolbox import CatchException, update_ui +from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive, input_clipping +import func_box + + +class ParseNoteBook: + + def __init__(self, file): + self.file = file + + def load_dict(self): + with open(self.file, 'r', encoding='utf-8', errors='replace') as f: + return json.load(f) + + +@CatchException +def 翻译理解jupyter(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): + pass + + +if __name__ == '__main__': + obj = ParseNoteBook('/Users/kilig/Desktop/jupy/NotarizedUpload.ipynb').load_dict() + print(obj['cells']) + diff --git a/crazy_functions/解析JupyterNotebook.py b/crazy_functions/解析JupyterNotebook.py index b4bcd56..6fca0fc 100644 --- a/crazy_functions/解析JupyterNotebook.py +++ b/crazy_functions/解析JupyterNotebook.py @@ -144,3 +144,13 @@ def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 return yield from ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, ) + + +if __name__ == '__main__': + import json + filename = '' + code = parseNotebook(filename) + print(code) + with open(filename, 'r', encoding='utf-8', errors='replace') as f: + notebook = f.read() + print(notebook) \ No newline at end of file diff --git a/func_box.py b/func_box.py index 02fb412..661d4c9 100644 --- a/func_box.py +++ b/func_box.py @@ -4,6 +4,7 @@ # @Author : Spike # @Descr : import hashlib +import io import json import os.path import subprocess @@ -480,8 +481,8 @@ def thread_write_chat(chatbot): """ private_key = toolbox.get_conf('private_key')[0] chat_title = chatbot[0][0].split() - i_say = chatbot[-1][0].strip("
/p") - gpt_result = chatbot[-1][1].strip('
/p").strip('
/p").strip('