@siact/sime-x-vue 0.0.18 → 0.0.20
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.
- package/dist/sime-x-vue.mjs +69 -18
- package/dist/sime-x-vue.mjs.map +1 -1
- package/dist/sime-x-vue.umd.js +69 -18
- package/dist/sime-x-vue.umd.js.map +1 -1
- package/dist/style.css +109 -109
- package/package.json +1 -1
- package/types/components/sime-provider.vue.d.ts +2 -0
- package/types/types.d.ts +10 -0
package/dist/sime-x-vue.mjs
CHANGED
|
@@ -106,7 +106,7 @@ const _hoisted_9$2 = ["onClick"];
|
|
|
106
106
|
const _hoisted_10$2 = { class: "ai-chat__messages-inner" };
|
|
107
107
|
const _hoisted_11$2 = { class: "ai-chat__message-content" };
|
|
108
108
|
const _hoisted_12$2 = ["innerHTML"];
|
|
109
|
-
const _hoisted_13$
|
|
109
|
+
const _hoisted_13$1 = {
|
|
110
110
|
key: 1,
|
|
111
111
|
class: "ai-chat__reasoning"
|
|
112
112
|
};
|
|
@@ -469,7 +469,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
469
469
|
innerHTML: renderMarkdown(part.text)
|
|
470
470
|
}, null, 8, _hoisted_12$2)
|
|
471
471
|
])
|
|
472
|
-
], 2)) : part.type === "reasoning" ? (openBlock(), createElementBlock("div", _hoisted_13$
|
|
472
|
+
], 2)) : part.type === "reasoning" ? (openBlock(), createElementBlock("div", _hoisted_13$1, [
|
|
473
473
|
createElementVNode("button", {
|
|
474
474
|
class: "ai-chat__reasoning-trigger",
|
|
475
475
|
onClick: ($event) => toggleReasoning(message.id)
|
|
@@ -1464,7 +1464,7 @@ const _hoisted_10$1 = {
|
|
|
1464
1464
|
};
|
|
1465
1465
|
const _hoisted_11$1 = { class: "input-bar" };
|
|
1466
1466
|
const _hoisted_12$1 = ["disabled"];
|
|
1467
|
-
const _hoisted_13
|
|
1467
|
+
const _hoisted_13 = ["disabled"];
|
|
1468
1468
|
const _hoisted_14 = {
|
|
1469
1469
|
key: 0,
|
|
1470
1470
|
class: "btn-spinner",
|
|
@@ -1511,6 +1511,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1511
1511
|
scrollToBottom: () => {
|
|
1512
1512
|
}
|
|
1513
1513
|
};
|
|
1514
|
+
const test = () => {
|
|
1515
|
+
aiChatbotX.speakText("你好,世界,今天是想起五天气横扫的缺点");
|
|
1516
|
+
};
|
|
1517
|
+
const test1 = () => {
|
|
1518
|
+
aiChatbotX.abortInvoke();
|
|
1519
|
+
};
|
|
1514
1520
|
const endpoint = `/sime/proxy/organizations/${aiChatbotX.organizationId()}/agents/${props.agentId}/stream-invoke`;
|
|
1515
1521
|
const agent = useAgentInvoke({
|
|
1516
1522
|
endpoint,
|
|
@@ -1549,6 +1555,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1549
1555
|
class: "command-test",
|
|
1550
1556
|
"data-theme": currentTheme$1
|
|
1551
1557
|
}, [
|
|
1558
|
+
createElementVNode("button", { onClick: test }, "测试"),
|
|
1559
|
+
createElementVNode("button", { onClick: test1 }, "测试1"),
|
|
1552
1560
|
createVNode(Transition, { name: "bubble-fade" }, {
|
|
1553
1561
|
default: withCtx(() => [
|
|
1554
1562
|
unref(showBubble) ? (openBlock(), createElementBlock("div", {
|
|
@@ -1663,14 +1671,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1663
1671
|
"stroke-linejoin": "round"
|
|
1664
1672
|
}, null, -1)
|
|
1665
1673
|
])]))
|
|
1666
|
-
], 8, _hoisted_13
|
|
1674
|
+
], 8, _hoisted_13)
|
|
1667
1675
|
])
|
|
1668
1676
|
]);
|
|
1669
1677
|
};
|
|
1670
1678
|
}
|
|
1671
1679
|
});
|
|
1672
1680
|
|
|
1673
|
-
const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
1681
|
+
const commandTest = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2d2cea1f"]]);
|
|
1674
1682
|
|
|
1675
1683
|
class CommandManager {
|
|
1676
1684
|
commands = /* @__PURE__ */ new Map();
|
|
@@ -1731,7 +1739,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1731
1739
|
__name: "sime-provider",
|
|
1732
1740
|
props: {
|
|
1733
1741
|
appToken: {},
|
|
1734
|
-
organizationId: {}
|
|
1742
|
+
organizationId: {},
|
|
1743
|
+
projectId: {}
|
|
1735
1744
|
},
|
|
1736
1745
|
setup(__props) {
|
|
1737
1746
|
const props = __props;
|
|
@@ -1742,6 +1751,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1742
1751
|
});
|
|
1743
1752
|
const stopBroadcastRef = shallowRef(async () => {
|
|
1744
1753
|
});
|
|
1754
|
+
const voiceAssistantRef = shallowRef(null);
|
|
1745
1755
|
provide(AiChatbotXKey, {
|
|
1746
1756
|
appToken: () => props.appToken,
|
|
1747
1757
|
organizationId: () => props.organizationId,
|
|
@@ -1753,6 +1763,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1753
1763
|
if (methods.start) startListeningRef.value = methods.start;
|
|
1754
1764
|
if (methods.stop) stopListeningRef.value = methods.stop;
|
|
1755
1765
|
},
|
|
1766
|
+
registerVoiceAssistant: (methods) => {
|
|
1767
|
+
voiceAssistantRef.value = methods;
|
|
1768
|
+
},
|
|
1756
1769
|
getCommads: async () => commandManager.value.getCommands(),
|
|
1757
1770
|
registerCommand: (cmd) => {
|
|
1758
1771
|
commandManager.value.registerCommand(cmd);
|
|
@@ -1762,6 +1775,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1762
1775
|
},
|
|
1763
1776
|
async executeCommand(commandName, args = []) {
|
|
1764
1777
|
return await commandManager.value.executeCommand(commandName, args);
|
|
1778
|
+
},
|
|
1779
|
+
sendMessage: async (text) => {
|
|
1780
|
+
voiceAssistantRef.value?.agentInvoke(text);
|
|
1781
|
+
},
|
|
1782
|
+
speakText: (text) => {
|
|
1783
|
+
voiceAssistantRef.value?.speakText(text);
|
|
1784
|
+
},
|
|
1785
|
+
stopSpeak: () => {
|
|
1786
|
+
voiceAssistantRef.value?.stopSpeak();
|
|
1787
|
+
},
|
|
1788
|
+
abortInvoke: () => {
|
|
1789
|
+
voiceAssistantRef.value?.agentAbort();
|
|
1765
1790
|
}
|
|
1766
1791
|
});
|
|
1767
1792
|
return (_ctx, _cache) => {
|
|
@@ -1789,7 +1814,27 @@ function useTTS(getVoiceConfig) {
|
|
|
1789
1814
|
}
|
|
1790
1815
|
return -1;
|
|
1791
1816
|
};
|
|
1792
|
-
const
|
|
1817
|
+
const normalizeNumbers = (text) => {
|
|
1818
|
+
return text.replace(/(-?\d[\d,]*\.?\d*)\s*%/g, (_, num) => {
|
|
1819
|
+
const cleanNum = num.replace(/,/g, "");
|
|
1820
|
+
const n = parseFloat(cleanNum);
|
|
1821
|
+
const spoken = cleanNum.replace(".", "点");
|
|
1822
|
+
if (n < 0) return `负百分之${spoken.replace("-", "")}`;
|
|
1823
|
+
return `百分之${spoken}`;
|
|
1824
|
+
}).replace(/(-?\d[\d,]*)\.(\d+)/g, (_, intPart, decPart) => {
|
|
1825
|
+
const cleanInt = intPart.replace(/,/g, "");
|
|
1826
|
+
if (cleanInt.startsWith("-")) {
|
|
1827
|
+
return `负${cleanInt.slice(1)}点${decPart}`;
|
|
1828
|
+
}
|
|
1829
|
+
return `${cleanInt}点${decPart}`;
|
|
1830
|
+
}).replace(/-(\d)/g, "负$1");
|
|
1831
|
+
};
|
|
1832
|
+
const stripMarkdown = (text) => {
|
|
1833
|
+
let result = text.replace(/```[\s\S]*?```/g, "").replace(/\|[^\n]*\|/g, "").replace(/#{1,6}\s*/g, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/`([^`]*)`/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^[-*+]\s+/gm, "").replace(/^>\s+/gm, "");
|
|
1834
|
+
result = normalizeNumbers(result);
|
|
1835
|
+
result = result.replace(/\s*\+\s*(?=\d)/g, "加").replace(/\s*\+\s*/g, "加").replace(/\s*-\s*(?=\d)/g, "减").replace(/\s*-\s*/g, "减").replace(/\s*×\s*/g, "乘").replace(/\s*÷\s*/g, "除").replace(/\s*=\s*/g, "等于").replace(/\n{2,}/g, "。").replace(/\n/g, ",").trim();
|
|
1836
|
+
return result;
|
|
1837
|
+
};
|
|
1793
1838
|
const normalizeSpeakText = (text, options) => {
|
|
1794
1839
|
const clean = stripMarkdown(text).replace(LEADING_WEAK_PUNCTUATION, "").trim();
|
|
1795
1840
|
if (!clean) return "";
|
|
@@ -2209,12 +2254,8 @@ const _hoisted_10 = {
|
|
|
2209
2254
|
key: 2,
|
|
2210
2255
|
class: "agent-text"
|
|
2211
2256
|
};
|
|
2212
|
-
const _hoisted_11 = {
|
|
2213
|
-
|
|
2214
|
-
class: "status-pill"
|
|
2215
|
-
};
|
|
2216
|
-
const _hoisted_12 = { class: "fab-avatar-wrapper" };
|
|
2217
|
-
const _hoisted_13 = ["src"];
|
|
2257
|
+
const _hoisted_11 = { class: "fab-avatar-wrapper" };
|
|
2258
|
+
const _hoisted_12 = ["src"];
|
|
2218
2259
|
const currentTheme = "dark";
|
|
2219
2260
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
2220
2261
|
__name: "voice-assistant",
|
|
@@ -2285,6 +2326,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2285
2326
|
tts.stop();
|
|
2286
2327
|
bubble.hide();
|
|
2287
2328
|
};
|
|
2329
|
+
const speakTextWithBubble = (text) => {
|
|
2330
|
+
bubble.open();
|
|
2331
|
+
agent.currentTextContent.value = text;
|
|
2332
|
+
tts.speak(text);
|
|
2333
|
+
};
|
|
2288
2334
|
const voice = useVoiceRecognition({
|
|
2289
2335
|
modelPath: props.modelPath,
|
|
2290
2336
|
wakeWords: props.wakeWords,
|
|
@@ -2303,13 +2349,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2303
2349
|
tts.warmUpAudio();
|
|
2304
2350
|
await voice.toggleVoiceMode(targetState);
|
|
2305
2351
|
};
|
|
2306
|
-
const { voiceStatus,
|
|
2352
|
+
const { voiceStatus, wakeAnimating, isTranscribing } = voice;
|
|
2307
2353
|
const { isInvoking, currentTextContent, currentToolParts, executingTools, hasAnyContent, toolDisplayName } = agent;
|
|
2308
2354
|
aiChatbotX?.registerVoiceMethods({
|
|
2309
2355
|
stopBroadcast: async () => interruptCurrentResponse(),
|
|
2310
2356
|
start: () => toggleVoiceMode(true),
|
|
2311
2357
|
stop: () => toggleVoiceMode(false)
|
|
2312
2358
|
});
|
|
2359
|
+
aiChatbotX?.registerVoiceAssistant({
|
|
2360
|
+
agentInvoke: agent.invoke,
|
|
2361
|
+
agentAbort: agent.abort,
|
|
2362
|
+
speakText: speakTextWithBubble,
|
|
2363
|
+
stopSpeak: tts.stop
|
|
2364
|
+
});
|
|
2313
2365
|
onBeforeUnmount(async () => {
|
|
2314
2366
|
bubble.destroy();
|
|
2315
2367
|
agent.abort();
|
|
@@ -2397,15 +2449,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2397
2449
|
class: "assistant-fab",
|
|
2398
2450
|
onClick: _cache[0] || (_cache[0] = ($event) => toggleVoiceMode())
|
|
2399
2451
|
}, [
|
|
2400
|
-
|
|
2401
|
-
createElementVNode("div", _hoisted_12, [
|
|
2452
|
+
createElementVNode("div", _hoisted_11, [
|
|
2402
2453
|
createElementVNode("img", {
|
|
2403
2454
|
src: __props.xLogo ? __props.xLogo : "/x.png",
|
|
2404
2455
|
alt: "voice assistant",
|
|
2405
2456
|
style: normalizeStyle({
|
|
2406
2457
|
width: `${__props.xSize?.width || 88}px`
|
|
2407
2458
|
})
|
|
2408
|
-
}, null, 12,
|
|
2459
|
+
}, null, 12, _hoisted_12),
|
|
2409
2460
|
createVNode(Transition, { name: "indicator-fade" }, {
|
|
2410
2461
|
default: withCtx(() => [
|
|
2411
2462
|
unref(voiceStatus) === "listening" ? (openBlock(), createElementBlock("div", {
|
|
@@ -2447,7 +2498,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2447
2498
|
}
|
|
2448
2499
|
});
|
|
2449
2500
|
|
|
2450
|
-
const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
2501
|
+
const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5f5506a2"]]);
|
|
2451
2502
|
|
|
2452
2503
|
var clientCommandKey = /* @__PURE__ */ ((clientCommandKey2) => {
|
|
2453
2504
|
clientCommandKey2["SET_THEME"] = "SiMeAgent_setTheme";
|