cnhkmcp 2.2.0__py3-none-any.whl → 2.3.0__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 (96) hide show
  1. cnhkmcp/__init__.py +1 -1
  2. 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 +1 -1
  3. 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 +2 -2
  4. 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 +1 -1
  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/vector_db/chroma.sqlite3 +0 -0
  6. cnhkmcp/untracked/APP/Tranformer/Transformer.py +2 -2
  7. cnhkmcp/untracked/APP/Tranformer/transformer_config.json +1 -1
  8. cnhkmcp/untracked/APP/blueprints/feature_engineering.py +2 -2
  9. cnhkmcp/untracked/APP/blueprints/inspiration_house.py +4 -4
  10. cnhkmcp/untracked/APP/blueprints/paper_analysis.py +3 -3
  11. cnhkmcp/untracked/APP/give_me_idea/BRAIN_Alpha_Template_Expert_SystemPrompt.md +34 -73
  12. cnhkmcp/untracked/APP/give_me_idea/alpha_data_specific_template_master.py +2 -2
  13. cnhkmcp/untracked/APP/give_me_idea/what_is_Alpha_template.md +366 -1
  14. cnhkmcp/untracked/APP/static/inspiration.js +345 -13
  15. cnhkmcp/untracked/APP/templates/index.html +11 -3
  16. cnhkmcp/untracked/APP/templates/transformer_web.html +1 -1
  17. cnhkmcp/untracked/APP/trailSomeAlphas/README.md +38 -0
  18. cnhkmcp/untracked/APP/trailSomeAlphas/ace.log +66 -0
  19. cnhkmcp/untracked/APP/trailSomeAlphas/enhance_template.py +588 -0
  20. cnhkmcp/untracked/APP/trailSomeAlphas/requirements.txt +3 -0
  21. cnhkmcp/untracked/APP/trailSomeAlphas/run_pipeline.py +1001 -0
  22. cnhkmcp/untracked/APP/trailSomeAlphas/run_pipeline_step_by_step.ipynb +5258 -0
  23. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-data-feature-engineering/OUTPUT_TEMPLATE.md +325 -0
  24. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-data-feature-engineering/SKILL.md +503 -0
  25. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-data-feature-engineering/examples.md +244 -0
  26. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-data-feature-engineering/output_report/ASI_delay1_analyst11_ideas.md +285 -0
  27. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-data-feature-engineering/reference.md +399 -0
  28. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/SKILL.md +40 -0
  29. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/config.json +6 -0
  30. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709385783386000.json +388 -0
  31. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709386274840400.json +131 -0
  32. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709386838244700.json +1926 -0
  33. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709387369198500.json +31 -0
  34. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709387908905800.json +1926 -0
  35. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709388486243600.json +240 -0
  36. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709389024058600.json +1926 -0
  37. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709389549608700.json +41 -0
  38. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709390068714000.json +110 -0
  39. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709390591996900.json +36 -0
  40. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709391129137100.json +31 -0
  41. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709391691643500.json +41 -0
  42. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709392192099200.json +31 -0
  43. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709392703423500.json +46 -0
  44. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769709393213729400.json +246 -0
  45. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710186683932500.json +388 -0
  46. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710187165414300.json +131 -0
  47. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710187665211700.json +1926 -0
  48. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710188149193400.json +31 -0
  49. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710188667627400.json +1926 -0
  50. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710189220822000.json +240 -0
  51. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710189726189500.json +1926 -0
  52. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710190248066100.json +41 -0
  53. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710190768298700.json +110 -0
  54. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710191282588100.json +36 -0
  55. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710191838960900.json +31 -0
  56. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710192396688000.json +41 -0
  57. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710192941922400.json +31 -0
  58. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710193473524600.json +46 -0
  59. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710194001961200.json +246 -0
  60. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710420975888800.json +46 -0
  61. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710421647590100.json +196 -0
  62. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710422131378500.json +5 -0
  63. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710422644184400.json +196 -0
  64. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710423702350600.json +196 -0
  65. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_1_idea_1769710424244661800.json +5 -0
  66. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/analyst11_ASI_delay1.csv +211 -0
  67. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/data/analyst11_ASI_delay1/final_expressions.json +7062 -0
  68. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/ace.log +3 -0
  69. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/ace_lib.py +1514 -0
  70. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/fetch_dataset.py +113 -0
  71. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/helpful_functions.py +180 -0
  72. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/implement_idea.py +236 -0
  73. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/merge_expression_list.py +90 -0
  74. cnhkmcp/untracked/APP/trailSomeAlphas/skills/brain-feature-implementation/scripts/parsetab.py +60 -0
  75. cnhkmcp/untracked/APP/trailSomeAlphas/skills/template_final_enhance/op/321/206/320/220/342/225/227/321/207/342/225/227/320/243.md +434 -0
  76. cnhkmcp/untracked/APP/trailSomeAlphas/skills/template_final_enhance/sample_prompt.md +62 -0
  77. cnhkmcp/untracked/APP/trailSomeAlphas/skills/template_final_enhance//321/205/320/235/320/245/321/205/320/253/320/260/321/205/320/275/320/240/321/206/320/220/320/255/321/210/320/220/320/223/321/211/320/220/342/225/227/321/210/342/225/233/320/241/321/211/320/243/342/225/233.md +354 -0
  78. cnhkmcp/untracked/APP/usage.md +2 -2
  79. 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 +388 -8
  80. cnhkmcp/untracked/skills/alpha-expression-verifier/scripts/validator.py +889 -0
  81. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/implement_idea.py +4 -3
  82. cnhkmcp/untracked/skills/brain-improve-alpha-performance/arXiv_API_Tool_Manual.md +490 -0
  83. cnhkmcp/untracked/skills/brain-improve-alpha-performance/reference.md +1 -1
  84. cnhkmcp/untracked/skills/brain-improve-alpha-performance/scripts/arxiv_api.py +229 -0
  85. 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 +35 -11
  86. cnhkmcp/vector_db/_manifest.json +1 -0
  87. cnhkmcp/vector_db/_meta.json +1 -0
  88. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/METADATA +1 -1
  89. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/RECORD +96 -30
  90. /cnhkmcp/untracked/{skills/expression_verifier → APP/trailSomeAlphas/skills/brain-feature-implementation}/scripts/validator.py +0 -0
  91. /cnhkmcp/untracked/skills/{expression_verifier → alpha-expression-verifier}/SKILL.md +0 -0
  92. /cnhkmcp/untracked/skills/{expression_verifier → alpha-expression-verifier}/scripts/verify_expr.py +0 -0
  93. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/WHEEL +0 -0
  94. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/entry_points.txt +0 -0
  95. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/licenses/LICENSE +0 -0
  96. {cnhkmcp-2.2.0.dist-info → cnhkmcp-2.3.0.dist-info}/top_level.txt +0 -0
@@ -7,11 +7,15 @@ let inspirationState = {
7
7
  isLoggedIn: false,
8
8
  llmConfig: {
9
9
  baseUrl: "https://api.moonshot.cn/v1",
10
- model: "kimi-k2-turbo-preview",
10
+ model: "kimi-k2.5",
11
11
  apiKey: ""
12
12
  },
13
13
  options: null,
14
- selectedDataset: null
14
+ selectedDataset: null,
15
+ selectedDatasetCategory: null,
16
+ pipelineTaskId: null,
17
+ pipelineEventSource: null,
18
+ enhanceTaskId: null
15
19
  };
16
20
 
17
21
  document.addEventListener('DOMContentLoaded', function() {
@@ -27,11 +31,34 @@ document.addEventListener('DOMContentLoaded', function() {
27
31
  document.getElementById('inspire-download').addEventListener('click', downloadInspirationResult);
28
32
  document.getElementById('inspire-new-task').addEventListener('click', resetInspirationTask);
29
33
  document.getElementById('inspire-close').addEventListener('click', closeInspirationModal);
34
+ const directBtn = document.getElementById('inspire-direct');
35
+ if (directBtn) {
36
+ directBtn.addEventListener('click', runDirectAlphaPipeline);
37
+ }
38
+ const directDlBtn = document.getElementById('inspire-direct-download');
39
+ if (directDlBtn) {
40
+ directDlBtn.addEventListener('click', downloadPipelineZip);
41
+ }
30
42
 
31
43
  const testBtn = document.getElementById('inspire-test-llm');
32
44
  if (testBtn) {
33
45
  testBtn.addEventListener('click', testLLMConnection);
34
46
  }
47
+ const enhanceBtn = document.getElementById('inspire-enhance');
48
+ if (enhanceBtn) {
49
+ enhanceBtn.addEventListener('click', () => {
50
+ const input = document.getElementById('inspire-idea-file');
51
+ if (input) input.click();
52
+ });
53
+ }
54
+ const enhanceInput = document.getElementById('inspire-idea-file');
55
+ if (enhanceInput) {
56
+ enhanceInput.addEventListener('change', handleEnhanceFile);
57
+ }
58
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
59
+ if (enhanceDlBtn) {
60
+ enhanceDlBtn.addEventListener('click', downloadEnhanceZip);
61
+ }
35
62
 
36
63
  // Initially disable generate button until tested
37
64
  const genBtn = document.getElementById('inspire-generate');
@@ -47,7 +74,7 @@ document.addEventListener('DOMContentLoaded', function() {
47
74
  newTaskBtn.style.opacity = '0.5';
48
75
  newTaskBtn.style.cursor = 'not-allowed';
49
76
  }
50
-
77
+
51
78
  // Check login status periodically or on load to update button state
52
79
  checkLoginAndUpdateButton();
53
80
  });
@@ -71,20 +98,26 @@ function checkLoginAndUpdateButton() {
71
98
  if (btn) {
72
99
  btn.style.opacity = '1';
73
100
  btn.style.cursor = 'pointer';
74
- // Add a visual indicator of logged-in state if desired, e.g., change icon color
101
+ btn.disabled = false;
75
102
  }
76
103
  } else {
77
104
  inspirationState.isLoggedIn = false;
78
105
  if (btn) {
79
- // Keep it clickable but maybe visually distinct
80
- btn.style.opacity = '1';
81
- btn.style.cursor = 'pointer';
106
+ btn.style.opacity = '0.5';
107
+ btn.style.cursor = 'not-allowed';
108
+ btn.disabled = true;
82
109
  }
83
110
  }
84
- // Always ensure it's enabled
85
- if (btn) btn.disabled = false;
86
111
  })
87
- .catch(err => console.error("Error checking login status:", err));
112
+ .catch(err => {
113
+ console.error("Error checking login status:", err);
114
+ const btn = document.getElementById('inspirationBtn');
115
+ if (btn) {
116
+ btn.disabled = true;
117
+ btn.style.opacity = '0.5';
118
+ btn.style.cursor = 'not-allowed';
119
+ }
120
+ });
88
121
  }
89
122
 
90
123
  // Expose this function globally so other scripts (like brain.js) can call it after login
@@ -114,7 +147,6 @@ function openInspirationModal() {
114
147
  document.getElementById('inspirationModal').style.display = 'block';
115
148
  loadInspirationOptions();
116
149
  }
117
-
118
150
  function closeInspirationModal() {
119
151
  document.getElementById('inspirationModal').style.display = 'none';
120
152
  }
@@ -254,7 +286,7 @@ function displayDatasetResults(datasets) {
254
286
  `;
255
287
 
256
288
  tr.addEventListener('click', function() {
257
- selectDataset(ds.id);
289
+ selectDataset(ds.id, category);
258
290
  });
259
291
 
260
292
  tr.addEventListener('mouseenter', function() {
@@ -275,8 +307,9 @@ function displayDatasetResults(datasets) {
275
307
  resultsDiv.appendChild(table);
276
308
  }
277
309
 
278
- function selectDataset(id) {
310
+ function selectDataset(id, category) {
279
311
  inspirationState.selectedDataset = id;
312
+ inspirationState.selectedDatasetCategory = category || null;
280
313
  const display = document.getElementById('inspire-selected-dataset');
281
314
  if (display) {
282
315
  display.textContent = "已选数据集: " + id;
@@ -351,6 +384,156 @@ function generateAlphaTemplates() {
351
384
  });
352
385
  }
353
386
 
387
+ function runDirectAlphaPipeline() {
388
+ if (!inspirationState.selectedDataset) {
389
+ alert("请先选择一个数据集。");
390
+ return;
391
+ }
392
+
393
+ const region = document.getElementById('inspire-region').value;
394
+ const delay = document.getElementById('inspire-delay').value;
395
+ const universe = document.getElementById('inspire-universe').value;
396
+ const dataCategory = inspirationState.selectedDatasetCategory;
397
+
398
+ if (!region || !delay || !universe) {
399
+ alert("请先选择区域、延迟和股票池。");
400
+ return;
401
+ }
402
+
403
+ if (!dataCategory) {
404
+ alert("当前数据集没有可用的分类信息,无法运行。请重新搜索并选择数据集。");
405
+ return;
406
+ }
407
+
408
+ const apiKey = document.getElementById('inspire-llm-key').value;
409
+ const baseUrl = document.getElementById('inspire-llm-url').value;
410
+ const model = document.getElementById('inspire-llm-model').value;
411
+
412
+ if (!apiKey) {
413
+ alert('请先填写 LLM API Key。');
414
+ return;
415
+ }
416
+
417
+ const outputDiv = document.getElementById('inspire-output');
418
+ outputDiv.innerHTML = '<pre id="inspire-stream" style="white-space: pre-wrap; margin: 0;"></pre>';
419
+
420
+ const directBtn = document.getElementById('inspire-direct');
421
+ if (directBtn) {
422
+ directBtn.disabled = true;
423
+ directBtn.textContent = '正在运行...';
424
+ }
425
+
426
+ const dlBtn = document.getElementById('inspire-direct-download');
427
+ if (dlBtn) dlBtn.style.display = 'none';
428
+
429
+ if (inspirationState.pipelineEventSource) {
430
+ inspirationState.pipelineEventSource.close();
431
+ inspirationState.pipelineEventSource = null;
432
+ }
433
+
434
+ fetch('/api/inspiration/run-pipeline', {
435
+ method: 'POST',
436
+ headers: getHeaders(),
437
+ body: JSON.stringify({
438
+ datasetId: inspirationState.selectedDataset,
439
+ dataCategory,
440
+ region,
441
+ delay,
442
+ universe,
443
+ apiKey,
444
+ baseUrl,
445
+ model
446
+ })
447
+ })
448
+ .then(res => res.json())
449
+ .then(data => {
450
+ if (!data.success) {
451
+ outputDiv.innerHTML = '启动失败: ' + (data.error || '未知错误');
452
+ if (directBtn) {
453
+ directBtn.disabled = false;
454
+ directBtn.textContent = '直接来点 Alpha';
455
+ }
456
+ return;
457
+ }
458
+
459
+ inspirationState.pipelineTaskId = data.taskId;
460
+ startPipelineStream(data.taskId);
461
+ })
462
+ .catch(err => {
463
+ outputDiv.innerHTML = '启动出错: ' + err;
464
+ if (directBtn) {
465
+ directBtn.disabled = false;
466
+ directBtn.textContent = '直接来点 Alpha';
467
+ }
468
+ });
469
+ }
470
+
471
+ function startPipelineStream(taskId) {
472
+ const streamEl = document.getElementById('inspire-stream');
473
+ const outputDiv = document.getElementById('inspire-output');
474
+ if (!streamEl) {
475
+ outputDiv.innerHTML = '<pre id="inspire-stream" style="white-space: pre-wrap; margin: 0;"></pre>';
476
+ }
477
+ const target = document.getElementById('inspire-stream');
478
+
479
+ const source = new EventSource(`/api/inspiration/stream-pipeline/${taskId}`);
480
+ inspirationState.pipelineEventSource = source;
481
+
482
+ source.onmessage = (event) => {
483
+ try {
484
+ const payload = JSON.parse(event.data);
485
+ if (payload && payload.line !== undefined) {
486
+ target.textContent += payload.line + '\n';
487
+ outputDiv.scrollTop = outputDiv.scrollHeight;
488
+ }
489
+ } catch {
490
+ target.textContent += event.data + '\n';
491
+ outputDiv.scrollTop = outputDiv.scrollHeight;
492
+ }
493
+ };
494
+
495
+ source.addEventListener('done', (event) => {
496
+ let info = null;
497
+ try {
498
+ info = JSON.parse(event.data);
499
+ } catch {
500
+ info = { success: false };
501
+ }
502
+ const directBtn = document.getElementById('inspire-direct');
503
+ if (directBtn) {
504
+ directBtn.disabled = false;
505
+ directBtn.textContent = '直接来点 Alpha';
506
+ }
507
+
508
+ if (info && info.success) {
509
+ target.textContent += '\n✅ 运行完成,可下载结果 ZIP。\n';
510
+ const dlBtn = document.getElementById('inspire-direct-download');
511
+ if (dlBtn) dlBtn.style.display = 'inline-block';
512
+ } else {
513
+ target.textContent += '\n❌ 运行失败,请检查日志。\n';
514
+ }
515
+
516
+ source.close();
517
+ inspirationState.pipelineEventSource = null;
518
+ });
519
+
520
+ source.addEventListener('error', () => {
521
+ const directBtn = document.getElementById('inspire-direct');
522
+ if (directBtn) {
523
+ directBtn.disabled = false;
524
+ directBtn.textContent = '直接来点 Alpha';
525
+ }
526
+ target.textContent += '\n⚠️ 日志流中断。\n';
527
+ source.close();
528
+ inspirationState.pipelineEventSource = null;
529
+ });
530
+ }
531
+
532
+ function downloadPipelineZip() {
533
+ if (!inspirationState.pipelineTaskId) return;
534
+ window.location.href = `/api/inspiration/download-pipeline/${inspirationState.pipelineTaskId}`;
535
+ }
536
+
354
537
  function formatMarkdown(text) {
355
538
  if (typeof marked !== 'undefined') {
356
539
  // Split text by code blocks (triple backticks or single backticks)
@@ -384,6 +567,8 @@ function testLLMConnection() {
384
567
  const model = document.getElementById('inspire-llm-model').value;
385
568
  const testBtn = document.getElementById('inspire-test-llm');
386
569
  const generateBtn = document.getElementById('inspire-generate');
570
+ const enhanceBtn = document.getElementById('inspire-enhance');
571
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
387
572
 
388
573
  if (!apiKey) {
389
574
  alert("请先输入 API Key。");
@@ -405,12 +590,16 @@ function testLLMConnection() {
405
590
  testBtn.textContent = "成功";
406
591
  testBtn.className = "btn btn-success";
407
592
  generateBtn.disabled = false;
593
+ if (enhanceBtn) enhanceBtn.disabled = false;
594
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
408
595
  setTimeout(() => { testBtn.textContent = "测试连接"; testBtn.className = "btn btn-secondary"; }, 3000);
409
596
  } else {
410
597
  testBtn.textContent = "失败";
411
598
  testBtn.className = "btn btn-danger";
412
599
  alert("连接失败: " + data.error);
413
600
  generateBtn.disabled = true;
601
+ if (enhanceBtn) enhanceBtn.disabled = true;
602
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
414
603
  setTimeout(() => { testBtn.textContent = "测试连接"; testBtn.className = "btn btn-secondary"; }, 3000);
415
604
  }
416
605
  })
@@ -418,9 +607,138 @@ function testLLMConnection() {
418
607
  testBtn.disabled = false;
419
608
  testBtn.textContent = "错误";
420
609
  alert("错误: " + err);
610
+ if (enhanceBtn) enhanceBtn.disabled = true;
611
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
421
612
  });
422
613
  }
423
614
 
615
+ function handleEnhanceFile(event) {
616
+ const files = event.target.files ? Array.from(event.target.files) : [];
617
+ if (files.length === 0) return;
618
+
619
+ const apiKey = document.getElementById('inspire-llm-key').value;
620
+ const baseUrl = document.getElementById('inspire-llm-url').value;
621
+ const model = document.getElementById('inspire-llm-model').value;
622
+ if (!apiKey) {
623
+ alert("请输入 LLM API Key。");
624
+ return;
625
+ }
626
+
627
+ const outputDiv = document.getElementById('inspire-output');
628
+ outputDiv.innerHTML = '<pre id="inspire-enhance-stream" style="white-space: pre-wrap; margin: 0;"></pre>';
629
+
630
+ const enhanceBtn = document.getElementById('inspire-enhance');
631
+ if (enhanceBtn) {
632
+ enhanceBtn.disabled = true;
633
+ enhanceBtn.textContent = '处理中...';
634
+ }
635
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
636
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
637
+
638
+ const formData = new FormData();
639
+ files.forEach(file => formData.append('ideaFiles', file));
640
+ formData.append('apiKey', apiKey);
641
+ formData.append('baseUrl', baseUrl);
642
+ formData.append('model', model);
643
+
644
+ fetch('/api/inspiration/enhance-template', {
645
+ method: 'POST',
646
+ headers: { 'Session-ID': localStorage.getItem('brain_session_id') || '' },
647
+ body: formData
648
+ })
649
+ .then(res => res.json())
650
+ .then(data => {
651
+ if (!data.success) {
652
+ outputDiv.innerHTML = '启动失败: ' + (data.error || '未知错误');
653
+ if (enhanceBtn) {
654
+ enhanceBtn.disabled = false;
655
+ enhanceBtn.textContent = '增强历史生成模板';
656
+ }
657
+ return;
658
+ }
659
+ inspirationState.enhanceTaskId = data.taskId;
660
+ startEnhanceStream(data.taskId, files.length);
661
+ })
662
+ .catch(err => {
663
+ outputDiv.innerHTML = '启动出错: ' + err;
664
+ if (enhanceBtn) {
665
+ enhanceBtn.disabled = false;
666
+ enhanceBtn.textContent = '增强历史生成模板';
667
+ }
668
+ })
669
+ .finally(() => {
670
+ event.target.value = '';
671
+ });
672
+ }
673
+
674
+ function startEnhanceStream(taskId, totalFiles) {
675
+ const outputDiv = document.getElementById('inspire-output');
676
+ const streamEl = document.getElementById('inspire-enhance-stream');
677
+ if (!streamEl) {
678
+ outputDiv.innerHTML = '<pre id="inspire-enhance-stream" style="white-space: pre-wrap; margin: 0;"></pre>';
679
+ }
680
+ const target = document.getElementById('inspire-enhance-stream');
681
+
682
+ const source = new EventSource(`/api/inspiration/stream-enhance/${taskId}`);
683
+ let completed = 0;
684
+
685
+ source.onmessage = (event) => {
686
+ try {
687
+ const payload = JSON.parse(event.data);
688
+ if (payload && payload.type === 'file_done') {
689
+ completed += 1;
690
+ target.textContent += `\n✅ 已完成 ${completed}/${totalFiles}: ${payload.file || ''} (${payload.success ? '成功' : '失败'})\n`;
691
+ outputDiv.scrollTop = outputDiv.scrollHeight;
692
+ return;
693
+ }
694
+ if (payload && payload.line !== undefined) {
695
+ const prefix = payload.file ? `[${payload.file}] ` : '';
696
+ target.textContent += prefix + payload.line + '\n';
697
+ outputDiv.scrollTop = outputDiv.scrollHeight;
698
+ }
699
+ } catch {
700
+ target.textContent += event.data + '\n';
701
+ outputDiv.scrollTop = outputDiv.scrollHeight;
702
+ }
703
+ };
704
+
705
+ source.addEventListener('done', (event) => {
706
+ let info = null;
707
+ try {
708
+ info = JSON.parse(event.data);
709
+ } catch {
710
+ info = { success: false };
711
+ }
712
+ const enhanceBtn = document.getElementById('inspire-enhance');
713
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
714
+ if (enhanceBtn) {
715
+ enhanceBtn.disabled = false;
716
+ enhanceBtn.textContent = '增强历史生成模板';
717
+ }
718
+ if (enhanceDlBtn) {
719
+ enhanceDlBtn.style.display = info && info.success ? 'inline-block' : 'none';
720
+ }
721
+ source.close();
722
+ });
723
+
724
+ source.addEventListener('error', () => {
725
+ const enhanceBtn = document.getElementById('inspire-enhance');
726
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
727
+ if (enhanceBtn) {
728
+ enhanceBtn.disabled = false;
729
+ enhanceBtn.textContent = '增强历史生成模板';
730
+ }
731
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
732
+ target.textContent += '\n⚠️ 日志流中断。\n';
733
+ source.close();
734
+ });
735
+ }
736
+
737
+ function downloadEnhanceZip() {
738
+ if (!inspirationState.enhanceTaskId) return;
739
+ window.location.href = `/api/inspiration/download-enhance/${inspirationState.enhanceTaskId}`;
740
+ }
741
+
424
742
  function downloadInspirationResult() {
425
743
  if (!inspirationState.lastResult) return;
426
744
 
@@ -437,6 +755,7 @@ function downloadInspirationResult() {
437
755
 
438
756
  function resetInspirationTask() {
439
757
  inspirationState.selectedDataset = null;
758
+ inspirationState.selectedDatasetCategory = null;
440
759
  const display = document.getElementById('inspire-selected-dataset');
441
760
  if (display) {
442
761
  display.textContent = "";
@@ -447,6 +766,19 @@ function resetInspirationTask() {
447
766
 
448
767
  const dlBtn = document.getElementById('inspire-download');
449
768
  if (dlBtn) dlBtn.style.display = 'none';
769
+
770
+ const directDlBtn = document.getElementById('inspire-direct-download');
771
+ if (directDlBtn) directDlBtn.style.display = 'none';
772
+
773
+ const enhanceDlBtn = document.getElementById('inspire-enhance-download');
774
+ if (enhanceDlBtn) enhanceDlBtn.style.display = 'none';
775
+ inspirationState.enhanceTaskId = null;
776
+
777
+ if (inspirationState.pipelineEventSource) {
778
+ inspirationState.pipelineEventSource.close();
779
+ inspirationState.pipelineEventSource = null;
780
+ }
781
+ inspirationState.pipelineTaskId = null;
450
782
 
451
783
  const newTaskBtn = document.getElementById('inspire-new-task');
452
784
  if (newTaskBtn) {
@@ -54,7 +54,7 @@
54
54
  <span style="margin-right: 5px;">🤖</span>加载72变生成的模板
55
55
  </button>
56
56
  <button class="btn btn-small btn-outline" onclick="document.getElementById('generatedExpressionsFile').click()" title="Load Generated Expressions from JSON file">
57
- <span style="margin-right: 5px;">📄</span>载入72变生成的表达式
57
+ <span style="margin-right: 5px;">📄</span>载入表达式列表Json
58
58
  </button>
59
59
  <input type="file" id="importTemplatesFile" accept=".json" style="display: none;" onchange="importCustomTemplates(event)">
60
60
  <input type="file" id="transformerFile" accept=".json" style="display: none;" onchange="handleTransformerFileSelect(event)">
@@ -840,7 +840,7 @@
840
840
  </div>
841
841
  <div style="margin-bottom: 10px;">
842
842
  <label style="display: block; margin-bottom: 5px; font-size: 0.9em; color: #666;">Model Name</label>
843
- <input type="text" id="inspire-llm-model" value="kimi-k2-turbo-preview" class="form-input" style="width: 100%;">
843
+ <input type="text" id="inspire-llm-model" value="kimi-k2.5" class="form-input" style="width: 100%;">
844
844
  </div>
845
845
  <div style="margin-bottom: 10px;">
846
846
  <label style="display: block; margin-bottom: 5px; font-size: 0.9em; color: #666;">API Key</label>
@@ -849,6 +849,11 @@
849
849
  <button id="inspire-test-llm" class="btn btn-secondary" style="white-space: nowrap;">测试连接</button>
850
850
  </div>
851
851
  </div>
852
+ <div>
853
+ <button id="inspire-enhance" class="btn btn-outline" style="width: 100%;" disabled>增强历史生成模板</button>
854
+ <input type="file" id="inspire-idea-file" accept="application/json" multiple style="display: none;">
855
+ <button id="inspire-enhance-download" class="btn btn-success" style="width: 100%; margin-top: 8px; display: none;">下载增强结果 ZIP 📦</button>
856
+ </div>
852
857
  </div>
853
858
 
854
859
  <div style="background: #f8f9fa; padding: 15px; border-radius: 5px;">
@@ -898,9 +903,12 @@
898
903
  <div id="inspire-col-3" class="inspire-col" style="flex: 1; display: flex; flex-direction: column; overflow-y: auto;">
899
904
  <div class="col-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 2px solid #ffc107; padding-bottom: 5px;">
900
905
  <h4 style="margin: 0; color: #d39e00;">3. Results</h4>
901
- <div style="display: flex; gap: 10px; align-items: center;">
906
+ <div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
902
907
  <button id="inspire-generate" class="btn btn-primary">生成 Alpha 模板</button>
908
+ <span style="font-family: 'Segoe Script', 'KaiTi', 'STKaiti', cursive; font-weight: 700; font-size: 16px; color: #6f42c1; text-shadow: 0 1px 2px rgba(0,0,0,0.15);">或</span>
909
+ <button id="inspire-direct" class="btn btn-primary">直接来点 Alpha</button>
903
910
  <button id="inspire-download" class="btn btn-success" style="display: none;">下载模板到本地 📥</button>
911
+ <button id="inspire-direct-download" class="btn btn-success" style="display: none;">下载 Alpha 结果 ZIP 📦</button>
904
912
  </div>
905
913
  <span class="vertical-label" style="color: #d39e00;">Results</span>
906
914
  </div>
@@ -94,7 +94,7 @@
94
94
  <form id="transformerForm">
95
95
  <div class="form-group">
96
96
  <label for="llm_model">LLM Model Name</label>
97
- <input type="text" id="llm_model" name="LLM_model_name" value="kimi-k2-turbo-preview">
97
+ <input type="text" id="llm_model" name="LLM_model_name" value="kimi-k2.5">
98
98
  </div>
99
99
  <div class="form-group">
100
100
  <label for="llm_api_key">LLM API Key</label>
@@ -0,0 +1,38 @@
1
+ # trailSomeAlphas Pipeline
2
+
3
+ This folder bundles **brain-data-feature-engineering** and **brain-feature-implementation** so it can run independently.
4
+
5
+ ## Setup
6
+
7
+ 1) Fill BRAIN credentials:
8
+ - Edit skills/brain-feature-implementation/config.json
9
+
10
+ 2) Set Moonshot API key (do not store in files):
11
+ - Windows PowerShell:
12
+ - $Env:MOONSHOT_API_KEY = "<your_api_key>"
13
+
14
+ Optional:
15
+ - Set base URL if needed: MOONSHOT_BASE_URL (default https://api.moonshot.cn/v1)
16
+
17
+ ## Run
18
+
19
+ From this folder:
20
+
21
+ - Generate ideas + implement expressions:
22
+ - python run_pipeline.py --data-category analyst --region USA --delay 1 --universe TOP3000
23
+
24
+ - Use an existing ideas markdown:
25
+ - python run_pipeline.py --data-category analyst --region USA --delay 1 --ideas-file <path_to_ideas.md>
26
+
27
+ ## Output
28
+
29
+ - Ideas report:
30
+ - skills/brain-data-feature-engineering/output_report/{region}_delay{delay}_{datasetId}_ideas.md
31
+
32
+ - Final expressions:
33
+ - skills/brain-feature-implementation/data/{datasetId}_{region}_delay{delay}/final_expressions.json
34
+
35
+ ## Notes
36
+
37
+ - The ideas report must include `Implementation Example` entries that use {variable} placeholders.
38
+ - The implementation step reads templates from backticks with `{variable}` placeholders.
@@ -0,0 +1,66 @@
1
+ 2026-01-30 01:10:55,423 - ace - ERROR -
2
+ Incorrect email or password
3
+
4
+ 2026-01-30 01:10:55,694 - ace - ERROR -
5
+ Incorrect email or password
6
+
7
+ 2026-01-30 01:10:55,966 - ace - ERROR -
8
+ Incorrect email or password
9
+
10
+ 2026-01-30 01:10:56,238 - ace - ERROR -
11
+ Incorrect email or password
12
+
13
+ 2026-01-30 01:10:56,508 - ace - ERROR -
14
+ Incorrect email or password
15
+
16
+ 2026-01-30 01:11:31,531 - ace - ERROR -
17
+ Incorrect email or password
18
+
19
+ 2026-01-30 01:16:05,950 - ace - ERROR -
20
+ Incorrect email or password
21
+
22
+ 2026-01-30 01:16:06,252 - ace - ERROR -
23
+ Incorrect email or password
24
+
25
+ 2026-01-30 01:16:06,518 - ace - ERROR -
26
+ Incorrect email or password
27
+
28
+ 2026-01-30 01:16:06,786 - ace - ERROR -
29
+ Incorrect email or password
30
+
31
+ 2026-01-30 01:16:07,052 - ace - ERROR -
32
+ Incorrect email or password
33
+
34
+ 2026-01-30 01:16:07,321 - ace - ERROR -
35
+ Incorrect email or password
36
+
37
+ 2026-01-30 01:16:07,587 - ace - ERROR -
38
+ Incorrect email or password
39
+
40
+ 2026-01-30 01:17:05,376 - ace - ERROR -
41
+ Incorrect email or password
42
+
43
+ 2026-01-30 01:17:05,661 - ace - ERROR -
44
+ Incorrect email or password
45
+
46
+ 2026-01-30 01:17:05,934 - ace - ERROR -
47
+ Incorrect email or password
48
+
49
+ 2026-01-30 01:17:06,209 - ace - ERROR -
50
+ Incorrect email or password
51
+
52
+ 2026-01-30 01:17:06,489 - ace - ERROR -
53
+ Incorrect email or password
54
+
55
+ 2026-01-30 01:17:06,764 - ace - ERROR -
56
+ Incorrect email or password
57
+
58
+ 2026-01-30 01:17:07,040 - ace - ERROR -
59
+ Incorrect email or password
60
+
61
+ 2026-01-30 01:23:21,160 - ace - ERROR -
62
+ Incorrect email or password
63
+
64
+ 2026-01-30 01:23:21,421 - ace - ERROR -
65
+ Incorrect email or password
66
+