@myun/gimi-chat 0.9.65 → 0.9.67
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/apis/useApi.d.ts +6 -0
- package/dist/apis/useApi.js +45 -1
- package/dist/components/ai-chat-dialogue/index copy.js +1 -1
- package/dist/components/ai-chat-dialogue/index.js +4 -2
- package/dist/components/answer-item/component/artifacts/index.d.ts +13 -0
- package/dist/components/answer-item/component/artifacts/index.js +52 -0
- package/dist/components/answer-item/component/artifacts/index.module.css +24 -0
- package/dist/components/answer-item/component/tool-list/index.d.ts +7 -0
- package/dist/components/answer-item/component/tool-list/index.js +117 -0
- package/dist/components/answer-item/component/tool-list/index.module.css +97 -0
- package/dist/components/answer-item/index.d.ts +2 -1
- package/dist/components/answer-item/index.js +179 -8
- package/dist/components/answer-item/index.module.css +35 -0
- package/dist/components/ask-card/index.d.ts +1 -1
- package/dist/components/chat-input/extension/index.d.ts +1 -0
- package/dist/components/chat-input/extension/index.js +2 -1
- package/dist/components/chat-input/extension/skill/MentionList.d.ts +32 -0
- package/dist/components/chat-input/extension/skill/MentionList.js +206 -0
- package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +3 -0
- package/dist/components/chat-input/extension/skill/ReferSlot.js +100 -0
- package/dist/components/chat-input/extension/skill/data.d.ts +10 -0
- package/dist/components/chat-input/extension/skill/data.js +49 -0
- package/dist/components/chat-input/extension/skill/index.d.ts +7 -0
- package/dist/components/chat-input/extension/skill/index.js +5 -0
- package/dist/components/chat-input/extension/skill/index.less +117 -0
- package/dist/components/chat-input/extension/skill/suggestion.d.ts +16 -0
- package/dist/components/chat-input/extension/skill/suggestion.js +228 -0
- package/dist/components/chat-input/index.js +145 -24
- package/dist/components/chat-input/index.module.css +6 -0
- package/dist/components/file-card/index.js +2 -1
- package/dist/components/file-card/index.module.css +1 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +6 -1
- package/dist/components/knowledge-trace/tryWatch.js +2 -2
- package/dist/components/message-list/index.js +15 -3
- package/dist/components/message-list/index.module.css +3 -0
- package/dist/components/message-list/skill-tag/index.d.ts +5 -0
- package/dist/components/message-list/skill-tag/index.js +23 -0
- package/dist/components/message-list/skill-tag/index.module.css +22 -0
- package/dist/components/templates/CommonChat.js +3 -1
- package/dist/hooks/useChatActions.d.ts +2 -1
- package/dist/hooks/useChatActions.js +52 -12
- package/dist/hooks/useChatStream.d.ts +6 -1
- package/dist/hooks/useChatStream.js +97 -5
- package/dist/hooks/useCommonChatAPI.d.ts +1 -1
- package/dist/hooks/useCommonChatAPI.js +212 -58
- package/dist/i18n/locales/en-US.d.ts +7 -0
- package/dist/i18n/locales/en-US.js +8 -1
- package/dist/i18n/locales/zh-CN.d.ts +7 -0
- package/dist/i18n/locales/zh-CN.js +8 -1
- package/dist/interfaces/chatMessage.d.ts +40 -0
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +7 -0
- package/dist/utils/tools.js +38 -1
- package/package.json +4 -2
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
21
|
import { useTranslation } from 'react-i18next';
|
|
3
22
|
import styles from "./index.module.css";
|
|
4
23
|
import classNames from 'classnames';
|
|
5
24
|
import ReasoningContent from "../reasoning-content/index";
|
|
6
|
-
import { processString } from "../../utils/tools";
|
|
25
|
+
import { processString, formatDurationMs } from "../../utils/tools";
|
|
7
26
|
import { MMarkdown } from '@myun/gimi-design';
|
|
8
27
|
import AskCard from "../ask-card";
|
|
9
28
|
import WorkFlowContent from "../work-flow-content";
|
|
@@ -13,14 +32,20 @@ import ExcelCard from "../excel-components/ExcelCard";
|
|
|
13
32
|
import WordCard from "../custom-render/WordCard";
|
|
14
33
|
import { IconTickCircle } from '@douyinfe/semi-icons';
|
|
15
34
|
import VoicePlay from "../message-actions/VoicePlay";
|
|
16
|
-
import { useAppSelector } from "../../store/hooks";
|
|
35
|
+
import { useAppDispatch, useAppSelector } from "../../store/hooks";
|
|
17
36
|
import CopyButton from "../message-actions/CopyButton";
|
|
18
37
|
import LikeButton from "../message-actions/LikeButton";
|
|
19
38
|
import UnLikeButton from "../message-actions/UnLikeButton";
|
|
20
39
|
import RegenerateButton from "../message-actions/RegenerateButton";
|
|
21
40
|
import ProductTag from "../product-tag";
|
|
41
|
+
import ToolList from "./component/tool-list";
|
|
42
|
+
import IconFont from "../iconfont-com";
|
|
43
|
+
import Artifacts from "./component/artifacts";
|
|
44
|
+
import ChatContext from "../templates/chatContext";
|
|
45
|
+
import { setMessageList } from "../../store/slices/gimiMenuSlice";
|
|
46
|
+
import { TOOL_MODULE_TYPES, getToolNameByStatus } from "../../hooks/useChatStream";
|
|
22
47
|
var AnswerItem = function AnswerItem(_ref) {
|
|
23
|
-
var _agentDetail$voiceCon;
|
|
48
|
+
var _item$thinkingInfo3, _item$thinkingInfo5, _item$thinkingInfo6, _item$thinkingInfo7, _item$toolList, _item$artifacts, _agentDetail$voiceCon;
|
|
24
49
|
var item = _ref.item,
|
|
25
50
|
onSucess = _ref.onSucess,
|
|
26
51
|
onFailure = _ref.onFailure,
|
|
@@ -30,6 +55,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
30
55
|
handleShowCourse = _ref.handleShowCourse,
|
|
31
56
|
handleClickPromptWord = _ref.handleClickPromptWord,
|
|
32
57
|
handleClickAskList = _ref.handleClickAskList,
|
|
58
|
+
handleClickConfirm = _ref.handleClickConfirm,
|
|
33
59
|
playTTSByText = _ref.playTTSByText,
|
|
34
60
|
stopTTSByText = _ref.stopTTSByText,
|
|
35
61
|
isVoicePlaying = _ref.isVoicePlaying,
|
|
@@ -52,8 +78,19 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
52
78
|
model = _ref.model,
|
|
53
79
|
onCurrentTraceVideoClick = _ref.onCurrentTraceVideoClick,
|
|
54
80
|
curPlayer = _ref.curPlayer;
|
|
81
|
+
var _useState = useState(true),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
expendThinking = _useState2[0],
|
|
84
|
+
setExpendThinking = _useState2[1];
|
|
85
|
+
var _useState3 = useState(false),
|
|
86
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
87
|
+
toolLoading = _useState4[0],
|
|
88
|
+
setToolLoading = _useState4[1];
|
|
55
89
|
var _useTranslation = useTranslation(),
|
|
56
90
|
t = _useTranslation.t;
|
|
91
|
+
var _useContext = useContext(ChatContext),
|
|
92
|
+
apiService = _useContext.apiService;
|
|
93
|
+
var dispatch = useAppDispatch();
|
|
57
94
|
var isMsgRecieving = useAppSelector(function (state) {
|
|
58
95
|
return state.gimiMenu.isMsgRecieving;
|
|
59
96
|
});
|
|
@@ -65,6 +102,12 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
65
102
|
var platform = useAppSelector(function (state) {
|
|
66
103
|
return state.gimiMenu.platform;
|
|
67
104
|
});
|
|
105
|
+
var messageList = useAppSelector(function (state) {
|
|
106
|
+
return state.gimiMenu.messageList;
|
|
107
|
+
});
|
|
108
|
+
var conversationId = useAppSelector(function (state) {
|
|
109
|
+
return state.gimiMenu.conversationId || '';
|
|
110
|
+
});
|
|
68
111
|
var handleLinkClickCapture = React.useCallback(function (e) {
|
|
69
112
|
if (platform !== 'preview') return;
|
|
70
113
|
var target = e.target;
|
|
@@ -101,6 +144,8 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
101
144
|
var agentDetail = useAppSelector(function (state) {
|
|
102
145
|
return state.gimiMenu.agentObj || {};
|
|
103
146
|
});
|
|
147
|
+
var agentDetailRef = useRef(agentDetail);
|
|
148
|
+
agentDetailRef.current = agentDetail;
|
|
104
149
|
var customRender = React.useMemo(function () {
|
|
105
150
|
return [{
|
|
106
151
|
type: 'excel',
|
|
@@ -156,6 +201,109 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
156
201
|
// }
|
|
157
202
|
];
|
|
158
203
|
}, [onDownloadCallback, model, item.id]);
|
|
204
|
+
var handleExpendThinking = /*#__PURE__*/function () {
|
|
205
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
206
|
+
var _item$thinkingInfo;
|
|
207
|
+
var _res$result, res, list, toolList, newMessageList;
|
|
208
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
209
|
+
while (1) switch (_context.prev = _context.next) {
|
|
210
|
+
case 0:
|
|
211
|
+
setExpendThinking(!expendThinking);
|
|
212
|
+
if (!(!((_item$thinkingInfo = item.thinkingInfo) !== null && _item$thinkingInfo !== void 0 && _item$thinkingInfo.loaded) && apiService)) {
|
|
213
|
+
_context.next = 14;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
setToolLoading(true);
|
|
217
|
+
_context.next = 5;
|
|
218
|
+
return apiService.getAgentToolList({
|
|
219
|
+
conversationId: item.conversationId || conversationId.toString() || '',
|
|
220
|
+
chatId: item.chatId || '',
|
|
221
|
+
pageSize: 200
|
|
222
|
+
});
|
|
223
|
+
case 5:
|
|
224
|
+
res = _context.sent;
|
|
225
|
+
list = (res === null || res === void 0 || (_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.list) || [];
|
|
226
|
+
if (list !== null && list !== void 0 && list.length) {
|
|
227
|
+
_context.next = 9;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
return _context.abrupt("return");
|
|
231
|
+
case 9:
|
|
232
|
+
// 组装tool数据
|
|
233
|
+
toolList = [];
|
|
234
|
+
list.forEach(function (item) {
|
|
235
|
+
var _data;
|
|
236
|
+
var data = null;
|
|
237
|
+
try {
|
|
238
|
+
data = JSON.parse(item.eventData || '{}');
|
|
239
|
+
} catch (error) {}
|
|
240
|
+
if ([].concat(_toConsumableArray(TOOL_MODULE_TYPES), ["user_confirm", "stream"]).includes(item.moduleType) && !["execute", "notifyWorkflowStart"].includes((_data = data) === null || _data === void 0 ? void 0 : _data.name)) {
|
|
241
|
+
var _data2, _data3;
|
|
242
|
+
// 只处理工作流模式下的 tool_result,其他情况暂不处理
|
|
243
|
+
if (data.moduleType === 'tool_result' && ((_data2 = data) === null || _data2 === void 0 ? void 0 : _data2.name) !== 'executeWorkflow') return;
|
|
244
|
+
|
|
245
|
+
// 为新节点类型根据 status 生成 toolName
|
|
246
|
+
var isNewNodeType = !['tool_invocation', 'tool_result', "user_confirm"].includes(item.moduleType);
|
|
247
|
+
var toolName = isNewNodeType ? getToolNameByStatus(item.moduleType, 'COMPLETED') : (_data3 = data) === null || _data3 === void 0 ? void 0 : _data3.toolName;
|
|
248
|
+
var index = toolList.findIndex(function (v) {
|
|
249
|
+
var _data4;
|
|
250
|
+
return v.id === ((_data4 = data) === null || _data4 === void 0 ? void 0 : _data4.id);
|
|
251
|
+
});
|
|
252
|
+
if (index < 0) {
|
|
253
|
+
toolList.push({
|
|
254
|
+
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
255
|
+
askingEventId: item.askingEventId
|
|
256
|
+
}),
|
|
257
|
+
status: item.confirmStatus === "PENDING" ? "RUNNING" : 'COMPLETED',
|
|
258
|
+
content: data.content || '',
|
|
259
|
+
toolName: item.moduleType === 'stream' && item.status === 'TERMINATED' ? '技能调用已停止' : toolName,
|
|
260
|
+
confirmStatus: item.confirmStatus,
|
|
261
|
+
id: data.id || item.id || +new Date(),
|
|
262
|
+
moduleType: item.moduleType
|
|
263
|
+
});
|
|
264
|
+
} else {
|
|
265
|
+
toolList[index] = _objectSpread(_objectSpread({}, toolList[index]), {}, {
|
|
266
|
+
content: data.content || toolList[index].content
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// 注意:chatId 在 role=0(用户消息) 和 role=1(AI回复) 之间可能共享,
|
|
273
|
+
// 加 type === 1 确保只更新 AI 消息这一条
|
|
274
|
+
newMessageList = messageList.map(function (msg) {
|
|
275
|
+
return msg.chatId === item.chatId && msg.type === 1 ? _objectSpread(_objectSpread({}, msg), {}, {
|
|
276
|
+
moduleType: item.moduleType,
|
|
277
|
+
toolList: toolList,
|
|
278
|
+
thinkingInfo: _objectSpread(_objectSpread({}, item.thinkingInfo), {}, {
|
|
279
|
+
loaded: true
|
|
280
|
+
})
|
|
281
|
+
}) : msg;
|
|
282
|
+
});
|
|
283
|
+
dispatch(setMessageList({
|
|
284
|
+
messageList: newMessageList
|
|
285
|
+
}));
|
|
286
|
+
setToolLoading(false);
|
|
287
|
+
case 14:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _callee);
|
|
292
|
+
}));
|
|
293
|
+
return function handleExpendThinking() {
|
|
294
|
+
return _ref2.apply(this, arguments);
|
|
295
|
+
};
|
|
296
|
+
}();
|
|
297
|
+
useEffect(function () {
|
|
298
|
+
var _item$thinkingInfo2;
|
|
299
|
+
if ((_item$thinkingInfo2 = item.thinkingInfo) !== null && _item$thinkingInfo2 !== void 0 && _item$thinkingInfo2.needInit) {
|
|
300
|
+
handleExpendThinking();
|
|
301
|
+
}
|
|
302
|
+
}, [(_item$thinkingInfo3 = item.thinkingInfo) === null || _item$thinkingInfo3 === void 0 ? void 0 : _item$thinkingInfo3.needInit]);
|
|
303
|
+
useEffect(function () {
|
|
304
|
+
var _item$thinkingInfo4;
|
|
305
|
+
setExpendThinking(!((_item$thinkingInfo4 = item.thinkingInfo) !== null && _item$thinkingInfo4 !== void 0 && _item$thinkingInfo4.collapse));
|
|
306
|
+
}, [(_item$thinkingInfo5 = item.thinkingInfo) === null || _item$thinkingInfo5 === void 0 ? void 0 : _item$thinkingInfo5.collapse]);
|
|
159
307
|
return /*#__PURE__*/React.createElement("div", {
|
|
160
308
|
className: styles.title,
|
|
161
309
|
onClickCapture: handleLinkClickCapture
|
|
@@ -163,10 +311,29 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
163
311
|
className: classNames(styles.answer)
|
|
164
312
|
}, item.mcp && /*#__PURE__*/React.createElement(WorkFlowContent, {
|
|
165
313
|
chatItem: item
|
|
314
|
+
}), (agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.agentMode) === 'workflow' ? /*#__PURE__*/React.createElement(React.Fragment, null, item.vipLevel === 1 && item.reasoningContent && /*#__PURE__*/React.createElement(ReasoningContent, {
|
|
315
|
+
reasoningTitle: reasoningTitle,
|
|
316
|
+
item: item
|
|
317
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
318
|
+
className: styles.thinkingContent
|
|
319
|
+
}, ((_item$thinkingInfo6 = item.thinkingInfo) === null || _item$thinkingInfo6 === void 0 ? void 0 : _item$thinkingInfo6.status) === "COMPLETED" && /*#__PURE__*/React.createElement("div", {
|
|
320
|
+
className: styles.thinkingLabel,
|
|
321
|
+
onClick: function onClick() {
|
|
322
|
+
return handleExpendThinking();
|
|
323
|
+
}
|
|
324
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
325
|
+
className: styles.toolName
|
|
326
|
+
}, (_item$thinkingInfo7 = item.thinkingInfo) === null || _item$thinkingInfo7 === void 0 ? void 0 : _item$thinkingInfo7.toolName), /*#__PURE__*/React.createElement(IconFont, {
|
|
327
|
+
className: classNames(styles.icon, _defineProperty({}, styles.hasContent, expendThinking)),
|
|
328
|
+
type: expendThinking ? "icon-a-jiantoucu2x-copy1" : "icon-a-jiantoucu2x",
|
|
329
|
+
size: 12
|
|
330
|
+
})), expendThinking && /*#__PURE__*/React.createElement(React.Fragment, null, (item === null || item === void 0 ? void 0 : item.toolList) && ((_item$toolList = item.toolList) === null || _item$toolList === void 0 ? void 0 : _item$toolList.length) > 0 && /*#__PURE__*/React.createElement(ToolList, {
|
|
331
|
+
toolList: item.toolList,
|
|
332
|
+
handleClickConfirm: handleClickConfirm
|
|
166
333
|
}), item.vipLevel === 1 && item.reasoningContent && /*#__PURE__*/React.createElement(ReasoningContent, {
|
|
167
334
|
reasoningTitle: reasoningTitle,
|
|
168
335
|
item: item
|
|
169
|
-
}), showTaskSuccess && /*#__PURE__*/React.createElement("div", {
|
|
336
|
+
}))), showTaskSuccess && /*#__PURE__*/React.createElement("div", {
|
|
170
337
|
className: styles.completed
|
|
171
338
|
}, /*#__PURE__*/React.createElement(IconTickCircle, {
|
|
172
339
|
className: styles.checkIcon
|
|
@@ -188,9 +355,11 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
188
355
|
onFailure: onFailure
|
|
189
356
|
}), item.stop === 1 && /*#__PURE__*/React.createElement("div", {
|
|
190
357
|
className: styles.stop
|
|
191
|
-
}, t('answer.stopped')),
|
|
358
|
+
}, t('answer.stopped')), item.artifacts && ((_item$artifacts = item.artifacts) === null || _item$artifacts === void 0 ? void 0 : _item$artifacts.length) > 0 && /*#__PURE__*/React.createElement(Artifacts, {
|
|
359
|
+
artifacts: item.artifacts
|
|
360
|
+
}), showOperation && /*#__PURE__*/React.createElement("div", {
|
|
192
361
|
className: styles.opera
|
|
193
|
-
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement("div", {
|
|
362
|
+
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
194
363
|
className: styles.opera_item
|
|
195
364
|
}, enableCopy && /*#__PURE__*/React.createElement(CopyButton, {
|
|
196
365
|
item: item,
|
|
@@ -209,7 +378,9 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
209
378
|
messageId: item.id
|
|
210
379
|
}), showRegerate && enableRegenerate && /*#__PURE__*/React.createElement(RegenerateButton, {
|
|
211
380
|
onRegenerateClick: onRegenerateClick
|
|
212
|
-
}))
|
|
381
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
382
|
+
className: styles.totalTokensWrap
|
|
383
|
+
}, item !== null && item !== void 0 && item.durationMs ? formatDurationMs(item.durationMs) : '', " ", platform === 'preview' && item.totalTokens ? " | ".concat(Number(item.totalTokens).toLocaleString('en-US'), " Tokens") : ''))), (item.relatedResourceList || []).length > 0 && (showCommend === null || showCommend === void 0 ? void 0 : showCommend(item.id)) && /*#__PURE__*/React.createElement("div", {
|
|
213
384
|
className: styles.quickInputList
|
|
214
385
|
}, (item.relatedResourceList || []).map(function (item, index) {
|
|
215
386
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
height: 18px;
|
|
97
97
|
margin-top: 12px;
|
|
98
98
|
display: flex;
|
|
99
|
+
align-items: center;
|
|
99
100
|
}
|
|
100
101
|
.opera .opera_item {
|
|
101
102
|
display: flex;
|
|
@@ -108,6 +109,12 @@
|
|
|
108
109
|
cursor: pointer;
|
|
109
110
|
user-select: none;
|
|
110
111
|
}
|
|
112
|
+
.opera .totalTokensWrap {
|
|
113
|
+
color: var(--theme-neutral, #4C5A70);
|
|
114
|
+
font-size: 14px;
|
|
115
|
+
line-height: 12px;
|
|
116
|
+
margin-left: 16px;
|
|
117
|
+
}
|
|
111
118
|
|
|
112
119
|
.operaicon {
|
|
113
120
|
height: 20px;
|
|
@@ -265,9 +272,37 @@
|
|
|
265
272
|
padding: 20px;
|
|
266
273
|
}
|
|
267
274
|
|
|
275
|
+
.thinkingContent .thinkingLabel {
|
|
276
|
+
display: flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
width: fit-content;
|
|
279
|
+
cursor: pointer;
|
|
280
|
+
}
|
|
281
|
+
.thinkingContent .thinkingLabel:hover .icon, .thinkingContent .thinkingLabel:hover .toolName {
|
|
282
|
+
color: var(--theme-neutral, #626262);
|
|
283
|
+
}
|
|
284
|
+
.thinkingContent .thinkingLabel .toolName {
|
|
285
|
+
color: var(--theme-mediumNeutral, #B3B2B2);
|
|
286
|
+
font-size: 13px;
|
|
287
|
+
}
|
|
288
|
+
.thinkingContent .thinkingLabel .icon {
|
|
289
|
+
color: var(--theme-mediumNeutral, #B3B2B2);
|
|
290
|
+
}
|
|
291
|
+
|
|
268
292
|
:global(.markdown_container) {
|
|
269
293
|
max-width: 800px;
|
|
270
294
|
}
|
|
295
|
+
:global(.markdown_container) img {
|
|
296
|
+
max-width: 200px;
|
|
297
|
+
max-height: 200px;
|
|
298
|
+
border-radius: 16px;
|
|
299
|
+
}
|
|
300
|
+
:global(.markdown_container) ul {
|
|
301
|
+
list-style-type: disc !important;
|
|
302
|
+
}
|
|
303
|
+
:global(.markdown_container) ul > li::before {
|
|
304
|
+
content: "" !important;
|
|
305
|
+
}
|
|
271
306
|
@media (min-width: 1920px) {
|
|
272
307
|
:global(.markdown_container) {
|
|
273
308
|
max-width: 1000px;
|
|
@@ -3,7 +3,7 @@ import { IChatMessageItem } from '../../interfaces/chatMessage';
|
|
|
3
3
|
interface IProps {
|
|
4
4
|
item: IChatMessageItem;
|
|
5
5
|
moduleInfo: any;
|
|
6
|
-
handleClickAskList: (item: any, operation: string, key: string, value?: string) => void;
|
|
6
|
+
handleClickAskList: (item: any, operation: string, key: string, value?: string, inputModel?: any) => void;
|
|
7
7
|
onAskCardCallback?: () => void;
|
|
8
8
|
}
|
|
9
9
|
declare const AskCard: ({ item, moduleInfo, handleClickAskList, onAskCardCallback }: IProps) => React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IUseApi } from '../../../../apis/useApi';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface SkillItem {
|
|
5
|
+
imageUrl: string;
|
|
6
|
+
toolDesc: string;
|
|
7
|
+
toolCategoryDesc: string;
|
|
8
|
+
toolName: string;
|
|
9
|
+
toolStatus: number;
|
|
10
|
+
toolId: number;
|
|
11
|
+
}
|
|
12
|
+
export interface MentionListRef {
|
|
13
|
+
onKeyDown: (props: {
|
|
14
|
+
event: KeyboardEvent;
|
|
15
|
+
exitCb?: () => void;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
}
|
|
18
|
+
interface MentionListProps {
|
|
19
|
+
items: SkillItem[];
|
|
20
|
+
command: (props: {
|
|
21
|
+
item?: SkillItem;
|
|
22
|
+
allowHotKeySend?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
editor?: any;
|
|
25
|
+
query?: string;
|
|
26
|
+
agentId?: number;
|
|
27
|
+
apiService?: IUseApi | null;
|
|
28
|
+
getCurrentTextLength?: () => number;
|
|
29
|
+
onVisibilityChange?: (visible: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
declare const MentionList: React.ForwardRefExoticComponent<MentionListProps & React.RefAttributes<MentionListRef>>;
|
|
32
|
+
export default MentionList;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
8
|
+
import { Toast } from '@douyinfe/semi-ui';
|
|
9
|
+
import AiLoading from "../../../../components/ai-loading";
|
|
10
|
+
import "./index.less";
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { maxInputLength } from "../../../../utils/tools";
|
|
13
|
+
var MentionList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
14
|
+
var command = _ref.command,
|
|
15
|
+
query = _ref.query,
|
|
16
|
+
agentId = _ref.agentId,
|
|
17
|
+
apiService = _ref.apiService,
|
|
18
|
+
getCurrentTextLength = _ref.getCurrentTextLength,
|
|
19
|
+
onVisibilityChange = _ref.onVisibilityChange;
|
|
20
|
+
var _useState = useState(0),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
selectedIndex = _useState2[0],
|
|
23
|
+
setSelectedIndex = _useState2[1];
|
|
24
|
+
var _useState3 = useState([]),
|
|
25
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
+
skillList = _useState4[0],
|
|
27
|
+
setSkillList = _useState4[1];
|
|
28
|
+
var _useState5 = useState([]),
|
|
29
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
|
+
filterOptions = _useState6[0],
|
|
31
|
+
setFilterOptions = _useState6[1];
|
|
32
|
+
var _useState7 = useState(false),
|
|
33
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
34
|
+
loading = _useState8[0],
|
|
35
|
+
setLoading = _useState8[1];
|
|
36
|
+
var _useTranslation = useTranslation(),
|
|
37
|
+
t = _useTranslation.t;
|
|
38
|
+
|
|
39
|
+
// 选项面板渲染,则 Enter 快捷键应该用于选项面板中,不能用于 AIChatInput 的发送
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
try {
|
|
42
|
+
command({
|
|
43
|
+
allowHotKeySend: false
|
|
44
|
+
});
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error('[skill] MentionList command error:', e);
|
|
47
|
+
}
|
|
48
|
+
// 选项面板卸载,则 Enter 快捷键应该用于 AIChatInput 的发送
|
|
49
|
+
return function () {
|
|
50
|
+
command({
|
|
51
|
+
allowHotKeySend: true
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}, [command]);
|
|
55
|
+
|
|
56
|
+
// 拉取当前智能体技能列表
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (!apiService || !agentId) {
|
|
59
|
+
setSkillList([]);
|
|
60
|
+
setFilterOptions([]);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
var cancelled = false;
|
|
64
|
+
setLoading(true);
|
|
65
|
+
apiService.getAgentSkillList(agentId).then(function (res) {
|
|
66
|
+
var _ref2, _result$data;
|
|
67
|
+
if (cancelled) return;
|
|
68
|
+
// FetchResponse 结构: { message, result, status }
|
|
69
|
+
var result = res === null || res === void 0 ? void 0 : res.result;
|
|
70
|
+
var list = Array.isArray(result) ? result : (_ref2 = (_result$data = result === null || result === void 0 ? void 0 : result.data) !== null && _result$data !== void 0 ? _result$data : result === null || result === void 0 ? void 0 : result.list) !== null && _ref2 !== void 0 ? _ref2 : [];
|
|
71
|
+
setSkillList(list);
|
|
72
|
+
setFilterOptions(list);
|
|
73
|
+
setSelectedIndex(0);
|
|
74
|
+
}).catch(function (e) {
|
|
75
|
+
if (!cancelled) console.error('[skill] getAgentSkillList error:', e);
|
|
76
|
+
}).finally(function () {
|
|
77
|
+
if (!cancelled) setLoading(false);
|
|
78
|
+
});
|
|
79
|
+
return function () {
|
|
80
|
+
cancelled = true;
|
|
81
|
+
};
|
|
82
|
+
}, [apiService, agentId]);
|
|
83
|
+
|
|
84
|
+
// query 变化或数据更新时手动 filter
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
var filter = query && query.length ? skillList.filter(function (item) {
|
|
87
|
+
return item.toolName.toLowerCase().includes((query || '').toLowerCase());
|
|
88
|
+
}) : skillList;
|
|
89
|
+
setFilterOptions(filter);
|
|
90
|
+
setSelectedIndex(0);
|
|
91
|
+
}, [query, skillList]);
|
|
92
|
+
|
|
93
|
+
// 通知外部当前是否有可显示内容(决定面板显示/隐藏)
|
|
94
|
+
useEffect(function () {
|
|
95
|
+
var hasContent = loading || filterOptions.length > 0;
|
|
96
|
+
onVisibilityChange === null || onVisibilityChange === void 0 || onVisibilityChange(hasContent);
|
|
97
|
+
}, [loading, filterOptions.length, onVisibilityChange]);
|
|
98
|
+
var upHandler = function upHandler() {
|
|
99
|
+
setSelectedIndex(function (i) {
|
|
100
|
+
return filterOptions.length ? (i + filterOptions.length - 1) % filterOptions.length : 0;
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var downHandler = function downHandler() {
|
|
104
|
+
setSelectedIndex(function (i) {
|
|
105
|
+
return filterOptions.length ? (i + 1) % filterOptions.length : 0;
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
var selectItem = function selectItem(id) {
|
|
109
|
+
var item = filterOptions[id];
|
|
110
|
+
if (item) {
|
|
111
|
+
if (getCurrentTextLength) {
|
|
112
|
+
var _item$toolId, _item$toolCategoryDes, _item$toolName;
|
|
113
|
+
var serialized = "<skilltool>".concat(JSON.stringify({
|
|
114
|
+
toolId: (_item$toolId = item.toolId) !== null && _item$toolId !== void 0 ? _item$toolId : '',
|
|
115
|
+
toolType: (_item$toolCategoryDes = item.toolCategoryDesc) !== null && _item$toolCategoryDes !== void 0 ? _item$toolCategoryDes : '',
|
|
116
|
+
toolName: (_item$toolName = item.toolName) !== null && _item$toolName !== void 0 ? _item$toolName : ''
|
|
117
|
+
}), "</skilltool>");
|
|
118
|
+
var currentLen = getCurrentTextLength();
|
|
119
|
+
if (currentLen + serialized.length > maxInputLength) {
|
|
120
|
+
Toast.warning(t('common.skillExceedLimit'));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
command({
|
|
125
|
+
item: item
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var onKeyDown = function onKeyDown(_ref3) {
|
|
130
|
+
var event = _ref3.event,
|
|
131
|
+
exitCb = _ref3.exitCb;
|
|
132
|
+
if (event.key === 'ArrowUp') {
|
|
133
|
+
upHandler();
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (event.key === 'ArrowDown') {
|
|
137
|
+
downHandler();
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (event.key === 'Enter') {
|
|
141
|
+
selectItem(selectedIndex);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (event.key === 'Escape') {
|
|
145
|
+
exitCb && exitCb();
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// 暴露给 ReactRenderer(component.ref),键盘事件由 suggestion 转发进来
|
|
152
|
+
var onKeyDownRef = useRef(onKeyDown);
|
|
153
|
+
onKeyDownRef.current = onKeyDown;
|
|
154
|
+
useImperativeHandle(ref, function () {
|
|
155
|
+
return {
|
|
156
|
+
onKeyDown: function onKeyDown(args) {
|
|
157
|
+
return onKeyDownRef.current(args);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
var renderItem = function renderItem(item) {
|
|
162
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
163
|
+
className: "skillItem"
|
|
164
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
165
|
+
src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202608/27/50553_20260827090545.png",
|
|
166
|
+
className: "icon",
|
|
167
|
+
alt: ""
|
|
168
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
169
|
+
className: "name"
|
|
170
|
+
}, item.toolName || ''), /*#__PURE__*/React.createElement("span", {
|
|
171
|
+
className: "toolDesc"
|
|
172
|
+
}, item.toolDesc || ''));
|
|
173
|
+
};
|
|
174
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
className: "ai-chat-input-custom-extension-dropdown-menu",
|
|
176
|
+
style: {
|
|
177
|
+
width: '100%'
|
|
178
|
+
}
|
|
179
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
180
|
+
className: "skillTitle"
|
|
181
|
+
}, t('common.selectSkill')), loading ? /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
style: {
|
|
183
|
+
margin: '20px'
|
|
184
|
+
}
|
|
185
|
+
}, /*#__PURE__*/React.createElement(AiLoading, null)) : filterOptions.length ? /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: "ai-chat-input-custom-extension-dropdown-wrap"
|
|
187
|
+
}, filterOptions.map(function (item, index) {
|
|
188
|
+
return (
|
|
189
|
+
/*#__PURE__*/
|
|
190
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-keyEvents
|
|
191
|
+
React.createElement("div", {
|
|
192
|
+
key: item.toolId || index,
|
|
193
|
+
className: index === selectedIndex ? 'is-selected optionItem' : 'optionItem',
|
|
194
|
+
onClick: function onClick() {
|
|
195
|
+
return selectItem(index);
|
|
196
|
+
},
|
|
197
|
+
onMouseEnter: function onMouseEnter() {
|
|
198
|
+
setSelectedIndex(index);
|
|
199
|
+
}
|
|
200
|
+
}, renderItem(item))
|
|
201
|
+
);
|
|
202
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
203
|
+
className: "item"
|
|
204
|
+
}, t('common.noSkill')));
|
|
205
|
+
});
|
|
206
|
+
export default MentionList;
|