71 lines
1.9 KiB
TypeScript
71 lines
1.9 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) =>
|
||
|
|
({ chatbox: "Chatbox 研究", manual: "手工研究", ai: "AI 研究(历史)" })[
|
||
|
|
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.kind === "chatbox" && source.reference && (
|
||
|
|
<Button
|
||
|
|
onClick={() =>
|
||
|
|
onAction({
|
||
|
|
type: "open_conversation",
|
||
|
|
conversation_id: source.reference!,
|
||
|
|
nonce: Date.now(),
|
||
|
|
})
|
||
|
|
}
|
||
|
|
>
|
||
|
|
打开研究会话
|
||
|
|
</Button>
|
||
|
|
)}
|
||
|
|
{source.template_input_id && (
|
||
|
|
<Button
|
||
|
|
onClick={() =>
|
||
|
|
onAction({
|
||
|
|
type: "open_research_input",
|
||
|
|
input_id: source.template_input_id!,
|
||
|
|
nonce: Date.now(),
|
||
|
|
})
|
||
|
|
}
|
||
|
|
>
|
||
|
|
查看研究输入
|
||
|
|
</Button>
|
||
|
|
)}
|
||
|
|
{source.parent_run_id && (
|
||
|
|
<Button
|
||
|
|
onClick={() =>
|
||
|
|
onAction({
|
||
|
|
type: "open_backtest",
|
||
|
|
run_id: source.parent_run_id!,
|
||
|
|
nonce: Date.now(),
|
||
|
|
})
|
||
|
|
}
|
||
|
|
>
|
||
|
|
查看原回测
|
||
|
|
</Button>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|