feat: 使用 Semi AI 组件升级研究助手与研究入口

This commit is contained in:
yuxuanhui
2026-09-10 12:22:26 +08:00
parent 9334b6f651
commit d403008f9b
16 changed files with 974 additions and 174 deletions
+58
View File
@@ -1,4 +1,62 @@
import type { PageContext, UIAction } from "./types";
import type { ResearchReference } from "./ResearchInput";
/** Only expose context already sent by the transport; never include unsaved notes. */
export function contextReferences(context: PageContext): ResearchReference[] {
const refs: ResearchReference[] = [];
const add = (id: string, label: string, value?: string | null) => {
if (value) refs.push({ id, name: `${label}:${value}` });
};
const scope = context.catalog_scope;
if (scope)
add("scope", "范围", `${scope.region}/${scope.universe}/D${scope.delay}`);
add("dataset", "数据集", context.dataset_id);
add("field", "字段", context.field_id);
add("input", "固定输入", context.template_input_id);
add("version", "集合版本", context.collection_version);
add("asset", "研究素材", context.research_asset_id);
add("experiment", "实验", context.research_experiment_id);
add("alpha", "Alpha", context.alpha_id);
add("run", "研究运行", context.research_run_id);
add("backtest", "回测", context.backtest_run_id);
if (context.selected_ids?.length)
add("selection", "已选 Alpha", `${context.selected_ids.length} 条`);
return refs;
}
export function researchPrompts(context: PageContext): string[] {
switch (context.page) {
case "datasets":
return context.unsaved_field_selection
? ["解释当前数据集的字段和适用场景"]
: context.template_input_id
? [
"分析这个固定输入中的字段,提出可验证的研究假设",
"基于这个固定输入构建候选,并预览回测",
]
: [
"解释当前数据集的字段和适用场景",
"如何选择字段并保存为固定研究输入?",
];
case "templates":
return [
"解释当前模板的经济含义和变量组合",
"检查当前研究输入与模板是否匹配",
];
case "variants":
return [
"分析种子 Alpha,提出结构与字段变体思路",
"比较结构变体与市场设置变体的适用场景",
];
case "features":
return ["解释当前特征方案的处理步骤", "根据固定输入提出可验证的特征假设"];
default:
return [
"查询当前研究对象与已有结果",
"介绍从字段选择到候选回测的研究流程",
];
}
}
export type WorkspacePage = PageContext["page"] | "mcp-keys";
const contextLabels: Record<