@siact/sime-x-vue 0.0.12 → 0.0.14

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.
@@ -774,20 +774,30 @@
774
774
  debug: { type: Boolean },
775
775
  chatbotUrl: {},
776
776
  appId: {},
777
- appToken: {}
777
+ appToken: {},
778
+ agentId: {}
778
779
  },
779
780
  setup(__props) {
780
781
  const props = __props;
781
782
  const commandManager = vue.shallowRef(new CommandManager({ debug: props.debug ?? false }));
783
+ const startListeningRef = vue.shallowRef(async () => {
784
+ });
785
+ const stopListeningRef = vue.shallowRef(async () => {
786
+ });
782
787
  const stopBroadcastRef = vue.shallowRef(async () => {
783
788
  });
784
789
  vue.provide(AiChatbotXKey, {
785
790
  chatbotUrl: () => props.chatbotUrl,
786
791
  appId: () => props.appId,
787
792
  appToken: () => props.appToken,
793
+ agentId: () => props.agentId,
794
+ startListening: () => startListeningRef.value(),
795
+ stopListening: () => stopListeningRef.value(),
788
796
  stopBroadcast: () => stopBroadcastRef.value(),
789
797
  registerVoiceMethods: (methods) => {
790
798
  if (methods.stopBroadcast) stopBroadcastRef.value = methods.stopBroadcast;
799
+ if (methods.start) startListeningRef.value = methods.start;
800
+ if (methods.stop) stopListeningRef.value = methods.stop;
791
801
  },
792
802
  getCommads: async () => commandManager.value.getCommands(),
793
803
  registerCommand: (cmd) => {
@@ -1770,9 +1780,9 @@
1770
1780
  const commandDefinitions = buildCommandDefinitionMap(commands);
1771
1781
  conversationHistory.value.length > 0 ? [...conversationHistory.value] : void 0;
1772
1782
  try {
1773
- const response = await fetch(options.endpoint.value, {
1783
+ const response = await fetch(options.endpoint, {
1774
1784
  method: "POST",
1775
- headers: { "Content-Type": "application/json" },
1785
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.appToken || ""}` },
1776
1786
  body: JSON.stringify({
1777
1787
  input: content,
1778
1788
  projectId: options.projectId || "",
@@ -1949,9 +1959,9 @@
1949
1959
  xSize: {},
1950
1960
  xTheme: {},
1951
1961
  wakeWords: {},
1962
+ wakeResponses: {},
1952
1963
  modelPath: {},
1953
1964
  projectId: {},
1954
- invokeUrl: {},
1955
1965
  voiceConfig: {},
1956
1966
  bubbleSize: {},
1957
1967
  bubbleDismissDelay: {}
@@ -1963,10 +1973,7 @@
1963
1973
  if (props.voiceConfig) return props.voiceConfig;
1964
1974
  return null;
1965
1975
  };
1966
- const endpoint = vue.computed(() => {
1967
- return props.invokeUrl || "http://localhost:3001/agent/zyy55sw40nrl801056m0o/stream-invoke";
1968
- });
1969
- const wakeResponses = ["在呢"];
1976
+ const wakeResponses = vue.computed(() => props.wakeResponses || ["在呢"]);
1970
1977
  const tts = useTTS(getVoiceConfig);
1971
1978
  const bubbleBridge = {
1972
1979
  open: () => {
@@ -1976,8 +1983,10 @@
1976
1983
  scrollToBottom: () => {
1977
1984
  }
1978
1985
  };
1986
+ const endpoint = `/sime/proxy/agent/${aiChatbotX.agentId()}/stream-invoke`;
1979
1987
  const agent = useAgentInvoke({
1980
1988
  endpoint,
1989
+ appToken: aiChatbotX.appToken(),
1981
1990
  projectId: props.projectId,
1982
1991
  aiChatbotX,
1983
1992
  tts: {
@@ -2016,7 +2025,7 @@
2016
2025
  onWake: () => {
2017
2026
  interruptCurrentResponse();
2018
2027
  tts.warmUpAudio();
2019
- const text = wakeResponses[Math.floor(Math.random() * wakeResponses.length)];
2028
+ const text = wakeResponses.value[Math.floor(Math.random() * wakeResponses.value.length)];
2020
2029
  tts.speak(text);
2021
2030
  },
2022
2031
  onTranscriptionDone: (text) => {
@@ -2030,7 +2039,9 @@
2030
2039
  const { voiceStatus, transcriptionText, wakeAnimating, isTranscribing } = voice;
2031
2040
  const { isInvoking, currentTextContent, currentToolParts, executingTools, hasAnyContent, toolDisplayName } = agent;
2032
2041
  aiChatbotX?.registerVoiceMethods({
2033
- stopBroadcast: async () => interruptCurrentResponse()
2042
+ stopBroadcast: async () => interruptCurrentResponse(),
2043
+ start: () => toggleVoiceMode(true),
2044
+ stop: () => toggleVoiceMode(false)
2034
2045
  });
2035
2046
  vue.onBeforeUnmount(async () => {
2036
2047
  bubble.destroy();
@@ -2122,7 +2133,7 @@
2122
2133
  vue.unref(transcriptionText) || vue.unref(isInvoking) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, vue.toDisplayString(vue.unref(isInvoking) ? "正在思考中..." : vue.unref(transcriptionText)), 1)) : vue.createCommentVNode("", true),
2123
2134
  vue.createElementVNode("div", _hoisted_12, [
2124
2135
  vue.createElementVNode("img", {
2125
- src: __props.xLogo ? __props.xLogo : "/sime.png",
2136
+ src: __props.xLogo ? __props.xLogo : "/x.png",
2126
2137
  alt: "voice assistant",
2127
2138
  style: vue.normalizeStyle({
2128
2139
  width: `${__props.xSize?.width || 88}px`
@@ -2169,7 +2180,7 @@
2169
2180
  }
2170
2181
  });
2171
2182
 
2172
- const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fda883a9"]]);
2183
+ const voiceAssistant = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-76f6b7ef"]]);
2173
2184
 
2174
2185
  var clientCommandKey = /* @__PURE__ */ ((clientCommandKey2) => {
2175
2186
  clientCommandKey2["SET_THEME"] = "SiMeAgent_setTheme";