Your Name commited on
Commit
a6c4b8d
1 Parent(s): 92d4400

add pip package check

Browse files
crazy_functions/批量总结PDF文档.py CHANGED
@@ -51,7 +51,15 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
51
  yield chatbot, history, msg
52
 
53
 
 
54
  def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
 
 
 
 
 
 
 
55
  history = [] # 清空历史,以免输入溢出
56
  import glob, os
57
  if os.path.exists(txt):
@@ -61,14 +69,13 @@ def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromp
61
  report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
62
  yield chatbot, history, '正常'
63
  return
64
- file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)] + \
65
- [f for f in glob.glob(f'{project_folder}/**/*.pdf', recursive=True)] # + \
 
66
  # [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
67
  # [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
68
  if len(file_manifest) == 0:
69
- report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.pdf文件: {txt}")
70
  yield chatbot, history, '正常'
71
  return
72
-
73
  yield from 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
74
-
 
51
  yield chatbot, history, msg
52
 
53
 
54
+ @CatchException
55
  def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
56
+ try:
57
+ import codecs, fitz
58
+ except:
59
+ report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"使用该模块需要额外用pip安装codecs和fitz包")
60
+ yield chatbot, history, '正常'
61
+ return
62
+
63
  history = [] # 清空历史,以免输入溢出
64
  import glob, os
65
  if os.path.exists(txt):
 
69
  report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
70
  yield chatbot, history, '正常'
71
  return
72
+
73
+ file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.pdf', recursive=True)] # + \
74
+ # [f for f in glob.glob(f'{project_folder}/**/*.tex', recursive=True)] + \
75
  # [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
76
  # [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
77
  if len(file_manifest) == 0:
78
+ report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex或.pdf文件: {txt}")
79
  yield chatbot, history, '正常'
80
  return
 
81
  yield from 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
 
crazy_functions/读文章写摘要.py CHANGED
@@ -67,4 +67,4 @@ def 读文章写摘要(txt, top_p, temperature, chatbot, history, systemPromptTx
67
  report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
68
  yield chatbot, history, '正常'
69
  return
70
- yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
 
67
  report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
68
  yield chatbot, history, '正常'
69
  return
70
+ yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
functional_crazy.py CHANGED
@@ -1,7 +1,11 @@
 
 
 
 
 
1
 
2
  def get_crazy_functionals():
3
  from crazy_functions.读文章写摘要 import 读文章写摘要
4
- from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
5
  from crazy_functions.生成函数注释 import 批量生成函数注释
6
  from crazy_functions.解析项目源代码 import 解析项目本身
7
  from crazy_functions.解析项目源代码 import 解析一个Python项目
@@ -10,7 +14,7 @@ def get_crazy_functionals():
10
  from crazy_functions.高级功能函数模板 import 高阶功能模板函数
11
  from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
12
 
13
- return {
14
  "[实验] 请解析并解构此项目本身": {
15
  "Function": 解析项目本身
16
  },
@@ -30,10 +34,6 @@ def get_crazy_functionals():
30
  "Color": "stop", # 按钮颜色
31
  "Function": 读文章写摘要
32
  },
33
- "[实验] 批量总结pdf文档并生成双语摘要(配合input输入框)": {
34
- "Color": "stop", # 按钮颜色
35
- "Function": 批量总结PDF文档
36
- },
37
  "[实验] 批量生成函数注释(配合input输入框)": {
38
  "Color": "stop", # 按钮颜色
39
  "Function": 批量生成函数注释
@@ -46,5 +46,22 @@ def get_crazy_functionals():
46
  },
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
 
 
1
+ # UserVisibleLevel是过滤器参数。
2
+ # 由于UI界面空间有限,所以通过这种方式决定UI界面中显示哪些插件
3
+ # 默认函数插件 VisibleLevel 是 0
4
+ # 当 UserVisibleLevel >= 函数插件的 VisibleLevel 时,该函数插件才会被显示出来
5
+ UserVisibleLevel = 0
6
 
7
  def get_crazy_functionals():
8
  from crazy_functions.读文章写摘要 import 读文章写摘要
 
9
  from crazy_functions.生成函数注释 import 批量生成函数注释
10
  from crazy_functions.解析项目源代码 import 解析项目本身
11
  from crazy_functions.解析项目源代码 import 解析一个Python项目
 
14
  from crazy_functions.高级功能函数模板 import 高阶功能模板函数
15
  from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
16
 
17
+ function_plugins = {
18
  "[实验] 请解析并解构此项目本身": {
19
  "Function": 解析项目本身
20
  },
 
34
  "Color": "stop", # 按钮颜色
35
  "Function": 读文章写摘要
36
  },
 
 
 
 
37
  "[实验] 批量生成函数注释(配合input输入框)": {
38
  "Color": "stop", # 按钮颜色
39
  "Function": 批量生成函数注释
 
46
  },
47
  }
48
 
49
+ # VisibleLevel=1 经过充分测试,但不常用的插件放在这里
50
+ if UserVisibleLevel >= 1:
51
+ function_plugins.update({
52
+ })
53
+
54
+
55
+ # VisibleLevel=2 尚未充分测试的函数插件,放在这里
56
+ from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
57
+ if UserVisibleLevel >= 2:
58
+ function_plugins.update({
59
+ "[实验] 批量总结PDF文档": {
60
+ "Color": "stop",
61
+ "Function": 批量总结PDF文档
62
+ },
63
+ })
64
+
65
+ return function_plugins
66
 
67