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,465 +0,0 @@
1
- /**
2
- * Inspiration Master - Frontend Logic
3
- */
4
-
5
- // Global state for inspiration feature
6
- let inspirationState = {
7
- isLoggedIn: false,
8
- llmConfig: {
9
- baseUrl: "https://api.moonshot.cn/v1",
10
- model: "kimi-k2-turbo-preview",
11
- apiKey: ""
12
- },
13
- options: null,
14
- selectedDataset: null
15
- };
16
-
17
- document.addEventListener('DOMContentLoaded', function() {
18
- const inspirationBtn = document.getElementById('inspirationBtn');
19
- if (inspirationBtn) {
20
- inspirationBtn.addEventListener('click', openInspirationModal);
21
- }
22
-
23
- // Initialize event listeners for the modal
24
- document.getElementById('inspire-region').addEventListener('change', updateUniversesAndDelays);
25
- document.getElementById('inspire-search-dataset').addEventListener('click', searchDatasets);
26
- document.getElementById('inspire-generate').addEventListener('click', generateAlphaTemplates);
27
- document.getElementById('inspire-download').addEventListener('click', downloadInspirationResult);
28
- document.getElementById('inspire-new-task').addEventListener('click', resetInspirationTask);
29
- document.getElementById('inspire-close').addEventListener('click', closeInspirationModal);
30
-
31
- const testBtn = document.getElementById('inspire-test-llm');
32
- if (testBtn) {
33
- testBtn.addEventListener('click', testLLMConnection);
34
- }
35
-
36
- // Initially disable generate button until tested
37
- const genBtn = document.getElementById('inspire-generate');
38
- if (genBtn) {
39
- genBtn.disabled = true;
40
- genBtn.title = "Please test LLM connection first";
41
- }
42
-
43
- // Initially disable new task button
44
- const newTaskBtn = document.getElementById('inspire-new-task');
45
- if (newTaskBtn) {
46
- newTaskBtn.disabled = true;
47
- newTaskBtn.style.opacity = '0.5';
48
- newTaskBtn.style.cursor = 'not-allowed';
49
- }
50
-
51
- // Check login status periodically or on load to update button state
52
- checkLoginAndUpdateButton();
53
- });
54
-
55
- function getHeaders() {
56
- const headers = {'Content-Type': 'application/json'};
57
- const sessionId = localStorage.getItem('brain_session_id');
58
- if (sessionId) {
59
- headers['Session-ID'] = sessionId;
60
- }
61
- return headers;
62
- }
63
-
64
- function checkLoginAndUpdateButton() {
65
- fetch('/api/check_login', { headers: getHeaders() })
66
- .then(response => response.json())
67
- .then(data => {
68
- const btn = document.getElementById('inspirationBtn');
69
- if (data.logged_in) {
70
- inspirationState.isLoggedIn = true;
71
- if (btn) {
72
- btn.style.opacity = '1';
73
- btn.style.cursor = 'pointer';
74
- // Add a visual indicator of logged-in state if desired, e.g., change icon color
75
- }
76
- } else {
77
- inspirationState.isLoggedIn = false;
78
- if (btn) {
79
- // Keep it clickable but maybe visually distinct
80
- btn.style.opacity = '1';
81
- btn.style.cursor = 'pointer';
82
- }
83
- }
84
- // Always ensure it's enabled
85
- if (btn) btn.disabled = false;
86
- })
87
- .catch(err => console.error("Error checking login status:", err));
88
- }
89
-
90
- // Expose this function globally so other scripts (like brain.js) can call it after login
91
- window.updateInspirationButtonState = checkLoginAndUpdateButton;
92
-
93
- function openInspirationModal() {
94
- if (!inspirationState.isLoggedIn) {
95
- // Double check
96
- fetch('/api/check_login', { headers: getHeaders() })
97
- .then(response => response.json())
98
- .then(data => {
99
- if (data.logged_in) {
100
- inspirationState.isLoggedIn = true;
101
- document.getElementById('inspirationModal').style.display = 'block';
102
- loadInspirationOptions();
103
- } else {
104
- // Trigger Brain Login Modal
105
- if (typeof openBrainLoginModal === 'function') {
106
- openBrainLoginModal();
107
- } else {
108
- alert("请先登录 BRAIN。");
109
- }
110
- }
111
- });
112
- return;
113
- }
114
- document.getElementById('inspirationModal').style.display = 'block';
115
- loadInspirationOptions();
116
- }
117
-
118
- function closeInspirationModal() {
119
- document.getElementById('inspirationModal').style.display = 'none';
120
- }
121
-
122
- function loadInspirationOptions() {
123
- if (inspirationState.options) return; // Already loaded
124
-
125
- fetch('/api/inspiration/options', { headers: getHeaders() })
126
- .then(res => res.json())
127
- .then(data => {
128
- inspirationState.options = data;
129
- populateRegionDropdown(data);
130
- })
131
- .catch(err => console.error("Failed to load options:", err));
132
- }
133
-
134
- function populateRegionDropdown(data) {
135
- const regionSelect = document.getElementById('inspire-region');
136
- regionSelect.innerHTML = '<option value="">Select Region</option>';
137
-
138
- // Assuming data structure matches what we get from ace_lib
139
- // Structure: { "EQUITY": { "USA": { ... }, "CHN": { ... } } }
140
- // We'll focus on EQUITY for now or iterate all
141
-
142
- let regions = new Set();
143
- if (data.EQUITY) {
144
- Object.keys(data.EQUITY).forEach(r => regions.add(r));
145
- }
146
-
147
- regions.forEach(r => {
148
- const option = document.createElement('option');
149
- option.value = r;
150
- option.textContent = r;
151
- regionSelect.appendChild(option);
152
- });
153
- }
154
-
155
- function updateUniversesAndDelays() {
156
- const region = document.getElementById('inspire-region').value;
157
- const universeSelect = document.getElementById('inspire-universe');
158
- const delaySelect = document.getElementById('inspire-delay');
159
-
160
- universeSelect.innerHTML = '<option value="">Select Universe</option>';
161
- delaySelect.innerHTML = '<option value="">Select Delay</option>';
162
-
163
- if (!region || !inspirationState.options || !inspirationState.options.EQUITY || !inspirationState.options.EQUITY[region]) return;
164
-
165
- const data = inspirationState.options.EQUITY[region];
166
-
167
- data.universes.forEach(u => {
168
- const option = document.createElement('option');
169
- option.value = u;
170
- option.textContent = u;
171
- universeSelect.appendChild(option);
172
- });
173
-
174
- data.delays.forEach(d => {
175
- const option = document.createElement('option');
176
- option.value = d;
177
- option.textContent = d;
178
- delaySelect.appendChild(option);
179
- });
180
- }
181
-
182
- function searchDatasets() {
183
- const region = document.getElementById('inspire-region').value;
184
- const delay = document.getElementById('inspire-delay').value;
185
- const universe = document.getElementById('inspire-universe').value;
186
- const search = document.getElementById('inspire-dataset-search').value;
187
-
188
- if (!region || !delay || !universe) {
189
- alert("请先选择区域、延迟和股票池。");
190
- return;
191
- }
192
-
193
- const resultsDiv = document.getElementById('inspire-dataset-results');
194
- resultsDiv.innerHTML = '正在加载数据集...';
195
-
196
- fetch('/api/inspiration/datasets', {
197
- method: 'POST',
198
- headers: getHeaders(),
199
- body: JSON.stringify({ region, delay, universe, search })
200
- })
201
- .then(res => res.json())
202
- .then(data => {
203
- displayDatasetResults(data);
204
- })
205
- .catch(err => {
206
- resultsDiv.innerHTML = '加载数据集出错: ' + err;
207
- });
208
- }
209
-
210
- function displayDatasetResults(datasets) {
211
- const resultsDiv = document.getElementById('inspire-dataset-results');
212
- resultsDiv.innerHTML = '';
213
-
214
- if (datasets.length === 0) {
215
- resultsDiv.innerHTML = '未找到数据集。';
216
- return;
217
- }
218
-
219
- const table = document.createElement('table');
220
- table.className = 'dataset-table';
221
- table.style.width = '100%'; // Ensure full width
222
- table.style.borderCollapse = 'collapse';
223
-
224
- table.innerHTML = `
225
- <thead>
226
- <tr style="text-align: left; background: #f1f1f1;">
227
- <th style="padding: 8px; border-bottom: 1px solid #ddd;">ID</th>
228
- <th style="padding: 8px; border-bottom: 1px solid #ddd;">Name</th>
229
- <th style="padding: 8px; border-bottom: 1px solid #ddd;">Category</th>
230
- </tr>
231
- </thead>
232
- <tbody></tbody>
233
- `;
234
-
235
- const tbody = table.querySelector('tbody');
236
-
237
- datasets.forEach(ds => {
238
- const tr = document.createElement('tr');
239
- tr.dataset.id = ds.id;
240
- tr.style.cursor = 'pointer';
241
- tr.style.transition = 'background-color 0.2s';
242
-
243
- // Fix [object Object] issue for category
244
- let category = ds.category;
245
- if (typeof category === 'object' && category !== null) {
246
- // Try to find a meaningful string representation
247
- category = category.name || category.id || JSON.stringify(category);
248
- }
249
-
250
- tr.innerHTML = `
251
- <td style="padding: 8px; border-bottom: 1px solid #eee; color: #007bff; font-weight: bold;">${ds.id}</td>
252
- <td style="padding: 8px; border-bottom: 1px solid #eee;">${ds.name}</td>
253
- <td style="padding: 8px; border-bottom: 1px solid #eee;">${category}</td>
254
- `;
255
-
256
- tr.addEventListener('click', function() {
257
- selectDataset(ds.id);
258
- });
259
-
260
- tr.addEventListener('mouseenter', function() {
261
- if (inspirationState.selectedDataset !== ds.id) {
262
- this.style.backgroundColor = '#f8f9fa';
263
- }
264
- });
265
-
266
- tr.addEventListener('mouseleave', function() {
267
- if (inspirationState.selectedDataset !== ds.id) {
268
- this.style.backgroundColor = '';
269
- }
270
- });
271
-
272
- tbody.appendChild(tr);
273
- });
274
-
275
- resultsDiv.appendChild(table);
276
- }
277
-
278
- function selectDataset(id) {
279
- inspirationState.selectedDataset = id;
280
- const display = document.getElementById('inspire-selected-dataset');
281
- if (display) {
282
- display.textContent = "已选数据集: " + id;
283
- display.style.display = 'block';
284
- }
285
-
286
- // Highlight the selected row
287
- document.querySelectorAll('.dataset-table tr').forEach(tr => tr.style.backgroundColor = '');
288
- const row = document.querySelector(`.dataset-table tr[data-id="${id}"]`);
289
- if (row) {
290
- row.style.backgroundColor = '#e7f1ff';
291
- }
292
- }
293
-
294
- // Removed toggleAccordion as we are moving to a horizontal layout
295
-
296
- function generateAlphaTemplates() {
297
- if (!inspirationState.selectedDataset) {
298
- alert("请先选择一个数据集。");
299
- return;
300
- }
301
-
302
- const apiKey = document.getElementById('inspire-llm-key').value;
303
- const baseUrl = document.getElementById('inspire-llm-url').value;
304
- const model = document.getElementById('inspire-llm-model').value;
305
-
306
- if (!apiKey) {
307
- alert("请输入 LLM API Key。");
308
- return;
309
- }
310
-
311
- const region = document.getElementById('inspire-region').value;
312
- const delay = document.getElementById('inspire-delay').value;
313
- const universe = document.getElementById('inspire-universe').value;
314
-
315
- const outputDiv = document.getElementById('inspire-output');
316
- outputDiv.innerHTML = '正在生成模板... 这可能需要几分钟...';
317
-
318
- fetch('/api/inspiration/generate', {
319
- method: 'POST',
320
- headers: getHeaders(),
321
- body: JSON.stringify({
322
- apiKey, baseUrl, model,
323
- region, delay, universe,
324
- datasetId: inspirationState.selectedDataset
325
- })
326
- })
327
- .then(res => res.json())
328
- .then(data => {
329
- if (data.error) {
330
- outputDiv.innerHTML = '错误: ' + data.error;
331
- } else {
332
- // Render Markdown
333
- // Assuming marked.js or similar is available, or just text for now
334
- // If you have a markdown renderer, use it.
335
- // For now, simple text or basic HTML replacement
336
- outputDiv.innerHTML = formatMarkdown(data.result);
337
- inspirationState.lastResult = data.result;
338
- const dlBtn = document.getElementById('inspire-download');
339
- if (dlBtn) dlBtn.style.display = 'inline-block';
340
-
341
- const newTaskBtn = document.getElementById('inspire-new-task');
342
- if (newTaskBtn) {
343
- newTaskBtn.disabled = false;
344
- newTaskBtn.style.opacity = '1';
345
- newTaskBtn.style.cursor = 'pointer';
346
- }
347
- }
348
- })
349
- .catch(err => {
350
- outputDiv.innerHTML = '生成模板出错: ' + err;
351
- });
352
- }
353
-
354
- function formatMarkdown(text) {
355
- if (typeof marked !== 'undefined') {
356
- // Split text by code blocks (triple backticks or single backticks)
357
- // We want to escape < and > in normal text, but NOT in code blocks
358
- const parts = text.split(/(```[\s\S]*?```|`[^`]*`)/g);
359
-
360
- const escapedParts = parts.map(part => {
361
- // If it starts with backtick, it's a code block -> return as is
362
- if (part.startsWith('`')) {
363
- return part;
364
- }
365
- // Otherwise, escape < and >
366
- return part.replace(/</g, '&lt;').replace(/>/g, '&gt;');
367
- });
368
-
369
- return marked.parse(escapedParts.join(''));
370
- }
371
-
372
- // Fallback simple formatter
373
- // Here we DO need to escape because we are building HTML manually
374
- const escapedText = text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
375
- let html = escapedText
376
- .replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>')
377
- .replace(/\n/g, '<br>');
378
- return html;
379
- }
380
-
381
- function testLLMConnection() {
382
- const apiKey = document.getElementById('inspire-llm-key').value;
383
- const baseUrl = document.getElementById('inspire-llm-url').value;
384
- const model = document.getElementById('inspire-llm-model').value;
385
- const testBtn = document.getElementById('inspire-test-llm');
386
- const generateBtn = document.getElementById('inspire-generate');
387
-
388
- if (!apiKey) {
389
- alert("请先输入 API Key。");
390
- return;
391
- }
392
-
393
- testBtn.textContent = "测试中...";
394
- testBtn.disabled = true;
395
-
396
- fetch('/api/inspiration/test_llm', {
397
- method: 'POST',
398
- headers: getHeaders(),
399
- body: JSON.stringify({ apiKey, baseUrl, model })
400
- })
401
- .then(res => res.json())
402
- .then(data => {
403
- testBtn.disabled = false;
404
- if (data.success) {
405
- testBtn.textContent = "成功";
406
- testBtn.className = "btn btn-success";
407
- generateBtn.disabled = false;
408
- setTimeout(() => { testBtn.textContent = "测试连接"; testBtn.className = "btn btn-secondary"; }, 3000);
409
- } else {
410
- testBtn.textContent = "失败";
411
- testBtn.className = "btn btn-danger";
412
- alert("连接失败: " + data.error);
413
- generateBtn.disabled = true;
414
- setTimeout(() => { testBtn.textContent = "测试连接"; testBtn.className = "btn btn-secondary"; }, 3000);
415
- }
416
- })
417
- .catch(err => {
418
- testBtn.disabled = false;
419
- testBtn.textContent = "错误";
420
- alert("错误: " + err);
421
- });
422
- }
423
-
424
- function downloadInspirationResult() {
425
- if (!inspirationState.lastResult) return;
426
-
427
- const blob = new Blob([inspirationState.lastResult], { type: 'text/markdown' });
428
- const url = URL.createObjectURL(blob);
429
- const a = document.createElement('a');
430
- a.href = url;
431
- a.download = `alpha_inspiration_${inspirationState.selectedDataset}.md`;
432
- document.body.appendChild(a);
433
- a.click();
434
- document.body.removeChild(a);
435
- URL.revokeObjectURL(url);
436
- }
437
-
438
- function resetInspirationTask() {
439
- inspirationState.selectedDataset = null;
440
- const display = document.getElementById('inspire-selected-dataset');
441
- if (display) {
442
- display.textContent = "";
443
- display.style.display = 'none';
444
- }
445
- document.getElementById('inspire-output').innerHTML = "";
446
- document.getElementById('inspire-dataset-results').innerHTML = "";
447
-
448
- const dlBtn = document.getElementById('inspire-download');
449
- if (dlBtn) dlBtn.style.display = 'none';
450
-
451
- const newTaskBtn = document.getElementById('inspire-new-task');
452
- if (newTaskBtn) {
453
- newTaskBtn.disabled = true;
454
- newTaskBtn.style.opacity = '0.5';
455
- newTaskBtn.style.cursor = 'not-allowed';
456
- }
457
- // Keep LLM config and Region/Universe selections
458
- }
459
-
460
- function toggleInspireColumn(colId) {
461
- const col = document.getElementById(colId);
462
- if (col) {
463
- col.classList.toggle('collapsed');
464
- }
465
- }