@myun/gimi-chat 0.9.64 → 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/chat-input/index.module.css +0 -6
- package/dist/components/file-card/index.js +1 -2
- package/dist/components/file-card/index.module.css +0 -1
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +1 -6
- package/dist/components/knowledge-trace/tryWatch.js +2 -2
- 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 -7
- package/dist/i18n/locales/en-US.js +1 -8
- package/dist/i18n/locales/zh-CN.d.ts +0 -7
- package/dist/i18n/locales/zh-CN.js +1 -8
- 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 -22
package/dist/apis/useApi.d.ts
CHANGED
|
@@ -86,12 +86,6 @@ export interface IUseApi {
|
|
|
86
86
|
getDocumentTrialUrl: (params: {
|
|
87
87
|
resourceUrl: string;
|
|
88
88
|
}) => Promise<FetchResponse<IDocumentTrialResult>>;
|
|
89
|
-
getAgentSkillList: (agentId: number) => Promise<FetchResponse<any>>;
|
|
90
|
-
getAgentToolList: (params: {
|
|
91
|
-
conversationId: string;
|
|
92
|
-
chatId: string;
|
|
93
|
-
pageSize: number;
|
|
94
|
-
}) => Promise<FetchResponse<any>>;
|
|
95
89
|
}
|
|
96
90
|
declare const useApi: (baseUrl: string, authToken: string, locale?: string) => IUseApi;
|
|
97
91
|
export default useApi;
|
package/dist/apis/useApi.js
CHANGED
|
@@ -553,48 +553,6 @@ var useApi = function useApi(baseUrl, authToken) {
|
|
|
553
553
|
return _ref28.apply(this, arguments);
|
|
554
554
|
};
|
|
555
555
|
}();
|
|
556
|
-
|
|
557
|
-
// 获取当前智能体技能
|
|
558
|
-
var getAgentSkillList = /*#__PURE__*/function () {
|
|
559
|
-
var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(agentId) {
|
|
560
|
-
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
561
|
-
while (1) switch (_context28.prev = _context28.next) {
|
|
562
|
-
case 0:
|
|
563
|
-
return _context28.abrupt("return", fetchService.get('/mcourse/web/agent/tool/list', {
|
|
564
|
-
params: {
|
|
565
|
-
agentId: agentId
|
|
566
|
-
}
|
|
567
|
-
}));
|
|
568
|
-
case 1:
|
|
569
|
-
case "end":
|
|
570
|
-
return _context28.stop();
|
|
571
|
-
}
|
|
572
|
-
}, _callee28);
|
|
573
|
-
}));
|
|
574
|
-
return function getAgentSkillList(_x27) {
|
|
575
|
-
return _ref29.apply(this, arguments);
|
|
576
|
-
};
|
|
577
|
-
}();
|
|
578
|
-
|
|
579
|
-
// 获取当前对话的工具调用
|
|
580
|
-
var getAgentToolList = /*#__PURE__*/function () {
|
|
581
|
-
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
582
|
-
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
583
|
-
while (1) switch (_context29.prev = _context29.next) {
|
|
584
|
-
case 0:
|
|
585
|
-
return _context29.abrupt("return", fetchService.get('/mbot/web/agent-message/event/timeline', {
|
|
586
|
-
params: params
|
|
587
|
-
}));
|
|
588
|
-
case 1:
|
|
589
|
-
case "end":
|
|
590
|
-
return _context29.stop();
|
|
591
|
-
}
|
|
592
|
-
}, _callee29);
|
|
593
|
-
}));
|
|
594
|
-
return function getAgentToolList(_x28) {
|
|
595
|
-
return _ref30.apply(this, arguments);
|
|
596
|
-
};
|
|
597
|
-
}();
|
|
598
556
|
return {
|
|
599
557
|
getSkillData: getSkillData,
|
|
600
558
|
getProductList: getProductList,
|
|
@@ -623,9 +581,7 @@ var useApi = function useApi(baseUrl, authToken) {
|
|
|
623
581
|
checkProductType: checkProductType,
|
|
624
582
|
getBusinessAgent: getBusinessAgent,
|
|
625
583
|
getVideoType: getVideoType,
|
|
626
|
-
getDocumentTrialUrl: getDocumentTrialUrl
|
|
627
|
-
getAgentSkillList: getAgentSkillList,
|
|
628
|
-
getAgentToolList: getAgentToolList
|
|
584
|
+
getDocumentTrialUrl: getDocumentTrialUrl
|
|
629
585
|
};
|
|
630
586
|
};
|
|
631
587
|
export default useApi;
|
|
@@ -494,7 +494,7 @@ var AiExplain = function AiExplain(_ref) {
|
|
|
494
494
|
setIsTextLoading(false);
|
|
495
495
|
}
|
|
496
496
|
// 卡片和问答直接关闭
|
|
497
|
-
if (textData.moduleType === 'skill' || textData.moduleType === 'ask'
|
|
497
|
+
if (textData.moduleType === 'skill' || textData.moduleType === 'ask') {
|
|
498
498
|
// 关闭loading
|
|
499
499
|
setIsTextLoading(false);
|
|
500
500
|
}
|
|
@@ -488,18 +488,16 @@ var AiExplain = function AiExplain(_ref) {
|
|
|
488
488
|
}
|
|
489
489
|
if (text.includes('moduleType')) {
|
|
490
490
|
var textData = splitTextAndModuleTypeJson(text).json || {};
|
|
491
|
-
console.log('textData', textData);
|
|
492
|
-
|
|
493
491
|
// 标准通话模式文字回显结束停止文字加载
|
|
494
492
|
if (textData.moduleType === 'end' && textData.conversationStatus && textData.conversationStatus === 'stop') {
|
|
495
493
|
setIsTextLoading(false);
|
|
496
494
|
}
|
|
497
495
|
// 卡片和问答直接关闭
|
|
498
|
-
if (textData.moduleType === 'skill' || textData.moduleType === 'ask'
|
|
496
|
+
if (textData.moduleType === 'skill' || textData.moduleType === 'ask') {
|
|
499
497
|
// 关闭loading
|
|
500
498
|
setIsTextLoading(false);
|
|
501
499
|
}
|
|
502
|
-
if (textData.answerType === 1 || textData.moduleType === 'skill'
|
|
500
|
+
if (textData.answerType === 1 || textData.moduleType === 'skill') {
|
|
503
501
|
var _clientRef$current2, _clientRef$current2$m;
|
|
504
502
|
// 静音点击置灰
|
|
505
503
|
setIsDisable(true);
|
|
@@ -9,8 +9,7 @@ interface AnswerItemProps {
|
|
|
9
9
|
showOpera?: (id: number) => boolean;
|
|
10
10
|
handleShowCourse: (v: any) => void;
|
|
11
11
|
handleClickPromptWord?: (prompt: string) => void;
|
|
12
|
-
handleClickAskList: (item: any, operation: string, key: string, value?: string
|
|
13
|
-
handleClickConfirm: (item: any, confirmed: boolean) => void;
|
|
12
|
+
handleClickAskList: (item: any, operation: string, key: string, value?: string) => void;
|
|
14
13
|
playTTSByText: (text: string) => void;
|
|
15
14
|
stopTTSByText: () => void;
|
|
16
15
|
isVoicePlaying: boolean;
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
|
|
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';
|
|
1
|
+
import React from 'react';
|
|
21
2
|
import { useTranslation } from 'react-i18next';
|
|
22
3
|
import styles from "./index.module.css";
|
|
23
4
|
import classNames from 'classnames';
|
|
24
5
|
import ReasoningContent from "../reasoning-content/index";
|
|
25
|
-
import { processString
|
|
6
|
+
import { processString } from "../../utils/tools";
|
|
26
7
|
import { MMarkdown } from '@myun/gimi-design';
|
|
27
8
|
import AskCard from "../ask-card";
|
|
28
9
|
import WorkFlowContent from "../work-flow-content";
|
|
@@ -32,20 +13,14 @@ import ExcelCard from "../excel-components/ExcelCard";
|
|
|
32
13
|
import WordCard from "../custom-render/WordCard";
|
|
33
14
|
import { IconTickCircle } from '@douyinfe/semi-icons';
|
|
34
15
|
import VoicePlay from "../message-actions/VoicePlay";
|
|
35
|
-
import {
|
|
16
|
+
import { useAppSelector } from "../../store/hooks";
|
|
36
17
|
import CopyButton from "../message-actions/CopyButton";
|
|
37
18
|
import LikeButton from "../message-actions/LikeButton";
|
|
38
19
|
import UnLikeButton from "../message-actions/UnLikeButton";
|
|
39
20
|
import RegenerateButton from "../message-actions/RegenerateButton";
|
|
40
21
|
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";
|
|
47
22
|
var AnswerItem = function AnswerItem(_ref) {
|
|
48
|
-
var
|
|
23
|
+
var _agentDetail$voiceCon;
|
|
49
24
|
var item = _ref.item,
|
|
50
25
|
onSucess = _ref.onSucess,
|
|
51
26
|
onFailure = _ref.onFailure,
|
|
@@ -55,7 +30,6 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
55
30
|
handleShowCourse = _ref.handleShowCourse,
|
|
56
31
|
handleClickPromptWord = _ref.handleClickPromptWord,
|
|
57
32
|
handleClickAskList = _ref.handleClickAskList,
|
|
58
|
-
handleClickConfirm = _ref.handleClickConfirm,
|
|
59
33
|
playTTSByText = _ref.playTTSByText,
|
|
60
34
|
stopTTSByText = _ref.stopTTSByText,
|
|
61
35
|
isVoicePlaying = _ref.isVoicePlaying,
|
|
@@ -78,19 +52,8 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
78
52
|
model = _ref.model,
|
|
79
53
|
onCurrentTraceVideoClick = _ref.onCurrentTraceVideoClick,
|
|
80
54
|
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];
|
|
89
55
|
var _useTranslation = useTranslation(),
|
|
90
56
|
t = _useTranslation.t;
|
|
91
|
-
var _useContext = useContext(ChatContext),
|
|
92
|
-
apiService = _useContext.apiService;
|
|
93
|
-
var dispatch = useAppDispatch();
|
|
94
57
|
var isMsgRecieving = useAppSelector(function (state) {
|
|
95
58
|
return state.gimiMenu.isMsgRecieving;
|
|
96
59
|
});
|
|
@@ -102,12 +65,6 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
102
65
|
var platform = useAppSelector(function (state) {
|
|
103
66
|
return state.gimiMenu.platform;
|
|
104
67
|
});
|
|
105
|
-
var messageList = useAppSelector(function (state) {
|
|
106
|
-
return state.gimiMenu.messageList;
|
|
107
|
-
});
|
|
108
|
-
var conversationId = useAppSelector(function (state) {
|
|
109
|
-
return state.gimiMenu.conversationId || '';
|
|
110
|
-
});
|
|
111
68
|
var handleLinkClickCapture = React.useCallback(function (e) {
|
|
112
69
|
if (platform !== 'preview') return;
|
|
113
70
|
var target = e.target;
|
|
@@ -144,8 +101,6 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
144
101
|
var agentDetail = useAppSelector(function (state) {
|
|
145
102
|
return state.gimiMenu.agentObj || {};
|
|
146
103
|
});
|
|
147
|
-
var agentDetailRef = useRef(agentDetail);
|
|
148
|
-
agentDetailRef.current = agentDetail;
|
|
149
104
|
var customRender = React.useMemo(function () {
|
|
150
105
|
return [{
|
|
151
106
|
type: 'excel',
|
|
@@ -201,109 +156,6 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
201
156
|
// }
|
|
202
157
|
];
|
|
203
158
|
}, [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]);
|
|
307
159
|
return /*#__PURE__*/React.createElement("div", {
|
|
308
160
|
className: styles.title,
|
|
309
161
|
onClickCapture: handleLinkClickCapture
|
|
@@ -311,29 +163,10 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
311
163
|
className: classNames(styles.answer)
|
|
312
164
|
}, item.mcp && /*#__PURE__*/React.createElement(WorkFlowContent, {
|
|
313
165
|
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
|
|
333
166
|
}), item.vipLevel === 1 && item.reasoningContent && /*#__PURE__*/React.createElement(ReasoningContent, {
|
|
334
167
|
reasoningTitle: reasoningTitle,
|
|
335
168
|
item: item
|
|
336
|
-
})
|
|
169
|
+
}), showTaskSuccess && /*#__PURE__*/React.createElement("div", {
|
|
337
170
|
className: styles.completed
|
|
338
171
|
}, /*#__PURE__*/React.createElement(IconTickCircle, {
|
|
339
172
|
className: styles.checkIcon
|
|
@@ -355,11 +188,9 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
355
188
|
onFailure: onFailure
|
|
356
189
|
}), item.stop === 1 && /*#__PURE__*/React.createElement("div", {
|
|
357
190
|
className: styles.stop
|
|
358
|
-
}, t('answer.stopped')),
|
|
359
|
-
artifacts: item.artifacts
|
|
360
|
-
}), showOperation && /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
}, t('answer.stopped')), showOperation && /*#__PURE__*/React.createElement("div", {
|
|
361
192
|
className: styles.opera
|
|
362
|
-
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement(
|
|
193
|
+
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement("div", {
|
|
363
194
|
className: styles.opera_item
|
|
364
195
|
}, enableCopy && /*#__PURE__*/React.createElement(CopyButton, {
|
|
365
196
|
item: item,
|
|
@@ -378,9 +209,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
378
209
|
messageId: item.id
|
|
379
210
|
}), showRegerate && enableRegenerate && /*#__PURE__*/React.createElement(RegenerateButton, {
|
|
380
211
|
onRegenerateClick: onRegenerateClick
|
|
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", {
|
|
212
|
+
}))), (item.relatedResourceList || []).length > 0 && (showCommend === null || showCommend === void 0 ? void 0 : showCommend(item.id)) && /*#__PURE__*/React.createElement("div", {
|
|
384
213
|
className: styles.quickInputList
|
|
385
214
|
}, (item.relatedResourceList || []).map(function (item, index) {
|
|
386
215
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
height: 18px;
|
|
97
97
|
margin-top: 12px;
|
|
98
98
|
display: flex;
|
|
99
|
-
align-items: center;
|
|
100
99
|
}
|
|
101
100
|
.opera .opera_item {
|
|
102
101
|
display: flex;
|
|
@@ -109,12 +108,6 @@
|
|
|
109
108
|
cursor: pointer;
|
|
110
109
|
user-select: none;
|
|
111
110
|
}
|
|
112
|
-
.opera .totalTokensWrap {
|
|
113
|
-
color: var(--theme-neutral, #4C5A70);
|
|
114
|
-
font-size: 14px;
|
|
115
|
-
line-height: 12px;
|
|
116
|
-
margin-left: 16px;
|
|
117
|
-
}
|
|
118
111
|
|
|
119
112
|
.operaicon {
|
|
120
113
|
height: 20px;
|
|
@@ -272,37 +265,9 @@
|
|
|
272
265
|
padding: 20px;
|
|
273
266
|
}
|
|
274
267
|
|
|
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
|
-
|
|
292
268
|
:global(.markdown_container) {
|
|
293
269
|
max-width: 800px;
|
|
294
270
|
}
|
|
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
|
-
}
|
|
306
271
|
@media (min-width: 1920px) {
|
|
307
272
|
:global(.markdown_container) {
|
|
308
273
|
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
|
|
6
|
+
handleClickAskList: (item: any, operation: string, key: string, value?: string) => void;
|
|
7
7
|
onAskCardCallback?: () => void;
|
|
8
8
|
}
|
|
9
9
|
declare const AskCard: ({ item, moduleInfo, handleClickAskList, onAskCardCallback }: IProps) => React.JSX.Element;
|