feat(shipping-notice): 支持发货通知解析延后至 Dify 画布,优化任务创建流程

This commit is contained in:
hugo committed 2026-06-22 16:59:38 +08:00
1 parent d46d61bfa1
commit 70e8f700ff
38 files changed
+3215 -714

No files matched your search

@@ -1,8 +1,8 @@
/**
* features/chat/shipping/shippingUploadPrompt.ts
* 用途:库存上传后发给 Dify 的提示语构建与附件类型分类。
* 用途:库存/通知上传后发给 Dify 的提示语构建与附件类型分类。
* 依赖:无;useChatShippingUploadHandler 在上传成功后调用。
* 逻辑:按 checkpoint 生成不同 follow-up 提示;classifyShippingUploadFile 区分库存/通知附件。
* 逻辑:按 checkpoint 生成不同 follow-up 提示;通知建批后触发 Dify LLM 解析续办。
*/
/**
* 根据上传 API 响应 checkpoint 生成发给 Agent 的 follow-up 提示语。
@@ -29,6 +29,34 @@ export function buildShippingInventoryUploadPrompt(
return `${prefix}。请继续处理库存导入,并告诉我下一步。`;
}
/**
* 根据通知建批 API 响应生成发给 Dify 的 follow-up 提示语(触发画布 LLM 抽取 + parse_notice)。
*/
export function buildShippingNoticeUploadPrompt(
result: Record<string, unknown> | null | undefined,
options?: { fileCount?: number; fileName?: string },
): string {
const batchNo = String(
(result?.batch_no as string | undefined)
|| ((result?.data as { batch?: { batch_no?: string } } | undefined)?.batch?.batch_no)
|| '',
).trim();
const taskId = String(
((result?.data as { focus_task?: { task_no?: string } } | undefined)?.focus_task?.task_no)
|| (result?.task_id as string | undefined)
|| ((result?.data as { tasks?: Array<{ task_id?: string }> } | undefined)?.tasks?.[0]?.task_id)
|| '',
).trim();
const fileCount = Number(options?.fileCount || 0);
const fileLabel = options?.fileName
? `《${options.fileName}》`
: (fileCount > 1 ? `${fileCount} 份发货通知` : '发货通知');
const parts = [`我已上传${fileLabel}`];
if (batchNo) parts.push(`批次 ${batchNo}`);
if (taskId) parts.push(`当前任务 ${taskId}`);
return `${parts.join(',')}。请读取任务 raw_text,用 LLM 抽取结构化字段后调用 parse_notice(structured=...) 落库;若抽取失败可仅传 raw_text 走后端规则兜底,并展示解析结果供我确认。`;
}
/**
* 按扩展名判断附件是库存 Excel 还是发货通知文件。
*/