cnhkmcp 2.1.2__py3-none-any.whl → 2.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/METADATA +1 -1
  2. cnhkmcp-2.1.3.dist-info/RECORD +6 -0
  3. cnhkmcp-2.1.3.dist-info/top_level.txt +1 -0
  4. cnhkmcp/__init__.py +0 -125
  5. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/README.md +0 -38
  6. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/ace.log +0 -0
  7. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/config.json +0 -6
  8. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/ace_lib.py +0 -1510
  9. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_datasets.py +0 -157
  10. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_documentation.py +0 -132
  11. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/fetch_all_operators.py +0 -99
  12. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/get_knowledgeBase_tool/helpful_functions.py +0 -180
  13. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/icon.ico +0 -0
  14. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/icon.png +0 -0
  15. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/knowledge/test.txt +0 -1
  16. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/main.py +0 -576
  17. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/process_knowledge_base.py +0 -281
  18. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/rag_engine.py +0 -408
  19. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/requirements.txt +0 -7
  20. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/run.bat +0 -3
  21. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242//321/211/320/266/320/246/321/206/320/274/320/261/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/231/320/243/321/205/342/225/235/320/220/321/206/320/230/320/241.py +0 -265
  22. cnhkmcp/untracked/APP/.gitignore +0 -32
  23. cnhkmcp/untracked/APP/MODULAR_STRUCTURE.md +0 -112
  24. cnhkmcp/untracked/APP/README.md +0 -309
  25. cnhkmcp/untracked/APP/Tranformer/Transformer.py +0 -4985
  26. cnhkmcp/untracked/APP/Tranformer/ace.log +0 -0
  27. cnhkmcp/untracked/APP/Tranformer/ace_lib.py +0 -1510
  28. cnhkmcp/untracked/APP/Tranformer/helpful_functions.py +0 -180
  29. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates.json +0 -2421
  30. cnhkmcp/untracked/APP/Tranformer/output/Alpha_candidates_/321/207/320/264/342/225/221/321/204/342/225/233/320/233.json +0 -654
  31. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_error.json +0 -1034
  32. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_success.json +0 -444
  33. cnhkmcp/untracked/APP/Tranformer/output/Alpha_generated_expressions_/321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/320/237/320/277/321/207/320/253/342/224/244/321/206/320/236/320/265/321/210/342/225/234/342/225/234/321/205/320/225/320/265Machine_lib.json +0 -22
  34. cnhkmcp/untracked/APP/Tranformer/parsetab.py +0 -60
  35. cnhkmcp/untracked/APP/Tranformer/template_summary.txt +0 -3182
  36. cnhkmcp/untracked/APP/Tranformer/transformer_config.json +0 -7
  37. cnhkmcp/untracked/APP/Tranformer/validator.py +0 -889
  38. cnhkmcp/untracked/APP/ace.log +0 -69
  39. cnhkmcp/untracked/APP/ace_lib.py +0 -1510
  40. cnhkmcp/untracked/APP/blueprints/__init__.py +0 -6
  41. cnhkmcp/untracked/APP/blueprints/feature_engineering.py +0 -347
  42. cnhkmcp/untracked/APP/blueprints/idea_house.py +0 -221
  43. cnhkmcp/untracked/APP/blueprints/inspiration_house.py +0 -432
  44. cnhkmcp/untracked/APP/blueprints/paper_analysis.py +0 -570
  45. cnhkmcp/untracked/APP/custom_templates/templates.json +0 -1257
  46. cnhkmcp/untracked/APP/give_me_idea/BRAIN_Alpha_Template_Expert_SystemPrompt.md +0 -400
  47. cnhkmcp/untracked/APP/give_me_idea/ace_lib.py +0 -1510
  48. cnhkmcp/untracked/APP/give_me_idea/alpha_data_specific_template_master.py +0 -252
  49. cnhkmcp/untracked/APP/give_me_idea/fetch_all_datasets.py +0 -157
  50. cnhkmcp/untracked/APP/give_me_idea/fetch_all_operators.py +0 -99
  51. cnhkmcp/untracked/APP/give_me_idea/helpful_functions.py +0 -180
  52. cnhkmcp/untracked/APP/give_me_idea/what_is_Alpha_template.md +0 -11
  53. cnhkmcp/untracked/APP/helpful_functions.py +0 -180
  54. cnhkmcp/untracked/APP/hkSimulator/ace_lib.py +0 -1497
  55. cnhkmcp/untracked/APP/hkSimulator/autosimulator.py +0 -447
  56. cnhkmcp/untracked/APP/hkSimulator/helpful_functions.py +0 -180
  57. cnhkmcp/untracked/APP/mirror_config.txt +0 -20
  58. cnhkmcp/untracked/APP/operaters.csv +0 -129
  59. cnhkmcp/untracked/APP/requirements.txt +0 -53
  60. cnhkmcp/untracked/APP/run_app.bat +0 -28
  61. cnhkmcp/untracked/APP/run_app.sh +0 -34
  62. cnhkmcp/untracked/APP/setup_tsinghua.bat +0 -39
  63. cnhkmcp/untracked/APP/setup_tsinghua.sh +0 -43
  64. cnhkmcp/untracked/APP/simulator/alpha_submitter.py +0 -404
  65. cnhkmcp/untracked/APP/simulator/simulator_wqb.py +0 -618
  66. cnhkmcp/untracked/APP/ssrn-3332513.pdf +6 -109201
  67. cnhkmcp/untracked/APP/static/brain.js +0 -589
  68. cnhkmcp/untracked/APP/static/decoder.js +0 -1540
  69. cnhkmcp/untracked/APP/static/feature_engineering.js +0 -1729
  70. cnhkmcp/untracked/APP/static/idea_house.js +0 -937
  71. cnhkmcp/untracked/APP/static/inspiration.js +0 -465
  72. cnhkmcp/untracked/APP/static/inspiration_house.js +0 -868
  73. cnhkmcp/untracked/APP/static/paper_analysis.js +0 -390
  74. cnhkmcp/untracked/APP/static/script.js +0 -3082
  75. cnhkmcp/untracked/APP/static/simulator.js +0 -597
  76. cnhkmcp/untracked/APP/static/styles.css +0 -3127
  77. cnhkmcp/untracked/APP/static/usage_widget.js +0 -508
  78. cnhkmcp/untracked/APP/templates/alpha_inspector.html +0 -511
  79. cnhkmcp/untracked/APP/templates/feature_engineering.html +0 -960
  80. cnhkmcp/untracked/APP/templates/idea_house.html +0 -564
  81. cnhkmcp/untracked/APP/templates/index.html +0 -932
  82. cnhkmcp/untracked/APP/templates/inspiration_house.html +0 -861
  83. cnhkmcp/untracked/APP/templates/paper_analysis.html +0 -91
  84. cnhkmcp/untracked/APP/templates/simulator.html +0 -343
  85. cnhkmcp/untracked/APP/templates/transformer_web.html +0 -580
  86. cnhkmcp/untracked/APP/usage.md +0 -351
  87. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/ace_lib.py +0 -1510
  88. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/brain_alpha_inspector.py +0 -712
  89. cnhkmcp/untracked/APP//321/207/342/225/235/320/250/321/205/320/230/320/226/321/204/342/225/225/320/220/321/211/320/221/320/243/321/206/320/261/320/265/helpful_functions.py +0 -180
  90. cnhkmcp/untracked/APP//321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/231/320/243/321/205/342/225/235/320/220/321/206/320/230/320/241.py +0 -2456
  91. cnhkmcp/untracked/arXiv_API_Tool_Manual.md +0 -490
  92. cnhkmcp/untracked/arxiv_api.py +0 -229
  93. cnhkmcp/untracked/forum_functions.py +0 -998
  94. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/forum_functions.py +0 -407
  95. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/platform_functions.py +0 -2415
  96. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272/user_config.json +0 -31
  97. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272//321/210/320/276/320/271AI/321/210/320/277/342/225/227/321/210/342/224/220/320/251/321/204/342/225/225/320/272/321/206/320/246/320/227/321/206/320/261/320/263/321/206/320/255/320/265/321/205/320/275/320/266/321/204/342/225/235/320/252/321/204/342/225/225/320/233/321/210/342/225/234/342/225/234/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270.md +0 -101
  98. cnhkmcp/untracked/mcp/321/206/320/246/320/227/321/204/342/225/227/342/225/242/321/210/320/276/342/225/221/321/205/320/255/320/253/321/207/320/231/320/2302_/321/205/320/266/320/222/321/206/320/256/320/254/321/205/320/236/320/257/321/207/320/231/320/230/321/205/320/240/320/277/321/205/320/232/320/270/321/204/342/225/225/320/235/321/204/342/225/221/320/226/321/206/342/225/241/320/237/321/210/320/267/320/230/321/205/320/251/320/270/321/205/342/226/221/342/226/222/321/210/320/277/320/245/321/210/342/224/220/320/251/321/204/342/225/225/320/272//321/211/320/225/320/235/321/207/342/225/234/320/276/321/205/320/231/320/235/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/230/320/241_/321/205/320/276/320/231/321/210/320/263/320/225/321/205/342/224/220/320/225/321/210/320/266/320/221/321/204/342/225/233/320/255/321/210/342/225/241/320/246/321/205/320/234/320/225.py +0 -190
  99. cnhkmcp/untracked/platform_functions.py +0 -2886
  100. cnhkmcp/untracked/sample_mcp_config.json +0 -11
  101. cnhkmcp/untracked/user_config.json +0 -31
  102. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/320/237/320/222/321/210/320/220/320/223/321/206/320/246/320/227/321/206/320/261/320/263_BRAIN_Alpha_Test_Requirements_and_Tips.md +0 -202
  103. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_Alpha_explaination_workflow.md +0 -56
  104. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_BRAIN_6_Tips_Datafield_Exploration_Guide.md +0 -194
  105. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_BRAIN_Alpha_Improvement_Workflow.md +0 -101
  106. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_Dataset_Exploration_Expert_Manual.md +0 -436
  107. cnhkmcp/untracked//321/207/320/264/342/225/221/321/204/342/225/233/320/233/321/205/342/225/226/320/265/321/204/342/225/234/320/254/321/206/342/225/241/320/221_daily_report_workflow.md +0 -128
  108. cnhkmcp/untracked//321/211/320/225/320/235/321/207/342/225/234/320/276/321/205/320/231/320/235/321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/230/320/241_/321/205/320/276/320/231/321/210/320/263/320/225/321/205/342/224/220/320/225/321/210/320/266/320/221/321/204/342/225/233/320/255/321/210/342/225/241/320/246/321/205/320/234/320/225.py +0 -190
  109. cnhkmcp-2.1.2.dist-info/RECORD +0 -111
  110. cnhkmcp-2.1.2.dist-info/top_level.txt +0 -1
  111. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/WHEEL +0 -0
  112. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/entry_points.txt +0 -0
  113. {cnhkmcp-2.1.2.dist-info → cnhkmcp-2.1.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +0,0 @@
1
- openai
2
- Pillow
3
- fastembed>=0.3.6
4
- chromadb>=0.5.11
5
- watchdog
6
- pypdf
7
- python-docx
@@ -1,265 +0,0 @@
1
- """
2
- 首次运行初始化脚本
3
- - 创建桌面快捷方式指向 main.py,用 Python 运行,图标为 icon.png
4
- - 检查 knowledge 文件夹文件数量
5
- - 如果 <= 3,提示用户建立知识库,并自动运行 process_knowledge_base.py
6
- """
7
-
8
- import os
9
- import sys
10
- import subprocess
11
- import shutil
12
- import json
13
- import platform
14
- import urllib.parse
15
- import urllib.request
16
- from pathlib import Path
17
-
18
- # 获取脚本所在目录(项目根目录)
19
- PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
20
- MAIN_SCRIPT = os.path.join(PROJECT_DIR, "main.py")
21
- ICON_ICO = os.path.join(PROJECT_DIR, "icon.ico")
22
- ICON_PNG = os.path.join(PROJECT_DIR, "icon.png")
23
- KNOWLEDGE_DIR = os.path.join(PROJECT_DIR, "knowledge")
24
- PROCESS_SCRIPT = os.path.join(PROJECT_DIR, "process_knowledge_base.py")
25
- CONFIG_PATH = os.path.join(PROJECT_DIR, "config.json")
26
-
27
-
28
- def load_config():
29
- if not os.path.exists(CONFIG_PATH):
30
- return {}
31
- try:
32
- with open(CONFIG_PATH, "r", encoding="utf-8") as f:
33
- return json.load(f) or {}
34
- except Exception as exc:
35
- print(f"✗ 读取 config.json 失败:{exc}")
36
- return {}
37
-
38
-
39
- def save_config(cfg):
40
- try:
41
- with open(CONFIG_PATH, "w", encoding="utf-8") as f:
42
- json.dump(cfg, f, ensure_ascii=False, indent=4)
43
- print(f"✓ 配置已写入:{CONFIG_PATH}")
44
- except Exception as exc:
45
- print(f"✗ 写入 config.json 失败:{exc}")
46
-
47
-
48
- def check_network_reachable(url="https://www.google.com/generate_204", timeout_ms=2000):
49
- """Check connectivity via ping + lightweight HTTPS GET. Returns True if either succeeds."""
50
- parsed = urllib.parse.urlparse(url)
51
- host = parsed.hostname or "google.com"
52
- is_windows = platform.system().lower().startswith("win")
53
- if is_windows:
54
- cmd = ["ping", "-n", "1", "-w", str(timeout_ms), host]
55
- else:
56
- cmd = ["ping", "-c", "1", "-W", str(int(timeout_ms / 1000)), host]
57
-
58
- try:
59
- result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
60
- if result.returncode == 0:
61
- return True
62
- except Exception as exc:
63
- print(f"✗ 无法执行 ping:{exc}")
64
-
65
- # Fallback: HTTPS request (respects proxy envs)
66
- try:
67
- with urllib.request.urlopen(url, timeout=timeout_ms / 1000.0) as resp:
68
- return 200 <= getattr(resp, "status", 200) < 400
69
- except Exception as exc:
70
- print(f"✗ HTTPS 连通性检测失败:{exc}")
71
- return False
72
-
73
-
74
- def prompt_config_if_needed():
75
- cfg = load_config()
76
-
77
- defaults = {
78
- "base_url": cfg.get("base_url") or "https://api.moonshot.cn/v1",
79
- "model": cfg.get("model") or "kimi-latest",
80
- }
81
-
82
- if not cfg.get("system_prompt"):
83
- cfg["system_prompt"] = (
84
- "You are a WorldQuant BRAIN platform expert and Consultant. "
85
- "Your goal is to assist users with Alpha development, BRAIN API usage, and maximizing consultant income."
86
- )
87
-
88
- def ask(field, label, default_value=None, allow_empty=False):
89
- current = str(cfg.get(field, "")).strip()
90
- prompt = f"请输入 {label}" + (f" [默认: {current or default_value}]" if (current or default_value) else "") + ": "
91
- value = input(prompt).strip()
92
- if not value:
93
- value = current if current else (default_value if default_value is not None else "")
94
- if value or allow_empty:
95
- cfg[field] = value
96
- return value
97
-
98
- api_key = ask("api_key", "API Key")
99
- base_url = ask("base_url", "Base URL", defaults["base_url"], allow_empty=True)
100
- model = ask("model", "模型名称", defaults["model"], allow_empty=True)
101
-
102
- if api_key:
103
- save_config(cfg)
104
- return True
105
-
106
- print("✗ 配置文件中的 api_key 为空,请填写后再运行本脚本。")
107
- return False
108
-
109
-
110
- def is_api_key_configured():
111
- """Check config; if api_key missing/empty, prompt user to fill and persist."""
112
- cfg = load_config()
113
-
114
- api_key = str(cfg.get("api_key", "")).strip()
115
- if api_key:
116
- return True
117
-
118
- print("✗ 当前 config.json 中 api_key 为空。")
119
- return prompt_config_if_needed()
120
-
121
- def create_desktop_shortcut():
122
- """创建桌面快捷方式"""
123
- try:
124
- import win32com.client
125
-
126
- desktop = os.path.expanduser("~\\Desktop")
127
- shortcut_path = os.path.join(desktop, "BRAIN顾问助手.lnk")
128
-
129
- # 获取 Python 可执行文件路径
130
- python_exe = sys.executable
131
-
132
- # 创建 shortcut
133
- shell = win32com.client.Dispatch("WScript.Shell")
134
- shortcut = shell.CreateShortcut(shortcut_path)
135
- shortcut.TargetPath = python_exe
136
- shortcut.Arguments = f'"{MAIN_SCRIPT}"'
137
- shortcut.WorkingDirectory = PROJECT_DIR
138
-
139
- # 设置图标:优先使用 .ico(Windows 标准格式),再试 .png
140
- icon_found = False
141
- if os.path.exists(ICON_ICO):
142
- # .ico 文件:使用 "路径,0" 格式
143
- shortcut.IconLocation = f"{ICON_ICO},0"
144
- icon_found = True
145
- print(f" 使用图标:{ICON_ICO}")
146
- elif os.path.exists(ICON_PNG):
147
- # .png 文件:也需要 "路径,0" 格式
148
- shortcut.IconLocation = f"{ICON_PNG},0"
149
- icon_found = True
150
- print(f" 使用图标:{ICON_PNG}")
151
- else:
152
- # 使用 Python 可执行文件的图标作为默认
153
- shortcut.IconLocation = f"{python_exe},0"
154
- print(f" 使用默认图标(Python 图标)")
155
-
156
- shortcut.Description = "BRAIN 顾问助手 - AI 驱动的交互工具"
157
- shortcut.save()
158
-
159
- print(f"✓ 桌面快捷方式已创建:{shortcut_path}")
160
- return True
161
- except ImportError:
162
- print("⚠ pywin32 未安装,尝试使用备选方案创建快捷方式...")
163
- try:
164
- # 备选方案:使用 Windows API
165
- create_shortcut_via_batch(desktop, shortcut_path, python_exe)
166
- return True
167
- except Exception as e:
168
- print(f"✗ 创建快捷方式失败:{e}")
169
- print(f" 请手动创建快捷方式,目标为:{python_exe} \"{MAIN_SCRIPT}\"")
170
- return False
171
- except Exception as e:
172
- print(f"✗ 创建快捷方式失败:{e}")
173
- return False
174
-
175
- def check_knowledge_base():
176
- """检查 knowledge 文件夹中的文件数量"""
177
- if not os.path.exists(KNOWLEDGE_DIR):
178
- os.makedirs(KNOWLEDGE_DIR)
179
- print(f"✓ 创建 knowledge 文件夹:{KNOWLEDGE_DIR}")
180
- return 0
181
-
182
- # 只计算文件,不计算目录
183
- files = [f for f in os.listdir(KNOWLEDGE_DIR) if os.path.isfile(os.path.join(KNOWLEDGE_DIR, f))]
184
- file_count = len(files)
185
- print(f"知识库文件数量:{file_count}")
186
-
187
- if files:
188
- print(f" 已有文件:{', '.join(files)}")
189
-
190
- return file_count
191
-
192
- def run_process_knowledge_base():
193
- """运行 process_knowledge_base.py 建立知识库"""
194
- if not os.path.exists(PROCESS_SCRIPT):
195
- print(f"✗ 找不到 {PROCESS_SCRIPT}")
196
- return False
197
-
198
- print(f"\n正在运行知识库初始化脚本...")
199
- print(f"命令:{sys.executable} \"{PROCESS_SCRIPT}\"")
200
-
201
- try:
202
- subprocess.run([sys.executable, PROCESS_SCRIPT], cwd=PROJECT_DIR)
203
- print("✓ 知识库初始化完成")
204
- return True
205
- except Exception as e:
206
- print(f"✗ 运行 process_knowledge_base.py 失败:{e}")
207
- return False
208
-
209
- def main():
210
- print("=" * 60)
211
- print("BRAIN 顾问助手 - 首次运行初始化")
212
- print("=" * 60)
213
- print()
214
-
215
- # 0. 检查 api_key 是否已配置,未配置则直接退出
216
- if not is_api_key_configured():
217
- input("按 Enter 键退出...")
218
- return
219
-
220
- # 0.1 检查网络(ping + HTTPS),以确认代理已开启
221
- print("[网络检查] 正在测试到 https://www.google.com 的连通性...")
222
- if not check_network_reachable("https://www.google.com/generate_204"):
223
- print("✗ 无法连通 google.com,请确认代理已开启,然后重新运行本脚本。")
224
- input("按 Enter 键退出...")
225
- return
226
- print("✓ 网络检查通过")
227
-
228
- # 1. 创建桌面快捷方式
229
- print("[1/2] 创建桌面快捷方式...")
230
- shortcut_ok = create_desktop_shortcut()
231
- print()
232
-
233
- # 2. 检查知识库
234
- print("[2/2] 检查本地知识库...")
235
- file_count = check_knowledge_base()
236
- print()
237
-
238
- if file_count <= 3:
239
- print("⚠ 知识库文件较少(<= 3 个)")
240
- print("建议建立本地知识库以增强 AI 回答效果")
241
- print()
242
-
243
- response = input("是否现在运行知识库初始化脚本?(y/n) [默认: y]: ").strip().lower()
244
- if response != 'n':
245
- run_process_knowledge_base()
246
- else:
247
- print(f"✓ 知识库已初始化(包含 {file_count} 个文件)")
248
-
249
- print()
250
- print("=" * 60)
251
- print("初始化完成!")
252
- print("=" * 60)
253
- print()
254
-
255
- if shortcut_ok:
256
- print("📌 你现在可以从桌面快捷方式启动应用")
257
- print(f" 或者运行:{sys.executable} \"{MAIN_SCRIPT}\"")
258
- else:
259
- print(f"请运行:{sys.executable} \"{MAIN_SCRIPT}\"")
260
- print()
261
-
262
- input("按 Enter 键退出...")
263
-
264
- if __name__ == "__main__":
265
- main()
@@ -1,32 +0,0 @@
1
- # Custom templates directory (user-specific data)
2
- custom_templates/
3
-
4
- # Python cache
5
- __pycache__/
6
- *.pyc
7
- *.pyo
8
- *.pyd
9
- .Python
10
- *.so
11
-
12
- # Virtual environment
13
- venv/
14
- env/
15
- .env
16
-
17
- # IDE files
18
- .vscode/
19
- .idea/
20
- *.swp
21
- *.swo
22
-
23
- # OS files
24
- .DS_Store
25
- Thumbs.db
26
-
27
- # Logs
28
- *.log
29
-
30
- # Temporary files
31
- *.tmp
32
- *.temp
@@ -1,112 +0,0 @@
1
- # BRAIN Project - Modular Structure
2
-
3
- This document describes the modular structure implemented for the BRAIN Expression Template Decoder application.
4
-
5
- ## Overview
6
-
7
- The application has been refactored to use Flask blueprints for better code organization and maintainability. The application is divided into several functional modules including paper analysis, feature engineering, idea generation, and inspiration.
8
-
9
- ## Project Structure
10
-
11
- ```
12
- BRAINProject/
13
- ├── 运行打开我.py # Main Flask application entry point
14
- ├── blueprints/ # Blueprint modules
15
- │ ├── __init__.py # Package initialization
16
- │ ├── feature_engineering.py # Feature engineering blueprint
17
- │ ├── idea_house.py # Idea house blueprint (Coze integration)
18
- │ ├── inspiration_house.py # Inspiration house blueprint
19
- │ └── paper_analysis.py # Paper analysis blueprint
20
- ├── templates/
21
- │ ├── index.html # Main page template
22
- │ ├── feature_engineering.html # Feature engineering page template
23
- │ ├── idea_house.html # Idea house page template
24
- │ ├── inspiration_house.html # Inspiration house page template
25
- │ └── paper_analysis.html # Paper analysis page template
26
- ├── static/
27
- │ ├── script.js # Main application JavaScript
28
- │ ├── feature_engineering.js # Feature engineering JavaScript
29
- │ ├── idea_house.js # Idea house JavaScript
30
- │ ├── inspiration_house.js # Inspiration house JavaScript
31
- │ ├── paper_analysis.js # Paper analysis JavaScript
32
- │ ├── brain.js # BRAIN API functions
33
- │ ├── decoder.js # Template decoder functions
34
- │ └── styles.css # Application styles
35
- └── requirements.txt # Python dependencies
36
- ```
37
-
38
- ## Blueprint Structure
39
-
40
- ### Paper Analysis Blueprint (`blueprints/paper_analysis.py`)
41
- Handles paper analysis functionality.
42
- - Routes: `/paper-analysis/`
43
- - Features: File processing (PDF, DOCX, etc.), Deepseek API integration.
44
-
45
- ### Feature Engineering Blueprint (`blueprints/feature_engineering.py`)
46
- Handles feature engineering tasks.
47
- - Routes: `/feature-engineering/`
48
- - Features: Deepseek/Kimi API integration for feature generation.
49
-
50
- ### Idea House Blueprint (`blueprints/idea_house.py`)
51
- Handles idea generation using Coze API.
52
- - Routes: `/idea-house/`
53
- - Features: Coze API integration for processing data fields.
54
-
55
- ### Inspiration House Blueprint (`blueprints/inspiration_house.py`)
56
- Handles inspiration generation.
57
- - Routes: `/inspiration-house/`
58
- - Features: Deepseek/Kimi API integration.
59
-
60
- ### Main Application (`运行打开我.py`)
61
- The main application entry point.
62
- - Routes: Main application routes, BRAIN API authentication.
63
- - Features: Auto-dependency installation, Blueprint registration.
64
-
65
- ## Benefits of This Structure
66
-
67
- 1. **Modularity**: Related functionality is grouped together in blueprints
68
- 2. **Maintainability**: Easier to maintain and update individual modules
69
- 3. **Scalability**: Easy to add new blueprints for additional features
70
- 4. **Separation of Concerns**: Each blueprint handles a specific domain
71
- 5. **Testability**: Individual modules can be tested independently
72
-
73
-
74
- ## Dependencies
75
-
76
- ### Main Application Dependencies:
77
- - Flask
78
- - Flask-CORS
79
- - requests
80
- - pandas (for BRAIN API integration)
81
-
82
- ### Module Specific Dependencies:
83
- - **Paper Analysis**: PyPDF2, pdfplumber, python-docx, docx2txt, striprtf, PyMuPDF
84
- - **Idea House**: cozepy (for Coze API)
85
-
86
- ## Adding New Blueprints
87
-
88
- To add a new blueprint:
89
-
90
- 1. Create a new file in the `blueprints/` directory
91
- 2. Define your blueprint:
92
- ```python
93
- from flask import Blueprint
94
-
95
- new_blueprint = Blueprint('new_feature', __name__, url_prefix='/new-feature')
96
-
97
- @new_blueprint.route('/')
98
- def index():
99
- return render_template('new_feature.html')
100
- ```
101
- 3. Import and register the blueprint in the main application file (`运行打开我.py`):
102
- ```python
103
- from blueprints.new_feature import new_blueprint
104
- app.register_blueprint(new_blueprint)
105
- ```
106
-
107
- ## Notes
108
-
109
- - The paper analysis JavaScript file (`static/paper_analysis.js`) has been updated to use the new blueprint URLs
110
- - The main index template has been updated to link to the correct blueprint route
111
- - Unused imports have been removed from the main application file
112
- - All paper analysis functionality remains intact but is now properly modularized