feat: 智能助手品名咨询优先调用 oms.channel_guide
All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m32s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m32s
识别能不能寄/走什么渠道;仅品名即可发问,并加强 Agent 系统提示强制调 MCP。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b43dee5753
commit
9fe829c6a9
@ -1026,10 +1026,20 @@ function buildAgentMessages(userFacingMessages: ChatMessage[]) {
|
||||
|
||||
if (activeCapability.value) {
|
||||
const cap = getCapability(activeCapability.value);
|
||||
list.push({
|
||||
role: 'system',
|
||||
content: `用户当前意图偏向「${cap.toolKey}」。必填信息已齐时立刻调工具;不要索要起运地;不要空回复。`,
|
||||
});
|
||||
if (cap.id === 'guide') {
|
||||
list.push({
|
||||
role: 'system',
|
||||
content:
|
||||
'用户在问品名能不能寄/走什么渠道。必须调用 oms.channel_guide,参数形如 ' +
|
||||
'{"productCode":"","productName":"","cargoName":"<从用户话提取的品名>"}。' +
|
||||
'已知渠道再填 productCode/productName,否则留空。不要空回复。',
|
||||
});
|
||||
} else {
|
||||
list.push({
|
||||
role: 'system',
|
||||
content: `用户当前意图偏向「${cap.toolKey}」。必填信息已齐时立刻调工具;不要索要起运地;不要空回复。`,
|
||||
});
|
||||
}
|
||||
}
|
||||
// 只带最近几轮,避免历史把 token 打爆
|
||||
const dialog = userFacingMessages
|
||||
|
||||
@ -50,8 +50,8 @@ export const MCP_CAPABILITY_GUIDES: McpCapabilityGuide[] = [
|
||||
exampleKey: 'nanaAssistant.mcp.guideExample',
|
||||
draftKey: 'nanaAssistant.mcp.guideDraft',
|
||||
fields: [
|
||||
{ key: 'product', required: true, labelKey: 'nanaAssistant.mcp.field.product' },
|
||||
{ key: 'cargoName', required: true, labelKey: 'nanaAssistant.mcp.field.cargoName' },
|
||||
{ key: 'product', required: false, labelKey: 'nanaAssistant.mcp.field.product' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -80,7 +80,6 @@ const ORDER_NO_LOOSE = /[A-Za-z][A-Za-z0-9\-_]{5,}/
|
||||
const ORDER_NO_STRICT =
|
||||
/\b(IDE\d{8,}|(?:YD|SF|YT|NF|LT)[A-Za-z0-9]{6,}|(?:[A-Z]{2,}\d{8,}))\b/i
|
||||
|
||||
const PRODUCT_HINT = /产品|渠道|线路|运输方式|[A-Z]{2,}[_-][A-Z0-9_]+/i
|
||||
const CARGO_HINT =
|
||||
/品名|货物|普货|敏感|衣服|服装|鞋|化妆品|lipstick|手机|电池|粉末|液体|食品|寄|发/i
|
||||
|
||||
@ -113,8 +112,12 @@ export function detectMissingFields(
|
||||
if (!COUNTRY_HINT.test(t)) missing.push('country')
|
||||
if (!WEIGHT_HINT.test(t)) missing.push('weight')
|
||||
} else if (capability === 'guide') {
|
||||
if (!PRODUCT_HINT.test(t)) missing.push('product')
|
||||
if (!CARGO_HINT.test(t) && t.replace(/\s/g, '').length < 4) missing.push('cargoName')
|
||||
// 仅品名必填;销售产品可选(工具可按品名检索对客说明)
|
||||
const hasCargo =
|
||||
CARGO_HINT.test(t) ||
|
||||
/[A-Za-z]{2,}/.test(t) ||
|
||||
(t.replace(/\s/g, '').length >= 2 && !/^(能不能|可以|吗|么|寄|发|走)+$/.test(t.replace(/\s/g, '')))
|
||||
if (!hasCargo) missing.push('cargoName')
|
||||
} else if (capability === 'track') {
|
||||
if (!opts?.hasWaybillContext && !extractOrderNo(t)) missing.push('orderNo')
|
||||
}
|
||||
@ -131,7 +134,13 @@ export function inferCapabilityFromText(text: string): McpCapabilityId | null {
|
||||
if (extractOrderNo(raw) && !COUNTRY_HINT.test(raw)) return 'track'
|
||||
if (ORDER_NO_STRICT.test(raw) && raw.length < 40) return 'track'
|
||||
|
||||
if (/品名|能发|禁运|可寄|对客说明|承运|敏感货/.test(lower)) return 'guide'
|
||||
if (
|
||||
/品名|能发|禁运|可寄|对客说明|承运|敏感货|能不能走|可以走|走什么渠道|哪个渠道|什么渠道|能不能寄|可以寄|能寄吗|可发吗/.test(
|
||||
lower,
|
||||
)
|
||||
) {
|
||||
return 'guide'
|
||||
}
|
||||
|
||||
if (/price|cost|quote|报价|价格|多少钱|运费|查价|怎么走|走得动/.test(lower)) return 'price'
|
||||
|
||||
|
||||
@ -40,9 +40,9 @@ export default {
|
||||
'nanaAssistant.mcp.guideTitle': 'Can this cargo ship?',
|
||||
'nanaAssistant.mcp.guideDesc': 'See if this item can go on this service',
|
||||
'nanaAssistant.mcp.guideCoach':
|
||||
'I need the sales product (service) and the cargo name.\nExample: product XX, cargo lipstick — can it ship?',
|
||||
'nanaAssistant.mcp.guideExample': 'Can lipstick ship?',
|
||||
'nanaAssistant.mcp.guideDraft': 'Sales product code/name:\nCargo name:',
|
||||
'Tell me the cargo name and I’ll check which channels allow it.\nExample: Can lipstick ship? / Which channel for cosmetics?',
|
||||
'nanaAssistant.mcp.guideExample': 'Can lipstick ship, which channel?',
|
||||
'nanaAssistant.mcp.guideDraft': 'Cargo name:\nSales product code/name (optional):',
|
||||
'nanaAssistant.mcp.trackTitle': 'Where is my parcel?',
|
||||
'nanaAssistant.mcp.trackDesc': 'See where the parcel is now',
|
||||
'nanaAssistant.mcp.trackCoach':
|
||||
|
||||
@ -39,9 +39,9 @@ export default {
|
||||
'nanaAssistant.mcp.guideTitle': '这个货能不能寄',
|
||||
'nanaAssistant.mcp.guideDesc': '看这个品名能不能走这条渠道',
|
||||
'nanaAssistant.mcp.guideCoach':
|
||||
'判断能不能寄需要:销售产品(运输方式)和品名。\n例如:产品 XX,品名 lipstick,能发吗?',
|
||||
'nanaAssistant.mcp.guideExample': 'lipstick能寄吗',
|
||||
'nanaAssistant.mcp.guideDraft': '销售产品代码/名称:\n客户品名:',
|
||||
'告诉我品名即可查能不能寄、走什么渠道。\n例如:lipstick 能寄吗? / 化妆品走什么渠道?',
|
||||
'nanaAssistant.mcp.guideExample': 'lipstick能寄吗,走什么渠道',
|
||||
'nanaAssistant.mcp.guideDraft': '客户品名:\n销售产品代码/名称(选填):',
|
||||
'nanaAssistant.mcp.trackTitle': '包裹到哪了',
|
||||
'nanaAssistant.mcp.trackDesc': '看包裹现在到哪了',
|
||||
'nanaAssistant.mcp.trackCoach':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user