docs(tec): 更新货代发货通知批次库存能力文档
- 添加单票与多票发货需求的处理方式 - 说明库存 Excel 上传后的保存与关联机制 - 解释库存匹配与 Excel 生成的独立执行方式 - 明确批次库存的真相来源 feat(chat): 优化发货库存上传提示语 - 根据上传结果生成更详细的提示信息 - 增加批次号的提示逻辑 - 使用国际化支持替换硬编码字符串 refactor(chat): 重构发货库存上传处理逻辑 - 移除多余的任务选择逻辑 - 简化上传处理流程 - 增强代码可读性与维护性 feat(locales): 更新多语言支持的提示信息 - 添加库存上传与任务处理的多语言提示 - 更新库存缺口与任务状态的描述
This commit is contained in:
1 parent
1bd9f278fe
commit
1cf8ff40bd
34 files changed
+4367
-3553
No files matched your search
@@ -4,6 +4,8 @@
|
||||
* 依赖:无;useChatShippingUploadHandler 在上传成功后调用。
|
||||
* 逻辑:按 checkpoint 生成不同 follow-up 提示;通知建批后触发 Dify LLM 解析续办。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
* 根据上传 API 响应 checkpoint 生成发给 Agent 的 follow-up 提示语。
|
||||
*/
|
||||
@@ -16,17 +18,29 @@ export function buildShippingInventoryUploadPrompt(
|
||||
&& (result.data as { field_alignment?: unknown }).field_alignment
|
||||
&& typeof (result.data as { field_alignment?: unknown }).field_alignment === 'object');
|
||||
const suggestOk = Boolean((result?.data as { suggest_ok?: boolean } | undefined)?.suggest_ok);
|
||||
const prefix = fileName ? `我已上传库存文件《${fileName}》` : '我已上传库存文件';
|
||||
const batchNo = String(
|
||||
(result?.batch_no as string | undefined)
|
||||
|| ((result?.data as { batch_no?: string } | undefined)?.batch_no)
|
||||
|| ((result?.data as { batch?: { batch_no?: string } } | undefined)?.batch?.batch_no)
|
||||
|| '',
|
||||
).trim();
|
||||
const prefix = batchNo
|
||||
? (fileName
|
||||
? String(i18n.global.t('chat.shippingNoticePrompt.inventory.prefixBatchWithFile', { fileName, batchNo }))
|
||||
: String(i18n.global.t('chat.shippingNoticePrompt.inventory.prefixBatch', { batchNo })))
|
||||
: (fileName
|
||||
? String(i18n.global.t('chat.shippingNoticePrompt.inventory.prefixWithFile', { fileName }))
|
||||
: String(i18n.global.t('chat.shippingNoticePrompt.inventory.prefix')));
|
||||
if (checkpoint === 'map_infer') {
|
||||
if (suggestOk) {
|
||||
return `${prefix}。请继续处理库存列映射;如果系统已识别出完整映射,请直接应用映射,并展示字段对齐结果给我确认。`;
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.inventory.mapInferSuggested', { prefix }));
|
||||
}
|
||||
return `${prefix}。请继续解析库存列映射,并在拿到可用映射后展示字段对齐结果给我确认。`;
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.inventory.mapInferPending', { prefix }));
|
||||
}
|
||||
if (checkpoint === 'align_review' || hasAlignment) {
|
||||
return `${prefix}。请展示库存字段对齐结果,并引导我确认或更正映射。`;
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.inventory.alignReview', { prefix }));
|
||||
}
|
||||
return `${prefix}。请继续处理库存导入,并告诉我下一步。`;
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.inventory.default', { prefix }));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,16 +68,29 @@ export function buildShippingNoticeUploadPrompt(
|
||||
: [];
|
||||
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}`);
|
||||
if (fileCount > 1 || taskIds.length > 1) {
|
||||
const taskListText = taskIds.length ? `任务列表:${taskIds.join('、')}。` : '';
|
||||
return `${parts.join(',')}。${taskListText}请立即开始整批处理,不要只处理当前任务。先调用 get_batch_status 查看整批状态,再按批次顺序逐票处理:必要时调用 switch_focus_task 切到对应任务,然后读取该任务 raw_text,用 LLM 抽取结构化字段并调用 parse_notice(structured=...) 落库;若抽取失败可仅传 task_id 让后端用 raw_text 兜底。每处理完一票,都继续切到下一票,直到本批每一票都进入各自下一阶段(待确认、待上传库存、自动推进中的任一状态)。禁止再次询问我“是否开始解析”或只停在第一票。`;
|
||||
? String(i18n.global.t('chat.shippingNoticePrompt.notice.fileLabelSingleFile', { fileName: options.fileName }))
|
||||
: (fileCount > 1
|
||||
? String(i18n.global.t('chat.shippingNoticePrompt.notice.fileLabelMulti', { fileCount }))
|
||||
: String(i18n.global.t('chat.shippingNoticePrompt.notice.fileLabelDefault')));
|
||||
const parts = [String(i18n.global.t('chat.shippingNoticePrompt.notice.uploadedPrefix', { fileLabel }))];
|
||||
if (batchNo) {
|
||||
parts.push(String(i18n.global.t('chat.shippingNoticePrompt.notice.batchLabel', { batchNo })));
|
||||
}
|
||||
return `${parts.join(',')}。请立即读取任务 raw_text,用 LLM 抽取结构化字段后直接调用 parse_notice(structured=...) 落库;若抽取失败可仅传 raw_text 走后端规则兜底。禁止再次询问我“是否开始解析”或“是否现在开始解析”。解析完成后,请直接展示解析结果供我确认。`;
|
||||
if (taskId) {
|
||||
parts.push(String(i18n.global.t('chat.shippingNoticePrompt.notice.taskLabel', { taskId })));
|
||||
}
|
||||
if (fileCount > 1 || taskIds.length > 1) {
|
||||
const taskListText = taskIds.length
|
||||
? String(i18n.global.t('chat.shippingNoticePrompt.notice.taskList', { taskIds: taskIds.join('、') }))
|
||||
: '';
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.notice.multiTask', {
|
||||
summary: parts.join(','),
|
||||
taskListText,
|
||||
}));
|
||||
}
|
||||
return String(i18n.global.t('chat.shippingNoticePrompt.notice.singleTask', {
|
||||
summary: parts.join(','),
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user