@tbox.cn/app-module-customer-service 1.0.0-alpha.16 → 1.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/server/index.ts
|
|
2
|
-
import { definePreTool, loadModuleSkills } from "@tbox.cn/app-agent-sdk-server";
|
|
2
|
+
import { definePreTool, loadModuleSkills, stripSystemReminderBlocks } from "@tbox.cn/app-agent-sdk-server";
|
|
3
3
|
|
|
4
4
|
// src/server/cards/customer-service-faq/meta.ts
|
|
5
5
|
import { customerServiceFaqCardDataSchema } from "@tbox.cn/app-contracts-mall";
|
|
@@ -232,9 +232,12 @@ var POLICY_TERMS = [
|
|
|
232
232
|
];
|
|
233
233
|
var faqPreTool = definePreTool(tools.customerServiceFaq, {
|
|
234
234
|
routing: { mode: "always" },
|
|
235
|
-
decide: ({ text }) => {
|
|
235
|
+
decide: ({ text, history = [] }) => {
|
|
236
236
|
const t = text?.trim() ?? "";
|
|
237
237
|
if (!t) return { decision: "skip", reason: "\u7A7A\u6587\u672C" };
|
|
238
|
+
if (/(?:这|那|该)(?:个|张|场|次)?(?:活动|促销|优惠券|券)/.test(t) && !/[「《“"].+?[」》”"]/.test(t) && !history.some((turn) => turn.role === "user" && stripSystemReminderBlocks(turn.content).trim())) {
|
|
239
|
+
return { decision: "skip", reason: "\u9996\u6B21\u5BF9\u8BDD\u4E2D\u7684\u6307\u4EE3\u6CA1\u6709\u5DF2\u9009\u76EE\u6807" };
|
|
240
|
+
}
|
|
238
241
|
if (POLICY_TERMS.some((w) => t.includes(w))) {
|
|
239
242
|
return { decision: "run", args: { query: text, topK: "3" } };
|
|
240
243
|
}
|
package/dist/index.js
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -54,14 +54,14 @@ declare const serverModule: {
|
|
|
54
54
|
relevanceScore: zod.ZodNumber;
|
|
55
55
|
referenceUrl: zod.ZodOptional<zod.ZodString>;
|
|
56
56
|
}, "strip", zod.ZodTypeAny, {
|
|
57
|
-
answer: string;
|
|
58
57
|
question: string;
|
|
58
|
+
answer: string;
|
|
59
59
|
relevanceScore: number;
|
|
60
60
|
category?: string | undefined;
|
|
61
61
|
referenceUrl?: string | undefined;
|
|
62
62
|
}, {
|
|
63
|
-
answer: string;
|
|
64
63
|
question: string;
|
|
64
|
+
answer: string;
|
|
65
65
|
relevanceScore: number;
|
|
66
66
|
category?: string | undefined;
|
|
67
67
|
referenceUrl?: string | undefined;
|
|
@@ -71,25 +71,25 @@ declare const serverModule: {
|
|
|
71
71
|
}, "strip", zod.ZodTypeAny, {
|
|
72
72
|
query: string;
|
|
73
73
|
faqs: {
|
|
74
|
-
answer: string;
|
|
75
74
|
question: string;
|
|
75
|
+
answer: string;
|
|
76
76
|
relevanceScore: number;
|
|
77
77
|
category?: string | undefined;
|
|
78
78
|
referenceUrl?: string | undefined;
|
|
79
79
|
}[];
|
|
80
|
-
noResultsReason?: string | undefined;
|
|
81
80
|
contactPhone?: string | undefined;
|
|
81
|
+
noResultsReason?: string | undefined;
|
|
82
82
|
}, {
|
|
83
83
|
query: string;
|
|
84
84
|
faqs: {
|
|
85
|
-
answer: string;
|
|
86
85
|
question: string;
|
|
86
|
+
answer: string;
|
|
87
87
|
relevanceScore: number;
|
|
88
88
|
category?: string | undefined;
|
|
89
89
|
referenceUrl?: string | undefined;
|
|
90
90
|
}[];
|
|
91
|
-
noResultsReason?: string | undefined;
|
|
92
91
|
contactPhone?: string | undefined;
|
|
92
|
+
noResultsReason?: string | undefined;
|
|
93
93
|
}>>;
|
|
94
94
|
};
|
|
95
95
|
skills: {
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-customer-service",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈客服承接模块:服务政策 FAQ 知识检索(命中正文作答/无结果联系客服卡)。",
|
|
6
6
|
"exports": {
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tbox.cn/app-contracts": "1.0.0-alpha.
|
|
23
|
-
"@tbox.cn/app-
|
|
24
|
-
"@tbox.cn/app-agent-sdk-
|
|
25
|
-
"@tbox.cn/app-
|
|
22
|
+
"@tbox.cn/app-contracts": "1.0.0-alpha.18",
|
|
23
|
+
"@tbox.cn/app-contracts-mall": "1.0.0-alpha.18",
|
|
24
|
+
"@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.18",
|
|
25
|
+
"@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.18"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"zod": "3.25.76",
|
package/src/server/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
ServerModule,
|
|
11
11
|
PreToolDef,
|
|
12
12
|
} from '@tbox.cn/app-agent-sdk-server';
|
|
13
|
-
import { definePreTool, loadModuleSkills } from '@tbox.cn/app-agent-sdk-server';
|
|
13
|
+
import { definePreTool, loadModuleSkills, stripSystemReminderBlocks } from '@tbox.cn/app-agent-sdk-server';
|
|
14
14
|
import customerServiceFaqMeta from './cards/customer-service-faq/meta';
|
|
15
15
|
import { createCustomerServiceTools } from './tools';
|
|
16
16
|
|
|
@@ -70,9 +70,16 @@ const POLICY_TERMS = [
|
|
|
70
70
|
|
|
71
71
|
const faqPreTool = definePreTool(tools.customerServiceFaq, {
|
|
72
72
|
routing: { mode: 'always' },
|
|
73
|
-
decide: ({ text }) => {
|
|
73
|
+
decide: ({ text, history = [] }) => {
|
|
74
74
|
const t = text?.trim() ?? '';
|
|
75
75
|
if (!t) return { decision: 'skip', reason: '空文本' };
|
|
76
|
+
// An unanchored “this event” can retrieve a perfectly valid FAQ for the wrong event.
|
|
77
|
+
// Keep explicit FAQ searches available once the customer identifies the target.
|
|
78
|
+
if (/(?:这|那|该)(?:个|张|场|次)?(?:活动|促销|优惠券|券)/.test(t)
|
|
79
|
+
&& !/[「《“"].+?[」》”"]/.test(t)
|
|
80
|
+
&& !history.some((turn) => turn.role === 'user' && stripSystemReminderBlocks(turn.content).trim())) {
|
|
81
|
+
return { decision: 'skip', reason: '首次对话中的指代没有已选目标' };
|
|
82
|
+
}
|
|
76
83
|
if (POLICY_TERMS.some((w) => t.includes(w))) {
|
|
77
84
|
return { decision: 'run', args: { query: text, topK: '3' } };
|
|
78
85
|
}
|
|
@@ -41,6 +41,13 @@ describe('faqPreTool decide:v3 三层门控(政策 run → 操作 skip →
|
|
|
41
41
|
const { serverModule } = await import('../src/server/index');
|
|
42
42
|
const decide = (serverModule.preTools!['customer-service-faq']!).decide;
|
|
43
43
|
|
|
44
|
+
it('没有前文的活动指代不注入无关活动政策;明确的活动可正常查询', async () => {
|
|
45
|
+
const ask = '参加这个活动需要什么条件?';
|
|
46
|
+
expect(await decide!({ text: ask, history: [] })).toMatchObject({ decision: 'skip' });
|
|
47
|
+
expect(await decide!({ text: ask, history: [{ role: 'user', content: '我想了解假日市集' }] })).toMatchObject({ decision: 'run' });
|
|
48
|
+
expect(await decide!({ text: '「假日市集」这个活动需要什么条件?' })).toMatchObject({ decision: 'run' });
|
|
49
|
+
});
|
|
50
|
+
|
|
44
51
|
it('操作型诉求(缴纳/我的/余额/进度)→ skip', async () => {
|
|
45
52
|
for (const text of ['帮我缴纳停车费', '我的停车费是多少', '我的积分余额还有多少', '退款申请进度']) {
|
|
46
53
|
const d = (await decide!({ text })) as { decision: string; reason?: string };
|