20261028 #14
@ -1026,11 +1026,21 @@ function buildAgentMessages(userFacingMessages: ChatMessage[]) {
|
|||||||
|
|
||||||
if (activeCapability.value) {
|
if (activeCapability.value) {
|
||||||
const cap = getCapability(activeCapability.value);
|
const cap = getCapability(activeCapability.value);
|
||||||
|
if (cap.id === 'guide') {
|
||||||
|
list.push({
|
||||||
|
role: 'system',
|
||||||
|
content:
|
||||||
|
'用户在问品名能不能寄/走什么渠道。必须调用 oms.channel_guide,参数形如 ' +
|
||||||
|
'{"productCode":"","productName":"","cargoName":"<从用户话提取的品名>"}。' +
|
||||||
|
'已知渠道再填 productCode/productName,否则留空。不要空回复。',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
list.push({
|
list.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: `用户当前意图偏向「${cap.toolKey}」。必填信息已齐时立刻调工具;不要索要起运地;不要空回复。`,
|
content: `用户当前意图偏向「${cap.toolKey}」。必填信息已齐时立刻调工具;不要索要起运地;不要空回复。`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 只带最近几轮,避免历史把 token 打爆
|
// 只带最近几轮,避免历史把 token 打爆
|
||||||
const dialog = userFacingMessages
|
const dialog = userFacingMessages
|
||||||
.filter((m) => m.role === 'user' || m.role === 'assistant')
|
.filter((m) => m.role === 'user' || m.role === 'assistant')
|
||||||
|
|||||||
@ -50,8 +50,8 @@ export const MCP_CAPABILITY_GUIDES: McpCapabilityGuide[] = [
|
|||||||
exampleKey: 'nanaAssistant.mcp.guideExample',
|
exampleKey: 'nanaAssistant.mcp.guideExample',
|
||||||
draftKey: 'nanaAssistant.mcp.guideDraft',
|
draftKey: 'nanaAssistant.mcp.guideDraft',
|
||||||
fields: [
|
fields: [
|
||||||
{ key: 'product', required: true, labelKey: 'nanaAssistant.mcp.field.product' },
|
|
||||||
{ key: 'cargoName', required: true, labelKey: 'nanaAssistant.mcp.field.cargoName' },
|
{ 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 =
|
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
|
/\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 =
|
const CARGO_HINT =
|
||||||
/品名|货物|普货|敏感|衣服|服装|鞋|化妆品|lipstick|手机|电池|粉末|液体|食品|寄|发/i
|
/品名|货物|普货|敏感|衣服|服装|鞋|化妆品|lipstick|手机|电池|粉末|液体|食品|寄|发/i
|
||||||
|
|
||||||
@ -113,8 +112,12 @@ export function detectMissingFields(
|
|||||||
if (!COUNTRY_HINT.test(t)) missing.push('country')
|
if (!COUNTRY_HINT.test(t)) missing.push('country')
|
||||||
if (!WEIGHT_HINT.test(t)) missing.push('weight')
|
if (!WEIGHT_HINT.test(t)) missing.push('weight')
|
||||||
} else if (capability === 'guide') {
|
} 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') {
|
} else if (capability === 'track') {
|
||||||
if (!opts?.hasWaybillContext && !extractOrderNo(t)) missing.push('orderNo')
|
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 (extractOrderNo(raw) && !COUNTRY_HINT.test(raw)) return 'track'
|
||||||
if (ORDER_NO_STRICT.test(raw) && raw.length < 40) 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'
|
if (/price|cost|quote|报价|价格|多少钱|运费|查价|怎么走|走得动/.test(lower)) return 'price'
|
||||||
|
|
||||||
|
|||||||
@ -40,9 +40,9 @@ export default {
|
|||||||
'nanaAssistant.mcp.guideTitle': 'Can this cargo ship?',
|
'nanaAssistant.mcp.guideTitle': 'Can this cargo ship?',
|
||||||
'nanaAssistant.mcp.guideDesc': 'See if this item can go on this service',
|
'nanaAssistant.mcp.guideDesc': 'See if this item can go on this service',
|
||||||
'nanaAssistant.mcp.guideCoach':
|
'nanaAssistant.mcp.guideCoach':
|
||||||
'I need the sales product (service) and the cargo name.\nExample: product XX, cargo lipstick — can it ship?',
|
'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?',
|
'nanaAssistant.mcp.guideExample': 'Can lipstick ship, which channel?',
|
||||||
'nanaAssistant.mcp.guideDraft': 'Sales product code/name:\nCargo name:',
|
'nanaAssistant.mcp.guideDraft': 'Cargo name:\nSales product code/name (optional):',
|
||||||
'nanaAssistant.mcp.trackTitle': 'Where is my parcel?',
|
'nanaAssistant.mcp.trackTitle': 'Where is my parcel?',
|
||||||
'nanaAssistant.mcp.trackDesc': 'See where the parcel is now',
|
'nanaAssistant.mcp.trackDesc': 'See where the parcel is now',
|
||||||
'nanaAssistant.mcp.trackCoach':
|
'nanaAssistant.mcp.trackCoach':
|
||||||
|
|||||||
@ -39,9 +39,9 @@ export default {
|
|||||||
'nanaAssistant.mcp.guideTitle': '这个货能不能寄',
|
'nanaAssistant.mcp.guideTitle': '这个货能不能寄',
|
||||||
'nanaAssistant.mcp.guideDesc': '看这个品名能不能走这条渠道',
|
'nanaAssistant.mcp.guideDesc': '看这个品名能不能走这条渠道',
|
||||||
'nanaAssistant.mcp.guideCoach':
|
'nanaAssistant.mcp.guideCoach':
|
||||||
'判断能不能寄需要:销售产品(运输方式)和品名。\n例如:产品 XX,品名 lipstick,能发吗?',
|
'告诉我品名即可查能不能寄、走什么渠道。\n例如:lipstick 能寄吗? / 化妆品走什么渠道?',
|
||||||
'nanaAssistant.mcp.guideExample': 'lipstick能寄吗',
|
'nanaAssistant.mcp.guideExample': 'lipstick能寄吗,走什么渠道',
|
||||||
'nanaAssistant.mcp.guideDraft': '销售产品代码/名称:\n客户品名:',
|
'nanaAssistant.mcp.guideDraft': '客户品名:\n销售产品代码/名称(选填):',
|
||||||
'nanaAssistant.mcp.trackTitle': '包裹到哪了',
|
'nanaAssistant.mcp.trackTitle': '包裹到哪了',
|
||||||
'nanaAssistant.mcp.trackDesc': '看包裹现在到哪了',
|
'nanaAssistant.mcp.trackDesc': '看包裹现在到哪了',
|
||||||
'nanaAssistant.mcp.trackCoach':
|
'nanaAssistant.mcp.trackCoach':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user