@myun/gimi-chat 0.9.69 → 0.9.71

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.
@@ -92,6 +92,12 @@ export interface IUseApi {
92
92
  chatId: string;
93
93
  pageSize: number;
94
94
  }) => Promise<FetchResponse<any>>;
95
+ checkFileExist: (fileKey: string) => Promise<FetchResponse<any>>;
96
+ getThinkingEffective: (agentId: number) => Promise<FetchResponse<any>>;
97
+ saveThinkingEnable: (params: {
98
+ agentId: number;
99
+ thinkingEnable: number;
100
+ }) => Promise<FetchResponse<any>>;
95
101
  }
96
102
  declare const useApi: (baseUrl: string, authToken: string, locale?: string) => IUseApi;
97
103
  export default useApi;
@@ -595,6 +595,66 @@ var useApi = function useApi(baseUrl, authToken) {
595
595
  return _ref30.apply(this, arguments);
596
596
  };
597
597
  }();
598
+
599
+ // 校验文件链接是否有效
600
+ var checkFileExist = /*#__PURE__*/function () {
601
+ var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(fileKey) {
602
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
603
+ while (1) switch (_context30.prev = _context30.next) {
604
+ case 0:
605
+ return _context30.abrupt("return", fetchService.post('/mfilesvc/fileExist/checkFile', {
606
+ fileKey: fileKey
607
+ }));
608
+ case 1:
609
+ case "end":
610
+ return _context30.stop();
611
+ }
612
+ }, _callee30);
613
+ }));
614
+ return function checkFileExist(_x29) {
615
+ return _ref31.apply(this, arguments);
616
+ };
617
+ }();
618
+
619
+ // 获取深度思考是否生效
620
+ var getThinkingEffective = /*#__PURE__*/function () {
621
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(agentId) {
622
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
623
+ while (1) switch (_context31.prev = _context31.next) {
624
+ case 0:
625
+ return _context31.abrupt("return", fetchService.get('/mbot/web/agent/thinking/effective', {
626
+ params: {
627
+ agentId: agentId
628
+ }
629
+ }));
630
+ case 1:
631
+ case "end":
632
+ return _context31.stop();
633
+ }
634
+ }, _callee31);
635
+ }));
636
+ return function getThinkingEffective(_x30) {
637
+ return _ref32.apply(this, arguments);
638
+ };
639
+ }();
640
+
641
+ // 保存深度思考开关状态
642
+ var saveThinkingEnable = /*#__PURE__*/function () {
643
+ var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
644
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
645
+ while (1) switch (_context32.prev = _context32.next) {
646
+ case 0:
647
+ return _context32.abrupt("return", fetchService.post('/mbot/web/agent/thinking/save', params));
648
+ case 1:
649
+ case "end":
650
+ return _context32.stop();
651
+ }
652
+ }, _callee32);
653
+ }));
654
+ return function saveThinkingEnable(_x31) {
655
+ return _ref33.apply(this, arguments);
656
+ };
657
+ }();
598
658
  return {
599
659
  getSkillData: getSkillData,
600
660
  getProductList: getProductList,
@@ -625,7 +685,10 @@ var useApi = function useApi(baseUrl, authToken) {
625
685
  getVideoType: getVideoType,
626
686
  getDocumentTrialUrl: getDocumentTrialUrl,
627
687
  getAgentSkillList: getAgentSkillList,
628
- getAgentToolList: getAgentToolList
688
+ getAgentToolList: getAgentToolList,
689
+ checkFileExist: checkFileExist,
690
+ getThinkingEffective: getThinkingEffective,
691
+ saveThinkingEnable: saveThinkingEnable
629
692
  };
630
693
  };
631
694
  export default useApi;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { ToolItem } from "../../../../interfaces/chatMessage";
3
- declare const ToolList: ({ toolList, handleClickConfirm }: {
3
+ declare const ToolList: ({ toolList, handleClickConfirm, customRender }: {
4
4
  toolList: ToolItem[];
5
5
  handleClickConfirm: (item: any, confirmed: boolean) => void;
6
+ customRender: any;
6
7
  }) => React.JSX.Element;
7
8
  export default ToolList;
@@ -14,7 +14,8 @@ import IconFont from "../../../iconfont-com";
14
14
  import styles from "./index.module.css";
15
15
  import classNames from "classnames";
16
16
  var ToolItemCom = function ToolItemCom(_ref) {
17
- var item = _ref.item;
17
+ var item = _ref.item,
18
+ customRender = _ref.customRender;
18
19
  var _useState = useState(false),
19
20
  _useState2 = _slicedToArray(_useState, 2),
20
21
  showContent = _useState2[0],
@@ -58,7 +59,9 @@ var ToolItemCom = function ToolItemCom(_ref) {
58
59
  })), item.content && showContent && /*#__PURE__*/React.createElement("div", {
59
60
  className: styles.toolItemContent
60
61
  }, /*#__PURE__*/React.createElement(MMarkdown, {
61
- content: content
62
+ content: content,
63
+ customRender: customRender,
64
+ showLoading: item.status === "RUNNING"
62
65
  })));
63
66
  };
64
67
  var ConfirmToolItem = function ConfirmToolItem(_ref2) {
@@ -100,7 +103,8 @@ var ConfirmToolItem = function ConfirmToolItem(_ref2) {
100
103
  };
101
104
  var ToolList = function ToolList(_ref3) {
102
105
  var toolList = _ref3.toolList,
103
- handleClickConfirm = _ref3.handleClickConfirm;
106
+ handleClickConfirm = _ref3.handleClickConfirm,
107
+ customRender = _ref3.customRender;
104
108
  return /*#__PURE__*/React.createElement("div", {
105
109
  className: styles.toolList
106
110
  }, toolList.map(function (item) {
@@ -110,7 +114,8 @@ var ToolList = function ToolList(_ref3) {
110
114
  handleClickConfirm: handleClickConfirm
111
115
  }) : /*#__PURE__*/React.createElement(ToolItemCom, {
112
116
  key: item.id,
113
- item: item
117
+ item: item,
118
+ customRender: customRender
114
119
  });
115
120
  }));
116
121
  };
@@ -24,7 +24,6 @@ import classNames from 'classnames';
24
24
  import ReasoningContent from "../reasoning-content/index";
25
25
  import { processString, formatDurationMs } from "../../utils/tools";
26
26
  import { MMarkdown } from '@myun/gimi-design';
27
- import AskCard from "../ask-card";
28
27
  import WorkFlowContent from "../work-flow-content";
29
28
  import ExcelSuccessCard from "../excel-components/ExcelSuccessCard";
30
29
  import KnowledgeIconGroup from "../knowledge-trace/KnowledgeIconComponent";
@@ -309,12 +308,7 @@ var AnswerItem = function AnswerItem(_ref) {
309
308
  onClickCapture: handleLinkClickCapture
310
309
  }, /*#__PURE__*/React.createElement("div", {
311
310
  className: classNames(styles.answer)
312
- }, item.mcp && /*#__PURE__*/React.createElement(WorkFlowContent, {
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", {
311
+ }, /*#__PURE__*/React.createElement("div", {
318
312
  className: styles.thinkingContent
319
313
  }, ((_item$thinkingInfo6 = item.thinkingInfo) === null || _item$thinkingInfo6 === void 0 ? void 0 : _item$thinkingInfo6.status) === "COMPLETED" && /*#__PURE__*/React.createElement("div", {
320
314
  className: styles.thinkingLabel,
@@ -329,11 +323,17 @@ var AnswerItem = function AnswerItem(_ref) {
329
323
  size: 12
330
324
  })), 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
325
  toolList: item.toolList,
332
- handleClickConfirm: handleClickConfirm
326
+ handleClickConfirm: handleClickConfirm,
327
+ customRender: customRender
333
328
  }), item.vipLevel === 1 && item.reasoningContent && /*#__PURE__*/React.createElement(ReasoningContent, {
334
329
  reasoningTitle: reasoningTitle,
335
330
  item: item
336
- }))), showTaskSuccess && /*#__PURE__*/React.createElement("div", {
331
+ }))), item.mcp && /*#__PURE__*/React.createElement(WorkFlowContent, {
332
+ chatItem: item
333
+ }), (agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.agentMode) === 'workflow' && item.vipLevel === 1 && item.reasoningContent && /*#__PURE__*/React.createElement(ReasoningContent, {
334
+ reasoningTitle: reasoningTitle,
335
+ item: item
336
+ }), showTaskSuccess && /*#__PURE__*/React.createElement("div", {
337
337
  className: styles.completed
338
338
  }, /*#__PURE__*/React.createElement(IconTickCircle, {
339
339
  className: styles.checkIcon
@@ -343,10 +343,6 @@ var AnswerItem = function AnswerItem(_ref) {
343
343
  content: processString(item.content || ''),
344
344
  customRender: customRender,
345
345
  showLoading: item.loading
346
- }), showAskTag && /*#__PURE__*/React.createElement(AskCard, {
347
- item: item,
348
- moduleInfo: item.moduleInfo,
349
- handleClickAskList: handleClickAskList
350
346
  }), showSkillTag && /*#__PURE__*/React.createElement(ExcelCard, {
351
347
  onRetry: onRetry,
352
348
  item: item,
@@ -138,6 +138,16 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
138
138
  _React$useState4 = _slicedToArray(_React$useState3, 2),
139
139
  hasContent = _React$useState4[0],
140
140
  setHasContent = _React$useState4[1];
141
+ // thinking: 1 显示深度思考按钮,0 隐藏
142
+ var _React$useState5 = React.useState(false),
143
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
144
+ shouldShowDeepThink = _React$useState6[0],
145
+ setShouldShowDeepThink = _React$useState6[1];
146
+ // thinkingEnable: 1 高亮(已开启),0 默认
147
+ var _React$useState7 = React.useState(false),
148
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
149
+ deepThinkActive = _React$useState8[0],
150
+ setDeepThinkActive = _React$useState8[1];
141
151
  var _useContext = useContext(ChatContext),
142
152
  apiService = _useContext.apiService;
143
153
  var _ref = apiService,
@@ -162,6 +172,34 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
162
172
  }
163
173
  });
164
174
  }, [apiService]);
175
+
176
+ // 获取深度思考配置
177
+ useEffect(function () {
178
+ var agentId = agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId;
179
+ if (props.hiddenDeepThink || !agentId || !(apiService !== null && apiService !== void 0 && apiService.getThinkingEffective)) {
180
+ setShouldShowDeepThink(false);
181
+ setDeepThinkActive(false);
182
+ return;
183
+ }
184
+ var cancelled = false;
185
+ apiService.getThinkingEffective(agentId).then(function (res) {
186
+ if (cancelled) return;
187
+ var result = (res === null || res === void 0 ? void 0 : res.result) || {};
188
+ // thinking: 1 显示按钮,0 隐藏
189
+ setShouldShowDeepThink(result.thinking === 1);
190
+ // thinkingEnable: 1 高亮(已开启),0 默认
191
+ setDeepThinkActive(result.thinkingEnable === 1);
192
+ }).catch(function (e) {
193
+ if (!cancelled) {
194
+ console.error('[deepThink] getThinkingEffective error:', e);
195
+ setShouldShowDeepThink(false);
196
+ setDeepThinkActive(false);
197
+ }
198
+ });
199
+ return function () {
200
+ cancelled = true;
201
+ };
202
+ }, [agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId, apiService]);
165
203
  React.useEffect(function () {
166
204
  if (!props.defaultPrompt) {
167
205
  setHasContent(false);
@@ -623,14 +661,34 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
623
661
  }
624
662
  (_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
625
663
  }, [props, fileList, t]);
664
+
665
+ // 点击切换深度思考开关
666
+ var handleToggleDeepThink = React.useCallback(function () {
667
+ var _agentObjRef$current4;
668
+ var agentId = (_agentObjRef$current4 = agentObjRef.current) === null || _agentObjRef$current4 === void 0 ? void 0 : _agentObjRef$current4.agentId;
669
+ if (!agentId || !(apiService !== null && apiService !== void 0 && apiService.saveThinkingEnable)) return;
670
+ var nextActive = !deepThinkActive;
671
+ var thinkingEnable = nextActive ? 1 : 0;
672
+ // 乐观更新 UI
673
+ setDeepThinkActive(nextActive);
674
+ apiService.saveThinkingEnable({
675
+ agentId: agentId,
676
+ thinkingEnable: thinkingEnable
677
+ }).catch(function (e) {
678
+ // 接口失败回滚
679
+ console.error('[deepThink] saveThinkingEnable error:', e);
680
+ setDeepThinkActive(!nextActive);
681
+ Toast.error(t('action.failed'));
682
+ });
683
+ }, [apiService, deepThinkActive, t]);
626
684
  var renderConfigureArea = React.useCallback(function () {
627
685
  return /*#__PURE__*/React.createElement("div", {
628
686
  className: styles.configureArea
629
- }, UploadFileTool, !props.hiddenDeepThink && /*#__PURE__*/React.createElement(Tooltip, {
630
- trigger: 'click',
687
+ }, UploadFileTool, !props.hiddenDeepThink && shouldShowDeepThink && /*#__PURE__*/React.createElement(Tooltip, {
631
688
  content: t('chatInput.deepThinkTip')
632
689
  }, /*#__PURE__*/React.createElement("div", {
633
- className: styles.deepthink
690
+ className: classNames(styles.deepthink, _defineProperty({}, styles.active, deepThinkActive)),
691
+ onClick: handleToggleDeepThink
634
692
  }, /*#__PURE__*/React.createElement(IconFontCom, {
635
693
  type: "icon-moxing",
636
694
  size: 14
@@ -645,7 +703,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
645
703
  marginLeft: 0
646
704
  }
647
705
  }))), AgentContainer);
648
- }, [UploadFileTool, props.hiddenDeepThink, AgentContainer]);
706
+ }, [UploadFileTool, props.hiddenDeepThink, shouldShowDeepThink, deepThinkActive, handleToggleDeepThink, AgentContainer]);
649
707
  var stopSSe = function stopSSe() {
650
708
  if (uploadFileRef.current) {
651
709
  var _uploadFileRef$curren2;
@@ -27,6 +27,10 @@
27
27
  .deepthink :hover {
28
28
  background-color: var(--theme-subtleNeutral, #F5F7FA);
29
29
  }
30
+ .deepthink.active {
31
+ color: var(--theme-primary, #4086ff);
32
+ background-color: var(--theme-primary-pale, #F0F8FF);
33
+ }
30
34
  .deepthink span {
31
35
  margin-left: 4px;
32
36
  font-family: PingFangSC, PingFang SC;
@@ -72,6 +72,9 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
72
72
  return state.gimiMenu.isMsgRecieving;
73
73
  });
74
74
  var isLastMessage = lastMessageId !== undefined && lastMessageId === messageId;
75
+ var platform = useAppSelector(function (state) {
76
+ return state.gimiMenu.platform;
77
+ });
75
78
  var iconUrl = type === 'video' ? knowledgeConstants.VIDEO_ICON_KNOWLADGE_TRACE_ADDRESS : type === 'document' ? knowledgeConstants.DOCUMENT_ICON_ADDRESS : type === "information" ? knowledgeConstants.INFORMATION_ICON_ADRESS : knowledgeConstants.CLASS_ICON_ADDRESS;
76
79
  var kowledgeTrace = {
77
80
  type: type,
@@ -150,13 +153,12 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
150
153
  }, [isMsgRecieving, isLastMessage, dispatch, messageId, resources, type]);
151
154
  var typeLabel = type === 'video' ? t('knowledgeTrace.type.video') : type === 'product' ? t('knowledgeTrace.type.course') : type === 'information' ? t('knowledgeTrace.type.information') : t('knowledgeTrace.type.document');
152
155
  var unit = type === 'information' ? t('trace.unit.article') : t('trace.unit.piece');
153
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popover, {
156
+ return /*#__PURE__*/React.createElement(React.Fragment, null, platform !== 'qiwei' ? /*#__PURE__*/React.createElement(Popover, {
154
157
  content: /*#__PURE__*/React.createElement(React.Fragment, null, hoverPanelContent),
155
158
  visible: showPanel,
156
159
  onVisibleChange: onVisibleChange,
157
160
  className: "knowledgeHoverPanel",
158
161
  position: "bottomLeft"
159
- // trigger='click'
160
162
  }, /*#__PURE__*/React.createElement("div", {
161
163
  className: styles.icon_btn,
162
164
  onClick: handleIconClick
@@ -166,7 +168,16 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
166
168
  count: resources === null || resources === void 0 ? void 0 : resources.length,
167
169
  unit: unit,
168
170
  type: typeLabel
169
- })))), /*#__PURE__*/React.createElement(TryWatch, {
171
+ })))) : /*#__PURE__*/React.createElement("div", {
172
+ className: styles.icon_btn,
173
+ onClick: handleIconClick
174
+ }, /*#__PURE__*/React.createElement(KnowledgeIcon, {
175
+ url: iconUrl
176
+ }), /*#__PURE__*/React.createElement("span", null, t('trace.countByType', {
177
+ count: resources === null || resources === void 0 ? void 0 : resources.length,
178
+ unit: unit,
179
+ type: typeLabel
180
+ }))), /*#__PURE__*/React.createElement(TryWatch, {
170
181
  item: curTrace,
171
182
  type: type,
172
183
  visible: tryWatchVisible,
@@ -7,13 +7,17 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
7
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
8
  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; }
9
9
  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; }
10
+ 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; }
11
+ 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); } }
12
+ 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); }); }; }
10
13
  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; }
11
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
15
  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); }
13
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
16
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
14
17
  import classNames from 'classnames';
15
18
  import styles from "./index.module.css";
16
- import { Spin } from '@douyinfe/semi-ui';
19
+ import { Spin, Toast } from '@douyinfe/semi-ui';
20
+ import { useTranslation } from 'react-i18next';
17
21
  import { References } from "../reference-content";
18
22
  import { replaceBraces } from "../../utils/tools";
19
23
  import UploadList from "../upload-list";
@@ -26,6 +30,7 @@ import CopyButton from "../message-actions/CopyButton";
26
30
  import { Virtuoso } from 'react-virtuoso';
27
31
  import { MMarkdown } from '@myun/gimi-design';
28
32
  import SkillTag from "./skill-tag";
33
+ import ChatContext from "../templates/chatContext";
29
34
  var MessageItem = /*#__PURE__*/React.memo(function (props) {
30
35
  var _v$quoteTeachModelLis, _v$quoteProductList, _v$messageFilesList;
31
36
  var v = props.v,
@@ -166,6 +171,125 @@ var MessageList = function MessageList(_ref) {
166
171
  var _useGimiFileUpload = useGimiFileUpload(),
167
172
  handleSSEFileAnalyize = _useGimiFileUpload.handleSSEFileAnalyize,
168
173
  fileUpload = _useGimiFileUpload.fileUpload;
174
+ var _useTranslation = useTranslation(),
175
+ t = _useTranslation.t;
176
+ var _useContext = useContext(ChatContext),
177
+ apiService = _useContext.apiService;
178
+
179
+ // 需要校验有效性的文件域名
180
+ var FILE_VALIDATE_DOMAINS = useMemo(function () {
181
+ return ['mstatic.gaodunwangxiao.com', 'gd-mcloud.oss-cn-hangzhou.aliyuncs.com'];
182
+ }, []);
183
+
184
+ // 校验文件链接是否有效,失效返回 false
185
+ var validateFileLink = useCallback( /*#__PURE__*/function () {
186
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
187
+ var _res$result, urlObj, fileKey, res;
188
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
189
+ while (1) switch (_context.prev = _context.next) {
190
+ case 0:
191
+ _context.prev = 0;
192
+ urlObj = new URL(url); // pathname 会把中文百分号编码,后端期望中文原文,需 decode 还原
193
+ fileKey = decodeURIComponent(urlObj.pathname.replace(/^\//, ''));
194
+ if (fileKey) {
195
+ _context.next = 5;
196
+ break;
197
+ }
198
+ return _context.abrupt("return", true);
199
+ case 5:
200
+ _context.next = 7;
201
+ return apiService === null || apiService === void 0 ? void 0 : apiService.checkFileExist(fileKey);
202
+ case 7:
203
+ res = _context.sent;
204
+ return _context.abrupt("return", (res === null || res === void 0 ? void 0 : res.status) === 0 && (res === null || res === void 0 || (_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.fileExist) === 1);
205
+ case 11:
206
+ _context.prev = 11;
207
+ _context.t0 = _context["catch"](0);
208
+ console.error('校验文件链接失败:', _context.t0);
209
+ // 校验接口异常时不阻断,允许访问
210
+ return _context.abrupt("return", true);
211
+ case 15:
212
+ case "end":
213
+ return _context.stop();
214
+ }
215
+ }, _callee, null, [[0, 11]]);
216
+ }));
217
+ return function (_x) {
218
+ return _ref2.apply(this, arguments);
219
+ };
220
+ }(), [apiService]);
221
+
222
+ // 监听 markdown 内 a 标签点击,对指定域名链接做有效性校验
223
+ useEffect(function () {
224
+ var container = containerRef.current;
225
+ if (!container) return;
226
+ var handleClick = /*#__PURE__*/function () {
227
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
228
+ var target, link, href, hostname, needValidate, isValid;
229
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
230
+ while (1) switch (_context2.prev = _context2.next) {
231
+ case 0:
232
+ target = event.target;
233
+ link = target.closest('a');
234
+ if (link) {
235
+ _context2.next = 4;
236
+ break;
237
+ }
238
+ return _context2.abrupt("return");
239
+ case 4:
240
+ href = link.href;
241
+ if (href) {
242
+ _context2.next = 7;
243
+ break;
244
+ }
245
+ return _context2.abrupt("return");
246
+ case 7:
247
+ // 判断是否为需要校验的域名
248
+ hostname = '';
249
+ _context2.prev = 8;
250
+ hostname = new URL(href).hostname;
251
+ _context2.next = 15;
252
+ break;
253
+ case 12:
254
+ _context2.prev = 12;
255
+ _context2.t0 = _context2["catch"](8);
256
+ return _context2.abrupt("return");
257
+ case 15:
258
+ needValidate = FILE_VALIDATE_DOMAINS.some(function (domain) {
259
+ return hostname === domain || hostname.endsWith('.' + domain);
260
+ });
261
+ if (needValidate) {
262
+ _context2.next = 18;
263
+ break;
264
+ }
265
+ return _context2.abrupt("return");
266
+ case 18:
267
+ // 先阻止默认跳转,异步校验通过后再手动打开
268
+ event.preventDefault();
269
+ _context2.next = 21;
270
+ return validateFileLink(href);
271
+ case 21:
272
+ isValid = _context2.sent;
273
+ if (isValid) {
274
+ window.open(href, '_blank', 'noopener,noreferrer');
275
+ } else {
276
+ Toast.warning(t('chatApi.linkUnavailable'));
277
+ }
278
+ case 23:
279
+ case "end":
280
+ return _context2.stop();
281
+ }
282
+ }, _callee2, null, [[8, 12]]);
283
+ }));
284
+ return function handleClick(_x2) {
285
+ return _ref3.apply(this, arguments);
286
+ };
287
+ }();
288
+ container.addEventListener('click', handleClick);
289
+ return function () {
290
+ container.removeEventListener('click', handleClick);
291
+ };
292
+ }, [containerRef, FILE_VALIDATE_DOMAINS, validateFileLink, t]);
169
293
  var handleReTry = React.useCallback(function (file) {
170
294
  if (file.status === FileStatus.ANALYSE_FAILED) {
171
295
  handleSSEFileAnalyize(file);
@@ -17,12 +17,7 @@ import { setIsMsgRecieving } from "../store/slices/gimiMenuSlice";
17
17
  import { getTimeZone } from "../utils/tools";
18
18
 
19
19
  // 需要展示为工具调用的模块类型
20
- export var TOOL_MODULE_TYPES = ['tool_invocation', 'tool_result', "thinking"
21
- // 'start', 'llm', 'knowledge', 'video', 'image-text',
22
- // 'input', 'if-select', 'intent', 'talk', 'text',
23
- // 'video-caption', 'summary', 'loop', 'skillBase',
24
- // 'break', 'http', 'esKnowledge', 'mcp'
25
- ];
20
+ export var TOOL_MODULE_TYPES = ['tool_invocation', 'tool_result', "thinking", 'start', 'llm', 'knowledge', 'video', 'image-text', 'input', 'if-select', 'intent', 'talk', 'text', 'video-caption', 'summary', 'loop', 'skillBase', 'break', 'http', 'esKnowledge', 'mcp'];
26
21
 
27
22
  // 所有需要进入处理流程的模块类型(包括工具类型 + 特殊处理类型)
28
23
  var PROCESSABLE_MODULE_TYPES = [].concat(TOOL_MODULE_TYPES, ['end', 'ask', 'skill', 'tool_call', 'artifact', 'user_confirm', 'COMPLETED']);
@@ -52,25 +47,93 @@ export var MODULE_TYPE_NAMES = {
52
47
  'mcp': 'MCP节点'
53
48
  };
54
49
 
50
+ // 节点状态文案配置(每个节点可自定义各状态文案)
51
+ var NODE_STATUS_TEXTS = {
52
+ 'start': {
53
+ 'STARTED': '开始理解问题',
54
+ 'RUNNING': '正在理解问题',
55
+ 'COMPLETED': '已完成理解问题'
56
+ },
57
+ 'llm': {
58
+ 'STARTED': '开始分析问题',
59
+ 'RUNNING': '正在分析问题',
60
+ 'COMPLETED': '已完成分析'
61
+ },
62
+ 'thinking': {
63
+ 'STARTED': '开始分析问题',
64
+ 'RUNNING': '正在分析问题',
65
+ 'COMPLETED': '已完成分析'
66
+ },
67
+ 'knowledge': {
68
+ 'STARTED': '开始调用知识库检索',
69
+ 'RUNNING': '正在调用知识库检索',
70
+ 'COMPLETED': '已调用知识库检索'
71
+ },
72
+ "esKnowledge": {
73
+ 'STARTED': '开始调用知识库检索',
74
+ 'RUNNING': '正在调用知识库检索',
75
+ 'COMPLETED': '已调用知识库检索'
76
+ },
77
+ "mcp": {
78
+ 'STARTED': '开始调用MCP',
79
+ 'RUNNING': '正在调用MCP',
80
+ 'COMPLETED': '已调用MCP'
81
+ },
82
+ "http": {
83
+ 'STARTED': '开始调用处理数据',
84
+ 'RUNNING': '正在调用处理数据',
85
+ 'COMPLETED': '已调用处理数据'
86
+ },
87
+ "loop": {
88
+ 'STARTED': '开始处理任务',
89
+ 'RUNNING': '正在处理任务',
90
+ 'COMPLETED': '已处理任务'
91
+ },
92
+ "intent": {
93
+ 'STARTED': '开始规划下一步处理方式',
94
+ 'RUNNING': '正在规划下一步处理方式',
95
+ 'COMPLETED': '已规划下一步处理方式'
96
+ },
97
+ "video": {
98
+ 'STARTED': '开始处理任务',
99
+ 'RUNNING': '正在处理任务',
100
+ 'COMPLETED': '已处理任务'
101
+ },
102
+ "talk": {
103
+ 'STARTED': '开始处理任务',
104
+ 'RUNNING': '正在处理任务',
105
+ 'COMPLETED': '已处理任务'
106
+ },
107
+ "image-text": {
108
+ 'STARTED': '开始处理任务',
109
+ 'RUNNING': '正在处理任务',
110
+ 'COMPLETED': '已处理任务'
111
+ },
112
+ "text": {
113
+ 'STARTED': '开始调用写入文件',
114
+ 'RUNNING': '正在调用写入文件',
115
+ 'COMPLETED': '已调用写入文件'
116
+ }
117
+
118
+ // 其他节点可继续添加自定义文案
119
+ };
120
+
55
121
  // 根据 moduleType 和 status 生成 toolName
56
122
  export var getToolNameByStatus = function getToolNameByStatus(moduleType, status) {
57
- // thinking 类型定制文案
58
- if (moduleType === 'thinking') {
59
- if (status === 'STARTED') {
60
- return '开始分析问题';
61
- } else if (status === 'RUNNING') {
62
- return '正在分析问题';
63
- } else if (status === 'COMPLETED') {
64
- return '已完成分析';
65
- }
66
- return '深度思考';
67
- }
68
123
  var baseName = MODULE_TYPE_NAMES[moduleType] || moduleType;
124
+
125
+ // 如果没有状态,返回基础名
69
126
  if (!status) {
70
127
  return baseName;
71
128
  }
72
129
 
73
- // 根据状态生成描述
130
+ // 优先查找节点特定配置
131
+ var nodeTexts = NODE_STATUS_TEXTS[moduleType];
132
+ if (nodeTexts !== null && nodeTexts !== void 0 && nodeTexts[status]) {
133
+ return nodeTexts[status];
134
+ }
135
+
136
+ // 降级到通用模板
74
137
  if (status === 'STARTED') {
75
138
  return "\u5F00\u59CB\u8FD0\u884C".concat(baseName);
76
139
  } else if (status === 'COMPLETED') {
@@ -231,7 +294,6 @@ export var useChatStream = function useChatStream(platform) {
231
294
 
232
295
  // 工具调用
233
296
  if (TOOL_MODULE_TYPES.includes(_dataObj.moduleType) && !["execute", "notifyWorkflowStart"].includes(_dataObj.name)) {
234
- // console.log('dataObj',dataObj);
235
297
  onToolStream === null || onToolStream === void 0 || onToolStream(_dataObj);
236
298
  }
237
299
  // 生成产物
@@ -171,6 +171,7 @@ declare const enUS: {
171
171
  'chatApi.completed': string;
172
172
  'chatApi.organizingAnswer': string;
173
173
  'chatApi.waitingForConfirmation': string;
174
+ 'chatApi.linkUnavailable': string;
174
175
  'messageAction.copy': string;
175
176
  'messageAction.likeDone': string;
176
177
  'messageAction.like': string;