- 入库改为让 roundtable-structure 走完整 agent 运行时(ingest run policy) 自行挑选/读取/调用入库技能并传入 taskId,不再前端代调演示 - 新增 /api/flow-extract/ingest-eligibility(智能体判断当前业务场景是否有 合适入库技能,决定入库按钮是否显示)+ /api/multi-agent/structure/init - 入库前判断是否已生成流程图:无则发起「是否先生成流程图」用户协助 - 「知识库入库」更名为「数据入库」 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
59 lines
2.4 KiB
TypeScript
59 lines
2.4 KiB
TypeScript
/**
|
||
* 第三步「入库」功能门控 + 入库执行客户端。
|
||
*
|
||
* 入库不再由前端硬编码「有没有含『入库』关键字的技能」判定,而是让**结构化输出智能体**
|
||
* (`roundtable-structure`)读它挂载的入库技能 + 当前业务场景,**自行判断**是否有适合本
|
||
* 场景的入库技能(技能名可能含「六步法」等场景线索)。判定为可入库才显示「入库」按钮。
|
||
*
|
||
* 真正入库时,由结构化输出智能体走**完整 agent 运行时**(`POST /api/multi-agent/run/stream`,
|
||
* role=ingest)**自己挑技能、读 SKILL.md 并调用**完成入库——而不是前端代它调技能。
|
||
*/
|
||
import { apiFetch } from "@/core/api/fetch-client";
|
||
import { getBackendBaseURL } from "@/core/config";
|
||
|
||
/** `/ingest-eligibility` 返回:是否可入库 + 选中的技能名 + 一句话依据。 */
|
||
export interface IngestEligibility {
|
||
canIngest: boolean;
|
||
skill: string;
|
||
reason: string;
|
||
}
|
||
|
||
/**
|
||
* 让结构化输出智能体判断「当前业务场景**是否有合适的入库技能**」(决定是否显示入库按钮)。
|
||
*
|
||
* 入参为业务场景线索(业务码 / 业务链名 / 总控编排提示 / 方案标题)+ taskId,由后端把挂在
|
||
* `roundtable-structure` 上、且已启用的技能交给模型对照判断。失败 / 未配置入库技能 → 不可入库。
|
||
*/
|
||
export async function checkIngestEligibility(req: {
|
||
taskId?: string | null;
|
||
businessCode?: string | null;
|
||
chainName?: string | null;
|
||
coordinatorPrompt?: string | null;
|
||
reportTitle?: string | null;
|
||
model?: string;
|
||
}): Promise<IngestEligibility> {
|
||
try {
|
||
const res = await apiFetch(`${getBackendBaseURL()}/api/flow-extract/ingest-eligibility`, {
|
||
method: "POST",
|
||
headers: { "Content-Type": "application/json" },
|
||
body: JSON.stringify({
|
||
task_id: req.taskId ?? null,
|
||
business_code: req.businessCode ?? null,
|
||
chain_name: req.chainName ?? null,
|
||
coordinator_prompt: req.coordinatorPrompt ?? null,
|
||
report_title: req.reportTitle ?? null,
|
||
model: req.model,
|
||
}),
|
||
});
|
||
if (!res.ok) return { canIngest: false, skill: "", reason: "" };
|
||
const data = (await res.json()) as { can_ingest?: boolean; skill?: string; reason?: string };
|
||
return {
|
||
canIngest: !!data.can_ingest,
|
||
skill: data.skill ?? "",
|
||
reason: data.reason ?? "",
|
||
};
|
||
} catch {
|
||
return { canIngest: false, skill: "", reason: "" };
|
||
}
|
||
}
|