@inupedia/spotlight-vue 0.5.17 → 0.5.19

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,96 +1,135 @@
1
- const u = {
1
+ const S = {
2
2
  call_tools: "调用工具",
3
3
  respond: "生成回答",
4
4
  fallback: "兜底回复"
5
- }, p = "3", m = "gather", f = "act", S = "answer", c = /^第 \d+ 轮:/u, g = /(?:\n\n+)?第 \d+ 轮:[\s\S]*?(?=\n\n第 \d+ 轮:|$)/gu, s = `
5
+ }, T = "3", _ = "gather", h = "act", E = "answer", m = /^第 \d+ 轮:/u, L = /(?:\n\n+)?第 \d+ 轮:[\s\S]*?(?=\n\n第 \d+ 轮:|$)/gu, a = `
6
6
 
7
7
  --- spotlight-answer ---
8
8
 
9
9
  `;
10
- function l(t) {
10
+ function o(t) {
11
11
  if (!t.trim()) return t;
12
12
  let n = t;
13
- for (const [e, i] of Object.entries(u))
13
+ for (const [e, i] of Object.entries(S))
14
14
  n = n.replace(new RegExp(`\\b${e}\\b`, "g"), i);
15
15
  return n;
16
16
  }
17
- const a = /(?:\n\n+|^)(【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】[\s\S]*?)(?=\n\n(?:第 \d+ 轮:|【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】)|$)/gu, _ = /【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】/u;
18
- function T(t) {
17
+ const f = /(?:\n\n+|^)(【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】[\s\S]*?)(?=\n\n(?:第 \d+ 轮:|【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】)|$)/gu, O = /【(?:Skill 已(?:加|预加)载|会话 Skill 已恢复)】/u;
18
+ function A(t) {
19
19
  const n = [
20
20
  ...t.matchAll(/(?:^|\n\n)(第 \d+ 轮:[^\n]+\n原因:[^\n]+)/gu)
21
- ].map((r) => r[1]?.trim() ?? "").filter(Boolean), e = [...t.matchAll(a)].map((r) => r[1]?.trim() ?? "").filter(Boolean);
21
+ ].map((s) => s[1]?.trim() ?? "").filter(Boolean), e = [...t.matchAll(f)].map((s) => s[1]?.trim() ?? "").filter(Boolean);
22
22
  if (n.length === 0 && e.length === 0)
23
23
  return { planning: "", answer: t };
24
24
  let i = t;
25
- for (const r of [...n, ...e])
26
- i = i.replace(r, "");
25
+ for (const s of [...n, ...e])
26
+ i = i.replace(s, "");
27
27
  return i = i.replace(/\n{3,}/g, `
28
28
 
29
29
  `).trim(), { planning: [...n, ...e].join(`
30
30
 
31
31
  `).trim(), answer: i };
32
32
  }
33
- function L(t) {
34
- const n = l(t).trim();
33
+ function P(t) {
34
+ const n = o(t).trim();
35
35
  if (!n) return { planning: "", answer: "" };
36
- const e = n.indexOf(s);
36
+ const e = n.indexOf(a);
37
37
  return e >= 0 ? {
38
38
  planning: n.slice(0, e).trim(),
39
- answer: n.slice(e + s.length).trim()
40
- } : T(n);
39
+ answer: n.slice(e + a.length).trim()
40
+ } : A(n);
41
41
  }
42
- function d(t, n) {
42
+ function B(t, n) {
43
43
  const e = t.trim(), i = n.trim();
44
- return e && i ? `${e}${s}${i}` : e || i;
44
+ return e && i ? `${e}${a}${i}` : e || i;
45
45
  }
46
- function P(t) {
47
- const n = l(t).trim();
46
+ function C(t) {
47
+ const n = o(t).trim();
48
48
  if (!n) return "";
49
- const { planning: e, answer: i } = L(n);
50
- if (e.trim() && !n.includes(s))
49
+ const { planning: e, answer: i } = P(n);
50
+ if (e.trim() && !n.includes(a))
51
51
  return "";
52
- const o = (i || (e.trim() ? "" : n)).trim();
53
- return !o || _.test(o) ? "" : O(o).replace(a, "").replace(/\n{3,}/g, `
52
+ const r = (i || (e.trim() ? "" : n)).trim();
53
+ return !r || O.test(r) ? "" : w(r).replace(f, "").replace(/\n{3,}/g, `
54
54
 
55
55
  `).trim();
56
56
  }
57
- function A(t) {
58
- return t === m || t === f || t === p;
59
- }
60
- function k(t) {
61
- return t === S;
57
+ function R(t) {
58
+ const n = t.trim();
59
+ return n ? n.replace(/^联网检索证据:\s*/u, "").split(/\n/u).map(
60
+ (e) => e.replace(
61
+ /(?:^[-*]\s*)?(?:Tavily answer|Hikari answer|Yuxi project knowledge|Spotlight knowledge)\s*[::]\s*/giu,
62
+ ""
63
+ )
64
+ ).join(`
65
+ `).replace(/\n{3,}/g, `
66
+
67
+ `).trim() : "";
62
68
  }
69
+ const u = "正在依据资料组织回答。", p = /^\s*\d+[.、]\s+(.+)$/u, I = /^(.*?命中\s+\d+\s+条资料)/u;
63
70
  function N(t) {
64
- return c.test(
65
- l(t).trimStart()
71
+ const n = t.trim();
72
+ if (!n) return null;
73
+ let e = "", i = n;
74
+ i.includes(u) && (e = u, i = i.replace(u, "").trim());
75
+ const r = i.split(/\n/u).map((c) => c.match(p)?.[1]?.trim() ?? "").filter(Boolean);
76
+ if (r.length > 0)
77
+ return { headline: i.split(/\n/u).map((l) => l.trim()).find((l) => l && !p.test(l))?.replace(/[::]\s*$/u, "") ?? "", items: r, note: e };
78
+ const s = i.match(I);
79
+ if (s) {
80
+ const c = s[1].trim(), d = i.slice(s[0].length).replace(/^[::]\s*/u, "").trim().replace(/[。..]\s*$/u, "").split(/[;;]\s*/u).map((g) => g.trim()).filter(Boolean);
81
+ return { headline: c, items: d, note: e };
82
+ }
83
+ return { headline: i, items: [], note: e };
84
+ }
85
+ function $(t) {
86
+ const n = N(t);
87
+ if (!n) return "";
88
+ const e = [n.headline];
89
+ return n.items.length > 0 && e.push(n.items.map((i, r) => `${r + 1}. ${i}`).join(`
90
+ `)), n.note && e.push(n.note), e.filter(Boolean).join(`
91
+ `);
92
+ }
93
+ function b(t) {
94
+ return t === _ || t === h || t === T;
95
+ }
96
+ function x(t) {
97
+ return t === E;
98
+ }
99
+ function D(t) {
100
+ return m.test(
101
+ o(t).trimStart()
66
102
  );
67
103
  }
68
- function E(t) {
69
- const n = l(t).trim();
104
+ function k(t) {
105
+ const n = o(t).trim();
70
106
  if (!n) return { intent: "", misplacedPlanning: "" };
71
107
  const e = n.search(/\n\n第 \d+ 轮:/u);
72
108
  return e >= 0 ? {
73
109
  intent: n.slice(0, e).trim(),
74
110
  misplacedPlanning: n.slice(e).trim()
75
- } : c.test(n) ? { intent: "", misplacedPlanning: n } : { intent: n, misplacedPlanning: "" };
111
+ } : m.test(n) ? { intent: "", misplacedPlanning: n } : { intent: n, misplacedPlanning: "" };
76
112
  }
77
- function I(t) {
78
- return E(t).intent;
113
+ function G(t) {
114
+ return k(t).intent;
79
115
  }
80
- function O(t) {
81
- const n = l(t).trim();
82
- return n ? n.replace(g, "").trim() : "";
116
+ function w(t) {
117
+ const n = o(t).trim();
118
+ return n ? n.replace(L, "").trim() : "";
83
119
  }
84
120
  export {
85
- s as TOOL_STEP_ANSWER_DELIMITER,
86
- d as composeToolStepContent,
87
- I as getIntentStepDisplayContent,
88
- l as humanizeSpotlightStepContent,
89
- k as isAnswerStep,
90
- N as isLoopPlanningChunk,
91
- A as isToolExecutionStep,
92
- P as sanitizeToolStepAnswerText,
93
- E as splitIntentStepContent,
94
- L as splitToolStepContent,
95
- O as stripLoopPlanningBlocks
121
+ a as TOOL_STEP_ANSWER_DELIMITER,
122
+ B as composeToolStepContent,
123
+ $ as formatGatherProcessText,
124
+ G as getIntentStepDisplayContent,
125
+ o as humanizeSpotlightStepContent,
126
+ x as isAnswerStep,
127
+ D as isLoopPlanningChunk,
128
+ b as isToolExecutionStep,
129
+ N as parseGatherProcessDisplay,
130
+ C as sanitizeToolStepAnswerText,
131
+ k as splitIntentStepContent,
132
+ P as splitToolStepContent,
133
+ R as stripInternalEvidenceAnswer,
134
+ w as stripLoopPlanningBlocks
96
135
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inupedia/spotlight-vue",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "description": "Thin Vue runtime for Inupedia Spotlight Client Tools",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -91,8 +91,8 @@
91
91
  "dependencies": {
92
92
  "prettier": "^3.8.1",
93
93
  "yaml": "^2.8.4",
94
- "@inupedia/spotlight-client": "0.5.17",
95
- "@inupedia/spotlight-protocol": "0.5.17"
94
+ "@inupedia/spotlight-protocol": "0.5.19",
95
+ "@inupedia/spotlight-client": "0.5.19"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "@inspira-ui/plugins": "^0.0.2",