@fv-ui/ai-chat 0.12.1 → 0.12.3

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.
Files changed (3) hide show
  1. package/es/index.mjs +35 -10
  2. package/lib/index.js +35 -10
  3. package/package.json +1 -1
package/es/index.mjs CHANGED
@@ -4913,7 +4913,10 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4913
4913
  }
4914
4914
  let lastFlushAt = 0;
4915
4915
  let lastFlushChars = 0;
4916
+ let orchestrated = false;
4916
4917
  watch(() => props.items, (items) => {
4918
+ const firstRun = !orchestrated;
4919
+ orchestrated = true;
4917
4920
  const now = Date.now();
4918
4921
  let flushedChars = 0;
4919
4922
  const flushCounting = (it) => {
@@ -4937,7 +4940,7 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4937
4940
  }
4938
4941
  }
4939
4942
  for (const it of items) {
4940
- if (it.typing && it.closed && preRegistered.has(it.key)) flushCounting(it);
4943
+ if (it.closed && (preRegistered.has(it.key) || !firstRun)) flushCounting(it);
4941
4944
  }
4942
4945
  if (flushedChars > 0) {
4943
4946
  lastFlushAt = now;
@@ -4950,6 +4953,12 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4950
4953
  function typingOf(item) {
4951
4954
  return typingConfigs.value.get(item.key) ?? true;
4952
4955
  }
4956
+ const lastTypingKey = computed(() => {
4957
+ for (let i = props.items.length - 1; i >= 0; i--) {
4958
+ if (isTypingItem(props.items[i])) return props.items[i].key;
4959
+ }
4960
+ return null;
4961
+ });
4953
4962
  function isTypingItem(item) {
4954
4963
  if (flushedKeys.value.has(item.key)) return false;
4955
4964
  if (holdingKeys.value.has(item.key)) return true;
@@ -5159,8 +5168,8 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
5159
5168
  class: normalizeClass(["fv-chain-title", { "is-clamped": __props.collapsible && showToggle(item.key) && !expandedKeys.value.has(item.key) }])
5160
5169
  },
5161
5170
  [
5162
- createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE;\r\n \u5EF6\u8FDF\u5F00\u6253\u7B49\u5F85\u671F(holding)\u6E32\u67D3\u7A7A\u5360\u4F4D,\u5230\u70B9\u518D\u6302\u6253\u5B57\u673A "),
5163
- isTypingItem(item) && !holdingKeys.value.has(item.key) ? (openBlock(), createBlock(_sfc_main$h, {
5171
+ createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE;\r\n \u5EF6\u8FDF\u5F00\u6253\u7B49\u5F85\u671F(holding)\u6E32\u67D3\u7A7A\u5360\u4F4D,\u5230\u70B9\u518D\u6302\u6253\u5B57\u673A;\r\n \u6574\u94FE\u4E0D\u53D8\u5F0F:\u81F3\u591A\u6700\u540E\u4E00\u4E2A\u5019\u9009\u6253\u5B57\u6B65\u6302\u6253\u5B57\u673A(lastTypingKey),\r\n \u5176\u4F59\u9759\u6001\u5168\u91CF\u2014\u2014\u65B0\u6B65\u5DF2\u5230\u573A,\u65E7\u6B65\u4E0D\u62D6\u62CD,\u7ED3\u6784\u4E0A\u675C\u7EDD\u591A\u6B65\u5E76\u884C\u9010\u5B57 "),
5172
+ isTypingItem(item) && item.key === lastTypingKey.value && !holdingKeys.value.has(item.key) ? (openBlock(), createBlock(_sfc_main$h, {
5164
5173
  key: 0,
5165
5174
  content: normalizeTitle(item.title),
5166
5175
  typing: typingOf(item),
@@ -6751,6 +6760,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6751
6760
  { immediate: true }
6752
6761
  );
6753
6762
  const useTypewriter = computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6763
+ const reasoningFlushed = ref(false);
6764
+ watch(
6765
+ () => [props.message.content, props.message.status],
6766
+ ([content, status]) => {
6767
+ if (content || status === "done" || status === "error") reasoningFlushed.value = true;
6768
+ },
6769
+ { immediate: true }
6770
+ );
6754
6771
  const textStepIcon = markRaw(ChatLineRound);
6755
6772
  const toolStepIcon = markRaw(Search);
6756
6773
  const toolChainItems = computed(() => {
@@ -6899,13 +6916,21 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6899
6916
  items: toolChainItems.value,
6900
6917
  collapsible: __props.collapsible,
6901
6918
  onTyping: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6902
- }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value ? (openBlock(), createBlock(_sfc_main$h, {
6903
- key: 1,
6904
- content: __props.message.reasoning ?? "",
6905
- "is-markdown": "",
6906
- typing: __props.typing,
6907
- onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6908
- }, null, 8, ["content", "typing"])) : hasReasoning.value ? (openBlock(), createBlock(_sfc_main$i, {
6919
+ }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value && !reasoningFlushed.value ? (openBlock(), createElementBlock(
6920
+ Fragment,
6921
+ { key: 1 },
6922
+ [
6923
+ createCommentVNode(" \u7EAF\u601D\u8003\u6D88\u606F(reasoning \u65E0 toolSteps)\u56DE\u843D\u94FE\u4E0B\u6E32\u67D3:\u6D41\u5F0F\u671F\u95F4 Typewriter \u9010\u5B57,\r\n \u6B63\u6587\u51FA\u73B0/\u601D\u8003\u6536\u53E3\u5373\u51B2\u5237\u56DE\u843D\u9759\u6001 Markdown(\u540C ThoughtChain \u5C01\u53E3\u51B2\u5237\u8BED\u4E49) "),
6924
+ createVNode(_sfc_main$h, {
6925
+ content: __props.message.reasoning ?? "",
6926
+ "is-markdown": "",
6927
+ typing: __props.typing,
6928
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6929
+ }, null, 8, ["content", "typing"])
6930
+ ],
6931
+ 2112
6932
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
6933
+ )) : hasReasoning.value ? (openBlock(), createBlock(_sfc_main$i, {
6909
6934
  key: 2,
6910
6935
  content: __props.message.reasoning ?? ""
6911
6936
  }, null, 8, ["content"])) : createCommentVNode("v-if", true)
package/lib/index.js CHANGED
@@ -4929,7 +4929,10 @@
4929
4929
  }
4930
4930
  let lastFlushAt = 0;
4931
4931
  let lastFlushChars = 0;
4932
+ let orchestrated = false;
4932
4933
  vue.watch(() => props.items, (items) => {
4934
+ const firstRun = !orchestrated;
4935
+ orchestrated = true;
4933
4936
  const now = Date.now();
4934
4937
  let flushedChars = 0;
4935
4938
  const flushCounting = (it) => {
@@ -4953,7 +4956,7 @@
4953
4956
  }
4954
4957
  }
4955
4958
  for (const it of items) {
4956
- if (it.typing && it.closed && preRegistered.has(it.key)) flushCounting(it);
4959
+ if (it.closed && (preRegistered.has(it.key) || !firstRun)) flushCounting(it);
4957
4960
  }
4958
4961
  if (flushedChars > 0) {
4959
4962
  lastFlushAt = now;
@@ -4966,6 +4969,12 @@
4966
4969
  function typingOf(item) {
4967
4970
  return typingConfigs.value.get(item.key) ?? true;
4968
4971
  }
4972
+ const lastTypingKey = vue.computed(() => {
4973
+ for (let i = props.items.length - 1; i >= 0; i--) {
4974
+ if (isTypingItem(props.items[i])) return props.items[i].key;
4975
+ }
4976
+ return null;
4977
+ });
4969
4978
  function isTypingItem(item) {
4970
4979
  if (flushedKeys.value.has(item.key)) return false;
4971
4980
  if (holdingKeys.value.has(item.key)) return true;
@@ -5175,8 +5184,8 @@
5175
5184
  class: vue.normalizeClass(["fv-chain-title", { "is-clamped": __props.collapsible && showToggle(item.key) && !expandedKeys.value.has(item.key) }])
5176
5185
  },
5177
5186
  [
5178
- vue.createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE;\r\n \u5EF6\u8FDF\u5F00\u6253\u7B49\u5F85\u671F(holding)\u6E32\u67D3\u7A7A\u5360\u4F4D,\u5230\u70B9\u518D\u6302\u6253\u5B57\u673A "),
5179
- isTypingItem(item) && !holdingKeys.value.has(item.key) ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
5187
+ vue.createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE;\r\n \u5EF6\u8FDF\u5F00\u6253\u7B49\u5F85\u671F(holding)\u6E32\u67D3\u7A7A\u5360\u4F4D,\u5230\u70B9\u518D\u6302\u6253\u5B57\u673A;\r\n \u6574\u94FE\u4E0D\u53D8\u5F0F:\u81F3\u591A\u6700\u540E\u4E00\u4E2A\u5019\u9009\u6253\u5B57\u6B65\u6302\u6253\u5B57\u673A(lastTypingKey),\r\n \u5176\u4F59\u9759\u6001\u5168\u91CF\u2014\u2014\u65B0\u6B65\u5DF2\u5230\u573A,\u65E7\u6B65\u4E0D\u62D6\u62CD,\u7ED3\u6784\u4E0A\u675C\u7EDD\u591A\u6B65\u5E76\u884C\u9010\u5B57 "),
5188
+ isTypingItem(item) && item.key === lastTypingKey.value && !holdingKeys.value.has(item.key) ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
5180
5189
  key: 0,
5181
5190
  content: normalizeTitle(item.title),
5182
5191
  typing: typingOf(item),
@@ -6767,6 +6776,14 @@
6767
6776
  { immediate: true }
6768
6777
  );
6769
6778
  const useTypewriter = vue.computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6779
+ const reasoningFlushed = vue.ref(false);
6780
+ vue.watch(
6781
+ () => [props.message.content, props.message.status],
6782
+ ([content, status]) => {
6783
+ if (content || status === "done" || status === "error") reasoningFlushed.value = true;
6784
+ },
6785
+ { immediate: true }
6786
+ );
6770
6787
  const textStepIcon = vue.markRaw(ElementPlusIconsVue.ChatLineRound);
6771
6788
  const toolStepIcon = vue.markRaw(ElementPlusIconsVue.Search);
6772
6789
  const toolChainItems = vue.computed(() => {
@@ -6915,13 +6932,21 @@
6915
6932
  items: toolChainItems.value,
6916
6933
  collapsible: __props.collapsible,
6917
6934
  onTyping: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6918
- }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
6919
- key: 1,
6920
- content: __props.message.reasoning ?? "",
6921
- "is-markdown": "",
6922
- typing: __props.typing,
6923
- onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6924
- }, null, 8, ["content", "typing"])) : hasReasoning.value ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6935
+ }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value && !reasoningFlushed.value ? (vue.openBlock(), vue.createElementBlock(
6936
+ vue.Fragment,
6937
+ { key: 1 },
6938
+ [
6939
+ vue.createCommentVNode(" \u7EAF\u601D\u8003\u6D88\u606F(reasoning \u65E0 toolSteps)\u56DE\u843D\u94FE\u4E0B\u6E32\u67D3:\u6D41\u5F0F\u671F\u95F4 Typewriter \u9010\u5B57,\r\n \u6B63\u6587\u51FA\u73B0/\u601D\u8003\u6536\u53E3\u5373\u51B2\u5237\u56DE\u843D\u9759\u6001 Markdown(\u540C ThoughtChain \u5C01\u53E3\u51B2\u5237\u8BED\u4E49) "),
6940
+ vue.createVNode(_sfc_main$h, {
6941
+ content: __props.message.reasoning ?? "",
6942
+ "is-markdown": "",
6943
+ typing: __props.typing,
6944
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6945
+ }, null, 8, ["content", "typing"])
6946
+ ],
6947
+ 2112
6948
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
6949
+ )) : hasReasoning.value ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6925
6950
  key: 2,
6926
6951
  content: __props.message.reasoning ?? ""
6927
6952
  }, null, 8, ["content"])) : vue.createCommentVNode("v-if", true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fv-ui/ai-chat",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "基于 Vue3 + Element Plus 的 AI 对话组件库",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",