add pip package check
This commit is contained in:
parent
7d57967519
commit
48cc2349e3
@ -51,7 +51,15 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
|
|||||||
yield chatbot, history, msg
|
yield chatbot, history, msg
|
||||||
|
|
||||||
|
|
||||||
|
@CatchException
|
||||||
def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
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 = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
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}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
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}/**/*.cpp', recursive=True)] + \
|
||||||
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
||||||
if len(file_manifest) == 0:
|
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, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
|
|
||||||
yield from 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
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}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
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)
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
# UserVisibleLevel是过滤器参数。
|
||||||
|
# 由于UI界面空间有限,所以通过这种方式决定UI界面中显示哪些插件
|
||||||
|
# 默认函数插件 VisibleLevel 是 0
|
||||||
|
# 当 UserVisibleLevel >= 函数插件的 VisibleLevel 时,该函数插件才会被显示出来
|
||||||
|
UserVisibleLevel = 0
|
||||||
|
|
||||||
def get_crazy_functionals():
|
def get_crazy_functionals():
|
||||||
from crazy_functions.读文章写摘要 import 读文章写摘要
|
from crazy_functions.读文章写摘要 import 读文章写摘要
|
||||||
from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
|
|
||||||
from crazy_functions.生成函数注释 import 批量生成函数注释
|
from crazy_functions.生成函数注释 import 批量生成函数注释
|
||||||
from crazy_functions.解析项目源代码 import 解析项目本身
|
from crazy_functions.解析项目源代码 import 解析项目本身
|
||||||
from crazy_functions.解析项目源代码 import 解析一个Python项目
|
from crazy_functions.解析项目源代码 import 解析一个Python项目
|
||||||
@ -10,7 +14,7 @@ def get_crazy_functionals():
|
|||||||
from crazy_functions.高级功能函数模板 import 高阶功能模板函数
|
from crazy_functions.高级功能函数模板 import 高阶功能模板函数
|
||||||
from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
|
from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
|
||||||
|
|
||||||
return {
|
function_plugins = {
|
||||||
"[实验] 请解析并解构此项目本身": {
|
"[实验] 请解析并解构此项目本身": {
|
||||||
"Function": 解析项目本身
|
"Function": 解析项目本身
|
||||||
},
|
},
|
||||||
@ -30,10 +34,6 @@ def get_crazy_functionals():
|
|||||||
"Color": "stop", # 按钮颜色
|
"Color": "stop", # 按钮颜色
|
||||||
"Function": 读文章写摘要
|
"Function": 读文章写摘要
|
||||||
},
|
},
|
||||||
"[实验] 批量总结pdf文档并生成双语摘要(配合input输入框)": {
|
|
||||||
"Color": "stop", # 按钮颜色
|
|
||||||
"Function": 批量总结PDF文档
|
|
||||||
},
|
|
||||||
"[实验] 批量生成函数注释(配合input输入框)": {
|
"[实验] 批量生成函数注释(配合input输入框)": {
|
||||||
"Color": "stop", # 按钮颜色
|
"Color": "stop", # 按钮颜色
|
||||||
"Function": 批量生成函数注释
|
"Function": 批量生成函数注释
|
||||||
@ -46,5 +46,22 @@ def get_crazy_functionals():
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# VisibleLevel=1 经过充分测试,但不常用的插件放在这里
|
||||||
|
if UserVisibleLevel >= 1:
|
||||||
|
function_plugins.update({
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
# VisibleLevel=2 尚未充分测试的函数插件,放在这里
|
||||||
|
from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
|
||||||
|
if UserVisibleLevel >= 2:
|
||||||
|
function_plugins.update({
|
||||||
|
"[实验] 批量总结PDF文档": {
|
||||||
|
"Color": "stop",
|
||||||
|
"Function": 批量总结PDF文档
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return function_plugins
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user