add pip package check

这个提交包含在:
Your Name
2023-03-29 21:47:56 +08:00
父节点 92d4400d19
当前提交 a6c4b8d764
共有 3 个文件被更改,包括 36 次插入12 次删除

查看文件

@@ -51,7 +51,15 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
yield chatbot, history, msg
@CatchException
def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
try:
import codecs, fitz
except:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"使用该模块需要额外用pip安装codecs和fitz包")
yield chatbot, history, '正常'
return
history = [] # 清空历史,以免输入溢出
import glob, os
if os.path.exists(txt):
@@ -61,14 +69,13 @@ def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromp
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
yield chatbot, history, '正常'
return
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.pdf', recursive=True)] # + \
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.pdf', recursive=True)] # + \
# [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)] + \
# [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.pdf文件: {txt}")
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex或.pdf文件: {txt}")
yield chatbot, history, '正常'
return
yield from 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)

查看文件

@@ -67,4 +67,4 @@ def 读文章写摘要(txt, top_p, temperature, chatbot, history, systemPromptTx
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
yield chatbot, history, '正常'
return
yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)