Files
worldquant-alpha-system/frontend/src/research/SourceDetails.tsx
T
yuxuanhui e256d6fef1
Deploy production / deploy (push) Successful in 56s
feat: add Super Alpha research, management and MCP workflows
2026-09-13 12:32:16 +08:00

123 lines
3.5 KiB
TypeScript

import { Button } from "@douyinfe/semi-ui-19";
import type { Source } from "../backtests/types";
import type { UIAction } from "../ai/types";
import "./style.css";
export const sourceLabel = (kind: string) =>
({
superalpha: "Super Alpha 研究",
chatbox: "Chatbox 研究",
manual: "手工研究",
mcp: "MCP 研究",
ai: "AI 研究(历史)",
template: "模板研究",
variant: "Alpha 变体",
feature: "特征工程",
pipeline: "研究流水线",
quantflow: "QuantFlow",
})[kind] ?? kind;
export function SourceDetails({
source,
onAction,
}: {
source: Source;
onAction: (action: UIAction) => void;
}) {
return (
<div className="detail-section research-source">
<p>研究来源:{sourceLabel(source.kind)}</p>
{source.hypothesis && <p>{source.hypothesis}</p>}
{source.batch_id && <p>业务批次:{source.batch_id}</p>}
{source.research_id && <p>研究编号:{source.research_id}</p>}
{source.reference && source.kind !== "chatbox" && (
<p>来源引用:{source.reference}</p>
)}
<div className="inline-actions">
{(source.superalpha_plan_id ||
((source.kind === "superalpha" ||
source.research_kind === "superalpha") &&
source.research_id)) && (
<Button
onClick={() =>
onAction({
type: "open_superalpha_research",
plan_id: source.superalpha_plan_id ?? undefined,
version: source.superalpha_plan_version ?? undefined,
experiment_id: source.research_id ?? undefined,
nonce: Date.now(),
})
}
>
查看 Super Alpha 研究
</Button>
)}
{source.research_id &&
["template", "variant", "feature", "pipeline", "quantflow"].includes(
source.kind,
) && (
<Button
onClick={() =>
onAction({
type: "open_experiment",
experiment_id: source.research_id!,
nonce: Date.now(),
})
}
>
查看研究实验
</Button>
)}
{source.kind === "chatbox" && source.reference && (
<Button
onClick={() =>
onAction({
type: "open_conversation",
conversation_id: source.reference!,
nonce: Date.now(),
})
}
>
打开研究会话
</Button>
)}
{[
...new Set([
...(source.input_snapshot_ids ?? []),
...(source.input_snapshot_id ? [source.input_snapshot_id] : []),
]),
].map((id, index) => (
<Button
key={id}
onClick={() =>
onAction({
type: "open_research_input",
input_id: id,
nonce: Date.now(),
})
}
>
查看研究输入
{(source.input_snapshot_ids?.length ?? 0) > 1
? ` ${index + 1}`
: ""}
</Button>
))}
{source.parent_run_id && (
<Button
onClick={() =>
onAction({
type: "open_backtest",
run_id: source.parent_run_id!,
nonce: Date.now(),
})
}
>
查看原回测
</Button>
)}
</div>
</div>
);
}