Spaces:
Sleeping
Sleeping
UP
Browse files
crazy_functions/批量Markdown翻译.py
CHANGED
|
@@ -134,7 +134,7 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|
| 134 |
history = [] # 清空历史,以免输入溢出
|
| 135 |
|
| 136 |
success, file_manifest, project_folder = get_files_from_everything(txt)
|
| 137 |
-
|
| 138 |
if not success:
|
| 139 |
# 什么都没有
|
| 140 |
if txt == "": txt = '空空如也的输入栏'
|
|
@@ -164,6 +164,7 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|
| 164 |
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
| 165 |
try:
|
| 166 |
import tiktoken
|
|
|
|
| 167 |
except:
|
| 168 |
report_execption(chatbot, history,
|
| 169 |
a=f"解析项目: {txt}",
|
|
@@ -171,18 +172,13 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
|
|
| 171 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
| 172 |
return
|
| 173 |
history = [] # 清空历史,以免输入溢出
|
| 174 |
-
|
| 175 |
-
if
|
| 176 |
-
|
| 177 |
-
else:
|
| 178 |
if txt == "": txt = '空空如也的输入栏'
|
| 179 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
| 180 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
| 181 |
return
|
| 182 |
-
if txt.endswith('.md'):
|
| 183 |
-
file_manifest = [txt]
|
| 184 |
-
else:
|
| 185 |
-
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
|
| 186 |
if len(file_manifest) == 0:
|
| 187 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
| 188 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
|
|
|
| 134 |
history = [] # 清空历史,以免输入溢出
|
| 135 |
|
| 136 |
success, file_manifest, project_folder = get_files_from_everything(txt)
|
| 137 |
+
|
| 138 |
if not success:
|
| 139 |
# 什么都没有
|
| 140 |
if txt == "": txt = '空空如也的输入栏'
|
|
|
|
| 164 |
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
| 165 |
try:
|
| 166 |
import tiktoken
|
| 167 |
+
import glob, os
|
| 168 |
except:
|
| 169 |
report_execption(chatbot, history,
|
| 170 |
a=f"解析项目: {txt}",
|
|
|
|
| 172 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
| 173 |
return
|
| 174 |
history = [] # 清空历史,以免输入溢出
|
| 175 |
+
success, file_manifest, project_folder = get_files_from_everything(txt)
|
| 176 |
+
if not success:
|
| 177 |
+
# 什么都没有
|
|
|
|
| 178 |
if txt == "": txt = '空空如也的输入栏'
|
| 179 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
| 180 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
| 181 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
if len(file_manifest) == 0:
|
| 183 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
|
| 184 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|