@myun/gimi-chat 0.9.63 → 0.9.65
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 +0 -6
- package/dist/apis/useApi.js +1 -45
- package/dist/components/ai-chat-dialogue/index copy.js +1 -1
- package/dist/components/ai-chat-dialogue/index.js +2 -4
- package/dist/components/answer-item/index.d.ts +1 -2
- package/dist/components/answer-item/index.js +8 -179
- package/dist/components/answer-item/index.module.css +0 -35
- package/dist/components/ask-card/index.d.ts +1 -1
- package/dist/components/chat-input/extension/index.d.ts +0 -1
- package/dist/components/chat-input/extension/index.js +1 -2
- package/dist/components/chat-input/index.js +24 -145
- package/dist/components/file-card/index.js +1 -2
- package/dist/components/file-card/index.module.css +0 -1
- package/dist/components/knowledge-trace/tryWatch.js +1 -1
- package/dist/components/message-list/index.js +3 -15
- package/dist/components/message-list/index.module.css +0 -3
- package/dist/components/templates/CommonChat.js +1 -3
- package/dist/hooks/useChatActions.d.ts +1 -2
- package/dist/hooks/useChatActions.js +12 -52
- package/dist/hooks/useChatStream.d.ts +1 -6
- package/dist/hooks/useChatStream.js +5 -97
- package/dist/hooks/useCommonChatAPI.d.ts +1 -1
- package/dist/hooks/useCommonChatAPI.js +58 -212
- package/dist/i18n/locales/en-US.d.ts +0 -6
- package/dist/i18n/locales/en-US.js +1 -7
- package/dist/i18n/locales/zh-CN.d.ts +0 -6
- package/dist/i18n/locales/zh-CN.js +1 -7
- package/dist/interfaces/chatMessage.d.ts +0 -40
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +0 -7
- package/dist/utils/tools.js +1 -38
- package/package.json +2 -4
- package/dist/components/answer-item/component/artifacts/index.d.ts +0 -13
- package/dist/components/answer-item/component/artifacts/index.js +0 -52
- package/dist/components/answer-item/component/artifacts/index.module.css +0 -24
- package/dist/components/answer-item/component/tool-list/index.d.ts +0 -7
- package/dist/components/answer-item/component/tool-list/index.js +0 -117
- package/dist/components/answer-item/component/tool-list/index.module.css +0 -97
- package/dist/components/chat-input/extension/skill/MentionList.d.ts +0 -31
- package/dist/components/chat-input/extension/skill/MentionList.js +0 -199
- package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +0 -3
- package/dist/components/chat-input/extension/skill/ReferSlot.js +0 -100
- package/dist/components/chat-input/extension/skill/data.d.ts +0 -10
- package/dist/components/chat-input/extension/skill/data.js +0 -49
- package/dist/components/chat-input/extension/skill/index.d.ts +0 -7
- package/dist/components/chat-input/extension/skill/index.js +0 -5
- package/dist/components/chat-input/extension/skill/index.less +0 -117
- package/dist/components/chat-input/extension/skill/suggestion.d.ts +0 -16
- package/dist/components/chat-input/extension/skill/suggestion.js +0 -206
- package/dist/components/message-list/skill-tag/index.d.ts +0 -5
- package/dist/components/message-list/skill-tag/index.js +0 -23
- package/dist/components/message-list/skill-tag/index.module.css +0 -21
|
@@ -1,24 +1,20 @@
|
|
|
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
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
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."); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
3
|
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
8
6
|
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); } }
|
|
9
7
|
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); }); }; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
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); }
|
|
10
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
12
|
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."); }
|
|
12
13
|
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); }
|
|
13
14
|
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; }
|
|
14
15
|
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; } }
|
|
15
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
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; }
|
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
20
|
-
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); }
|
|
21
|
-
import React, { useContext, useEffect, useMemo } from "react";
|
|
17
|
+
import React, { useContext } from "react";
|
|
22
18
|
import { useTranslation } from 'react-i18next';
|
|
23
19
|
import { AIChatInput, Divider, Popover } from '@douyinfe/semi-ui';
|
|
24
20
|
import { transformToInputSlots } from "../../utils/chatInputUtil";
|
|
@@ -37,33 +33,20 @@ import UploadList from "../upload-list";
|
|
|
37
33
|
import { FileStatus } from "../../interfaces/fileInterface";
|
|
38
34
|
import LottieImg from "../lottie-img";
|
|
39
35
|
import AIChatDialogue from "../ai-chat-dialogue";
|
|
40
|
-
import { Keydown, TitleSlot
|
|
36
|
+
import { Keydown, TitleSlot } from "./extension";
|
|
41
37
|
import QuotedContent from "../quoted-content";
|
|
42
38
|
import { ReferencesEdit } from "../reference-content";
|
|
43
39
|
import IconFontCom from "../iconfont-com";
|
|
44
40
|
import VoiceBars from "../voice-bars";
|
|
45
41
|
import classNames from 'classnames';
|
|
46
|
-
import { maxInputLength } from "../../utils/tools";
|
|
47
42
|
var extractText = function extractText() {
|
|
48
43
|
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
49
|
-
var skipSkill = arguments.length > 1 ? arguments[1] : undefined;
|
|
50
44
|
return content.map(function (item) {
|
|
51
45
|
if (item.type === 'text' && typeof item.text === 'string') {
|
|
52
46
|
return item.text;
|
|
53
47
|
}
|
|
54
|
-
// skill 节点序列化为 <skilltool> 标记发送,取值来自 content 中 transformer 展开后的 item
|
|
55
|
-
|
|
56
|
-
if (item.type === 'skill' && !skipSkill) {
|
|
57
|
-
var _skill$toolId, _skill$toolType, _skill$toolName;
|
|
58
|
-
var skill = item;
|
|
59
|
-
return "<skilltool>".concat(JSON.stringify({
|
|
60
|
-
toolId: (_skill$toolId = skill.toolId) !== null && _skill$toolId !== void 0 ? _skill$toolId : '',
|
|
61
|
-
toolType: (_skill$toolType = skill.toolType) !== null && _skill$toolType !== void 0 ? _skill$toolType : '',
|
|
62
|
-
toolName: (_skill$toolName = skill.toolName) !== null && _skill$toolName !== void 0 ? _skill$toolName : ''
|
|
63
|
-
}), "</skilltool>");
|
|
64
|
-
}
|
|
65
48
|
if (item.content && Array.isArray(item.content)) {
|
|
66
|
-
return extractText(item.content
|
|
49
|
+
return extractText(item.content);
|
|
67
50
|
}
|
|
68
51
|
return '';
|
|
69
52
|
}).join('');
|
|
@@ -101,32 +84,12 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
101
84
|
var inputWrapRef = React.useRef(null);
|
|
102
85
|
var preInputValueRef = React.useRef('');
|
|
103
86
|
var inputRef = React.useRef(null);
|
|
104
|
-
var isTruncatingRef = React.useRef(false);
|
|
105
87
|
var uploadFileRef = React.useRef(null);
|
|
106
88
|
var conversationIdRef = React.useRef(conversationId);
|
|
107
89
|
conversationIdRef.current = conversationId;
|
|
108
90
|
var agentObjRef = React.useRef(agentObj);
|
|
109
91
|
agentObjRef.current = agentObj;
|
|
110
|
-
|
|
111
|
-
return new Map([['referSlot', function (obj) {
|
|
112
|
-
var _obj$attrs = obj.attrs,
|
|
113
|
-
attrs = _obj$attrs === void 0 ? {} : _obj$attrs;
|
|
114
|
-
var value = attrs.value,
|
|
115
|
-
info = attrs.info,
|
|
116
|
-
_attrs$type = attrs.type,
|
|
117
|
-
type = _attrs$type === void 0 ? 'text' : _attrs$type,
|
|
118
|
-
uniqueKey = attrs.uniqueKey;
|
|
119
|
-
return _objectSpread({
|
|
120
|
-
type: type,
|
|
121
|
-
value: value,
|
|
122
|
-
uniqueKey: uniqueKey
|
|
123
|
-
}, JSON.parse(info || '{}'));
|
|
124
|
-
}]]);
|
|
125
|
-
}, []);
|
|
126
|
-
var extensions = useMemo(function () {
|
|
127
|
-
// 使用 / 触发 skill 下拉面板,选中后插入 referSlot
|
|
128
|
-
return [ReferSlot, SkillMention];
|
|
129
|
-
}, []);
|
|
92
|
+
|
|
130
93
|
// 语音聊天相关
|
|
131
94
|
var _React$useState = React.useState(false),
|
|
132
95
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -142,26 +105,6 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
142
105
|
apiService = _useContext.apiService;
|
|
143
106
|
var _ref = apiService,
|
|
144
107
|
createRoomId = _ref.createRoomId;
|
|
145
|
-
|
|
146
|
-
// skill 面板由 tiptap ReactRenderer 渲染、脱离 Context 树,注入 agentId 与 apiService 供其拉取接口
|
|
147
|
-
useEffect(function () {
|
|
148
|
-
setSkillContext({
|
|
149
|
-
getAgentId: function getAgentId() {
|
|
150
|
-
var _agentObjRef$current;
|
|
151
|
-
return (_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.agentId;
|
|
152
|
-
},
|
|
153
|
-
getApiService: function getApiService() {
|
|
154
|
-
return apiService !== null && apiService !== void 0 ? apiService : null;
|
|
155
|
-
},
|
|
156
|
-
getSkillDisplay: function getSkillDisplay() {
|
|
157
|
-
var _agentObjRef$current2;
|
|
158
|
-
return (_agentObjRef$current2 = agentObjRef.current) === null || _agentObjRef$current2 === void 0 ? void 0 : _agentObjRef$current2.skillDisplay;
|
|
159
|
-
},
|
|
160
|
-
getCurrentTextLength: function getCurrentTextLength() {
|
|
161
|
-
return preInputValueRef.current.length;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}, [apiService]);
|
|
165
108
|
React.useEffect(function () {
|
|
166
109
|
if (!props.defaultPrompt) {
|
|
167
110
|
setHasContent(false);
|
|
@@ -193,49 +136,12 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
193
136
|
});
|
|
194
137
|
var onContentChange = React.useCallback(function (content) {
|
|
195
138
|
var _props$onValueChange;
|
|
196
|
-
// 长度按 extractText 的完整值计算(含 skill 序列化后的 <skilltool> 字符串)
|
|
197
139
|
var value = extractText(content);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var editor = (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || (_inputRef$current4$ge = _inputRef$current4.getEditor) === null || _inputRef$current4$ge === void 0 ? void 0 : _inputRef$current4$ge.call(_inputRef$current4);
|
|
204
|
-
var ranges = [];
|
|
205
|
-
editor === null || editor === void 0 || editor.state.doc.descendants(function (node, pos) {
|
|
206
|
-
if (node.isText && node.text) {
|
|
207
|
-
ranges.push({
|
|
208
|
-
from: pos,
|
|
209
|
-
to: pos + node.text.length
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
return true;
|
|
213
|
-
});
|
|
214
|
-
var textTotal = ranges.reduce(function (sum, r) {
|
|
215
|
-
return sum + (r.to - r.from);
|
|
216
|
-
}, 0);
|
|
217
|
-
// 文本字符不足以抵掉超出量(超出来自 skill 节点本身),删也没用,避免死循环
|
|
218
|
-
if (editor && textTotal >= overflow) {
|
|
219
|
-
Toast.warning(t('chatInput.maxLength'));
|
|
220
|
-
var tr = editor.state.tr;
|
|
221
|
-
var remaining = overflow;
|
|
222
|
-
for (var i = ranges.length - 1; i >= 0 && remaining > 0; i--) {
|
|
223
|
-
var _ranges$i = ranges[i],
|
|
224
|
-
from = _ranges$i.from,
|
|
225
|
-
to = _ranges$i.to;
|
|
226
|
-
var take = Math.min(remaining, to - from);
|
|
227
|
-
tr.delete(tr.mapping.map(to - take), tr.mapping.map(to));
|
|
228
|
-
remaining -= take;
|
|
229
|
-
}
|
|
230
|
-
if (tr.docChanged) {
|
|
231
|
-
// 防止删除本身再次触发截断逻辑;删除后长度正好等于上限,
|
|
232
|
-
// 由它触发的这次回调会走下面的正常分支去同步 state
|
|
233
|
-
isTruncatingRef.current = true;
|
|
234
|
-
editor.view.dispatch(tr);
|
|
235
|
-
isTruncatingRef.current = false;
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
140
|
+
if (value.length > 10000) {
|
|
141
|
+
var _inputRef$current4;
|
|
142
|
+
Toast.warning(t('chatInput.maxLength'));
|
|
143
|
+
value = value.slice(0, 10000);
|
|
144
|
+
(_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.setContent(value);
|
|
239
145
|
}
|
|
240
146
|
setHasContent(value.trim().length > 0);
|
|
241
147
|
preInputValueRef.current = value;
|
|
@@ -281,37 +187,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
281
187
|
var el = inputWrapRef.current;
|
|
282
188
|
if (!el) return;
|
|
283
189
|
var handlePaste = function handlePaste(e) {
|
|
284
|
-
var _e$clipboardData,
|
|
285
|
-
var
|
|
286
|
-
var pasteText = ((_e$clipboardData2 = e.clipboardData) === null || _e$clipboardData2 === void 0 ? void 0 : _e$clipboardData2.getData('text/plain')) || '';
|
|
287
|
-
var items = Array.from(((_e$clipboardData3 = e.clipboardData) === null || _e$clipboardData3 === void 0 ? void 0 : _e$clipboardData3.items) || []);
|
|
190
|
+
var _e$clipboardData, _agentObjRef$current, _fileList$length, _uploadFileRef$curren;
|
|
191
|
+
var items = Array.from(((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.items) || []);
|
|
288
192
|
var imageItem = items.find(function (item) {
|
|
289
193
|
return item.kind === 'file' && item.type.startsWith('image/');
|
|
290
194
|
});
|
|
291
|
-
|
|
292
|
-
// 含技能节点时,降级为纯文本插入(剥离 refer-slot 标签)
|
|
293
|
-
if (!imageItem && pasteHtml.includes('<refer-slot')) {
|
|
294
|
-
e.preventDefault();
|
|
295
|
-
e.stopPropagation();
|
|
296
|
-
if (pasteText) {
|
|
297
|
-
var _inputRef$current7;
|
|
298
|
-
if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
|
|
299
|
-
Toast.warning(t('chatInput.maxLength'));
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
(_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.getEditor()) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.commands) === null || _inputRef$current7 === void 0 || _inputRef$current7.insertContent(pasteText);
|
|
303
|
-
}
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
if (!imageItem && pasteText) {
|
|
307
|
-
if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
|
|
308
|
-
e.preventDefault();
|
|
309
|
-
e.stopPropagation();
|
|
310
|
-
Toast.warning(t('chatInput.maxLength'));
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
195
|
if (!imageItem) return;
|
|
316
196
|
|
|
317
197
|
// 有图片时阻止 tiptap 默认行为(避免图片被插入编辑器)
|
|
@@ -319,7 +199,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
319
199
|
e.preventDefault();
|
|
320
200
|
|
|
321
201
|
// 前置校验:上传功能是否开启
|
|
322
|
-
if (!props.enableFileUpload || ((_agentObjRef$
|
|
202
|
+
if (!props.enableFileUpload || ((_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.openUploadFile) === 0) return;
|
|
323
203
|
if (props.disabled || isAskProcess) return;
|
|
324
204
|
if (((_fileList$length = fileList === null || fileList === void 0 ? void 0 : fileList.length) !== null && _fileList$length !== void 0 ? _fileList$length : 0) >= 10) {
|
|
325
205
|
Toast.info(t('chatInput.uploadLimitTen'));
|
|
@@ -609,7 +489,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
609
489
|
return file.status === FileStatus.UPLOADING || file.status === FileStatus.PADDING || file.status === FileStatus.RETRING;
|
|
610
490
|
});
|
|
611
491
|
if (uploadingFile) {
|
|
612
|
-
var _inputRef$
|
|
492
|
+
var _inputRef$current7;
|
|
613
493
|
// 文件处理中,恢复输入内容,不发送
|
|
614
494
|
var message = '';
|
|
615
495
|
if (uploadingFile.status === FileStatus.UPLOADING || uploadingFile.status === FileStatus.RETRING) {
|
|
@@ -618,7 +498,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
618
498
|
message = t('fileValidation.parsing');
|
|
619
499
|
}
|
|
620
500
|
Toast.info(message);
|
|
621
|
-
(_inputRef$
|
|
501
|
+
(_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || _inputRef$current7.setContent(text);
|
|
622
502
|
return;
|
|
623
503
|
}
|
|
624
504
|
(_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
|
|
@@ -721,11 +601,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
721
601
|
};
|
|
722
602
|
var handleInterrupt = function handleInterrupt() {
|
|
723
603
|
var _props$onInterrupt;
|
|
724
|
-
|
|
604
|
+
var latestMessage = messageList[messageList.length - 1];
|
|
725
605
|
// 如果模型没有返回或正处于工作流调用阶段,不允许打断
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
606
|
+
if (latestMessage.role === 1 && (!latestMessage.content && !latestMessage.reasoningContent || latestMessage.mcp)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
729
609
|
(_props$onInterrupt = props.onInterrupt) === null || _props$onInterrupt === void 0 || _props$onInterrupt.call(props);
|
|
730
610
|
};
|
|
731
611
|
var defaultContent = transformToInputSlots(props.defaultPrompt || '', props.titleSlot || '');
|
|
@@ -785,8 +665,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
785
665
|
canSend: !props.disabled && hasContent,
|
|
786
666
|
onMessageSend: onMessageSend,
|
|
787
667
|
generating: isMsgRecieving,
|
|
788
|
-
extensions: [TitleSlot, Keydown]
|
|
789
|
-
transformer: transformer
|
|
668
|
+
extensions: [TitleSlot, Keydown]
|
|
790
669
|
}, props)), showChatCommunication && /*#__PURE__*/React.createElement(AIChatDialogue, {
|
|
791
670
|
paper: {
|
|
792
671
|
enableCaptions: false,
|
|
@@ -8,7 +8,6 @@ import { setFilePreviewState, openSidebar } from "../../store/slices/gimiMenuSli
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { IconChevronRightStroked } from '@douyinfe/semi-icons';
|
|
10
10
|
import IconFontCom from "../iconfont-com";
|
|
11
|
-
import { documentConstants } from "../../constants";
|
|
12
11
|
export var FileCard = function FileCard(_ref) {
|
|
13
12
|
var fileName = _ref.fileName,
|
|
14
13
|
downloadUrl = _ref.downloadUrl,
|
|
@@ -51,7 +50,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
51
50
|
}, /*#__PURE__*/React.createElement("div", {
|
|
52
51
|
className: styles.icon
|
|
53
52
|
}, /*#__PURE__*/React.createElement("img", {
|
|
54
|
-
src:
|
|
53
|
+
src: fileImgMap[fileType] || fileImgMap['xlsx'],
|
|
55
54
|
alt: ""
|
|
56
55
|
})), /*#__PURE__*/React.createElement("div", {
|
|
57
56
|
className: styles.left
|
|
@@ -256,7 +256,7 @@ var TryWatch = function TryWatch(_ref7) {
|
|
|
256
256
|
var _useTranslation4 = useTranslation(),
|
|
257
257
|
t = _useTranslation4.t;
|
|
258
258
|
var handleFull = function handleFull() {
|
|
259
|
-
if (item.isDelete === 1) return;
|
|
259
|
+
if (item.isDelete === 1 || item.isDeleted === 1) return;
|
|
260
260
|
if (platform !== 'myun') return Toast.warning(t('trace.jumpUnsupported'));
|
|
261
261
|
if (type === 'information') {
|
|
262
262
|
handleInformation();
|
|
@@ -24,8 +24,6 @@ import { FileStatus } from "../../interfaces/fileInterface";
|
|
|
24
24
|
import useChatActions from "../../hooks/useChatActions";
|
|
25
25
|
import CopyButton from "../message-actions/CopyButton";
|
|
26
26
|
import { Virtuoso } from 'react-virtuoso';
|
|
27
|
-
import { MMarkdown } from '@myun/gimi-design';
|
|
28
|
-
import SkillTag from "./skill-tag";
|
|
29
27
|
var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
30
28
|
var _v$quoteTeachModelLis, _v$quoteProductList, _v$messageFilesList;
|
|
31
29
|
var v = props.v,
|
|
@@ -43,7 +41,6 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
43
41
|
handleClickPromptWord = props.handleClickPromptWord,
|
|
44
42
|
handleShowCourse = props.handleShowCourse,
|
|
45
43
|
handleClickAskList = props.handleClickAskList,
|
|
46
|
-
handleClickConfirm = props.handleClickConfirm,
|
|
47
44
|
playTTSByText = props.playTTSByText,
|
|
48
45
|
stopTTSByText = props.stopTTSByText,
|
|
49
46
|
isPlaying = props.isPlaying,
|
|
@@ -76,13 +73,7 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
76
73
|
quoteTeachModelList: v.quoteTeachModelList
|
|
77
74
|
}), v.content && /*#__PURE__*/React.createElement("div", {
|
|
78
75
|
className: styles.title
|
|
79
|
-
}, /*#__PURE__*/React.createElement(
|
|
80
|
-
content: replaceBraces(v.content) || '',
|
|
81
|
-
customRender: [{
|
|
82
|
-
type: 'skilltool',
|
|
83
|
-
component: SkillTag
|
|
84
|
-
}]
|
|
85
|
-
})), v.messageFiles && /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
}, replaceBraces(v.content)), v.messageFiles && /*#__PURE__*/React.createElement("div", {
|
|
86
77
|
className: styles.listBox
|
|
87
78
|
}, /*#__PURE__*/React.createElement(UploadList, {
|
|
88
79
|
isMessage: true,
|
|
@@ -111,7 +102,6 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
111
102
|
handleClickPromptWord: handleClickPromptWord,
|
|
112
103
|
handleShowCourse: handleShowCourse,
|
|
113
104
|
handleClickAskList: handleClickAskList,
|
|
114
|
-
handleClickConfirm: handleClickConfirm,
|
|
115
105
|
playTTSByText: playTTSByText,
|
|
116
106
|
stopTTSByText: stopTTSByText,
|
|
117
107
|
isVoicePlaying: isPlaying,
|
|
@@ -180,8 +170,7 @@ var MessageList = function MessageList(_ref) {
|
|
|
180
170
|
// 使用 chatActions hook 提供的函数
|
|
181
171
|
var showOpera = chatActions.showOpera,
|
|
182
172
|
showCommend = chatActions.showCommend,
|
|
183
|
-
handleClickAskList = chatActions.handleClickAskList
|
|
184
|
-
handleClickConfirm = chatActions.handleClickConfirm;
|
|
173
|
+
handleClickAskList = chatActions.handleClickAskList;
|
|
185
174
|
var handleClickPromptWord = React.useCallback(function (prompt) {
|
|
186
175
|
handleSend(prompt);
|
|
187
176
|
}, [handleSend]);
|
|
@@ -290,7 +279,6 @@ var MessageList = function MessageList(_ref) {
|
|
|
290
279
|
handleClickPromptWord: handleClickPromptWord,
|
|
291
280
|
handleShowCourse: handleShowCourse,
|
|
292
281
|
handleClickAskList: handleClickAskList,
|
|
293
|
-
handleClickConfirm: handleClickConfirm,
|
|
294
282
|
playTTSByText: playTTSByText,
|
|
295
283
|
stopTTSByText: stopTTSByText,
|
|
296
284
|
isPlaying: isPlaying,
|
|
@@ -306,7 +294,7 @@ var MessageList = function MessageList(_ref) {
|
|
|
306
294
|
onCurrentTraceVideoClick: onCurrentTraceVideoClick,
|
|
307
295
|
curPlayer: curPlayer
|
|
308
296
|
});
|
|
309
|
-
}, [chatUI, hideUserMessage, showOpera, onCopyCallback, onSucessExcel, onFailureExcel, onRetryExcel, showCommend, handleClickPromptWord, handleShowCourse, handleClickAskList,
|
|
297
|
+
}, [chatUI, hideUserMessage, showOpera, onCopyCallback, onSucessExcel, onFailureExcel, onRetryExcel, showCommend, handleClickPromptWord, handleShowCourse, handleClickAskList, playTTSByText, stopTTSByText, isPlaying, onRegenerateClick, enableCopy, enableLike, enableUnLike, enableRegenerate, enableVoicePlay, onDownloadCallback, reasoningTitle, model, handleReTry, onLikeCallback, onUnLikeCallback]);
|
|
310
298
|
return /*#__PURE__*/React.createElement("div", {
|
|
311
299
|
className: classNames(styles.main),
|
|
312
300
|
style: buildStyle()
|
|
@@ -261,9 +261,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
261
261
|
width: '100%'
|
|
262
262
|
}
|
|
263
263
|
}, /*#__PURE__*/React.createElement(AiLoading, null)), /*#__PURE__*/React.createElement(MessageList, _extends({
|
|
264
|
-
chatList: messageList || defaultMessages
|
|
265
|
-
// chatList={defaultMessages}
|
|
266
|
-
,
|
|
264
|
+
chatList: messageList || defaultMessages,
|
|
267
265
|
handleSend: handleSend,
|
|
268
266
|
platform: platform,
|
|
269
267
|
inputModelRef: inputModelRef,
|
|
@@ -7,7 +7,6 @@ export declare const usePureChatActions: () => {
|
|
|
7
7
|
declare const useChatActions: (showCopyId: number | null, inputModelRef: React.MutableRefObject<any>, handleSend: (val: string, agent?: any, isSystemAuto?: boolean) => void) => {
|
|
8
8
|
showOpera: (id: number) => boolean;
|
|
9
9
|
showCommend: (id: number) => boolean;
|
|
10
|
-
handleClickAskList: (item: any, operation: string, key: string, value?: string | undefined
|
|
11
|
-
handleClickConfirm: (item: any, confirmed: boolean) => void;
|
|
10
|
+
handleClickAskList: (item: any, operation: string, key: string, value?: string | undefined) => void;
|
|
12
11
|
};
|
|
13
12
|
export default useChatActions;
|
|
@@ -79,24 +79,22 @@ export var usePureChatActions = function usePureChatActions() {
|
|
|
79
79
|
replaceTags.forEach(function (tag) {
|
|
80
80
|
text = text.replace(new RegExp("<".concat(tag, ">(.*?)</").concat(tag, ">"), 'g'), '');
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
_context.prev = 5;
|
|
85
|
-
_context.next = 8;
|
|
82
|
+
_context.prev = 4;
|
|
83
|
+
_context.next = 7;
|
|
86
84
|
return navigator.clipboard.writeText(text);
|
|
87
|
-
case
|
|
85
|
+
case 7:
|
|
88
86
|
Toast.success(t('action.copySuccess'));
|
|
89
|
-
_context.next =
|
|
87
|
+
_context.next = 13;
|
|
90
88
|
break;
|
|
91
|
-
case
|
|
92
|
-
_context.prev =
|
|
93
|
-
_context.t0 = _context["catch"](
|
|
89
|
+
case 10:
|
|
90
|
+
_context.prev = 10;
|
|
91
|
+
_context.t0 = _context["catch"](4);
|
|
94
92
|
Toast.error(t('action.copyFailed'));
|
|
95
|
-
case
|
|
93
|
+
case 13:
|
|
96
94
|
case "end":
|
|
97
95
|
return _context.stop();
|
|
98
96
|
}
|
|
99
|
-
}, _callee, null, [[
|
|
97
|
+
}, _callee, null, [[4, 10]]);
|
|
100
98
|
}));
|
|
101
99
|
return function (_x) {
|
|
102
100
|
return _ref2.apply(this, arguments);
|
|
@@ -189,13 +187,13 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
189
187
|
* 点击问询列表
|
|
190
188
|
*/
|
|
191
189
|
var handleClickAskList = React.useMemo(function () {
|
|
192
|
-
return debounce(function (item, operation, key, value
|
|
190
|
+
return debounce(function (item, operation, key, value) {
|
|
193
191
|
var _messageList8;
|
|
194
192
|
var messageList = messageListRef.current;
|
|
195
193
|
if ((_messageList8 = messageList[messageList.length - 1]) !== null && _messageList8 !== void 0 && _messageList8.selectValue) {
|
|
196
194
|
return;
|
|
197
195
|
}
|
|
198
|
-
var _inputModel =
|
|
196
|
+
var _inputModel = _defineProperty({}, "".concat(item.id, ".").concat(operation), key);
|
|
199
197
|
inputModelRef.current = _inputModel;
|
|
200
198
|
var newMessageList = updateLastMessage(messageList, function (lastMessage) {
|
|
201
199
|
return _objectSpread(_objectSpread({}, lastMessage), {}, {
|
|
@@ -208,48 +206,10 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
208
206
|
handleSend(value || '');
|
|
209
207
|
}, 100);
|
|
210
208
|
}, [handleSend, inputModelRef, dispatch]);
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 确认/拒绝工具调用
|
|
214
|
-
* 绕开 ask 的 selectValue 防重逻辑,直接组装 user_confirm inputModel 发送
|
|
215
|
-
*/
|
|
216
|
-
var handleClickConfirm = React.useCallback(function (item, confirmed) {
|
|
217
|
-
var _lastMessage$toolList, _item$data, _item$data2;
|
|
218
|
-
// 1. 更新最后一条消息的 toolList,把这条 user_confirm 改成已确认/已拒绝
|
|
219
|
-
var currentMessageList = messageListRef.current;
|
|
220
|
-
var lastMessage = currentMessageList[currentMessageList.length - 1];
|
|
221
|
-
var updatedToolList = (_lastMessage$toolList = lastMessage.toolList) === null || _lastMessage$toolList === void 0 ? void 0 : _lastMessage$toolList.map(function (tool) {
|
|
222
|
-
return tool.id === item.id ? _objectSpread(_objectSpread({}, tool), {}, {
|
|
223
|
-
moduleType: "user_confirm",
|
|
224
|
-
status: 'COMPLETED',
|
|
225
|
-
confirmStatus: confirmed ? "CONFIRMED" : "REJECTED"
|
|
226
|
-
}) : tool;
|
|
227
|
-
});
|
|
228
|
-
var updatedMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
|
|
229
|
-
toolList: updatedToolList
|
|
230
|
-
})]);
|
|
231
|
-
dispatch(setMessageList({
|
|
232
|
-
messageList: updatedMessageList
|
|
233
|
-
}));
|
|
234
|
-
|
|
235
|
-
// 2. 组装 inputModel 并发送
|
|
236
|
-
var inputModel = {
|
|
237
|
-
user_confirm: {
|
|
238
|
-
askingEventId: (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.askingEventId,
|
|
239
|
-
confirmResults: [{
|
|
240
|
-
toolCallId: ((_item$data2 = item.data) === null || _item$data2 === void 0 || (_item$data2 = _item$data2.toolCalls) === null || _item$data2 === void 0 || (_item$data2 = _item$data2[0]) === null || _item$data2 === void 0 ? void 0 : _item$data2.id) || '',
|
|
241
|
-
confirmed: confirmed
|
|
242
|
-
}]
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
inputModelRef.current = inputModel;
|
|
246
|
-
handleSend('', undefined, true, undefined, true); // skipCreateNewMessage: true 复用当前消息
|
|
247
|
-
}, [handleSend, inputModelRef, dispatch]);
|
|
248
209
|
return {
|
|
249
210
|
showOpera: showOpera,
|
|
250
211
|
showCommend: showCommend,
|
|
251
|
-
handleClickAskList: handleClickAskList
|
|
252
|
-
handleClickConfirm: handleClickConfirm
|
|
212
|
+
handleClickAskList: handleClickAskList
|
|
253
213
|
};
|
|
254
214
|
};
|
|
255
215
|
export default useChatActions;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const TOOL_MODULE_TYPES: string[];
|
|
3
|
-
export declare const MODULE_TYPE_NAMES: Record<string, string>;
|
|
4
|
-
export declare const getToolNameByStatus: (moduleType: string, status?: string) => string;
|
|
5
2
|
interface StreamChatCallbacks {
|
|
6
3
|
onSseOpen?: (response: Response) => void;
|
|
7
4
|
onDataReceived?: (response: string, type: 'content' | 'reasoningContent') => void;
|
|
8
|
-
onComplete?: (response: any, type: string, reasoningResponse?: string
|
|
5
|
+
onComplete?: (response: any, type: string, reasoningResponse?: string) => void;
|
|
9
6
|
onErrorComplete?: () => void;
|
|
10
7
|
onMCPToolsStream?: (dataObj: any) => void;
|
|
11
|
-
onToolStream?: (dataObj: any) => void;
|
|
12
|
-
onArtifactStream?: (dataObj: any) => void;
|
|
13
8
|
}
|
|
14
9
|
/**
|
|
15
10
|
* 处理流式聊天逻辑
|