@myun/gimi-chat 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/client/components/history-list/index.js +14 -11
  2. package/dist/client/components/slider/index.js +5 -2
  3. package/dist/client/core/index.js +6 -2
  4. package/dist/components/ai-chat-dialogue/index.js +26 -23
  5. package/dist/components/ai-loading/index.js +4 -1
  6. package/dist/components/answer-item/index.js +7 -4
  7. package/dist/components/ask-card/index.js +5 -2
  8. package/dist/components/ask-card/index.module.css +8 -1
  9. package/dist/components/chat-input/index.js +29 -25
  10. package/dist/components/chat-voice/VoiceCommunication.js +6 -4
  11. package/dist/components/chat-voice/VoiceRecord.js +6 -3
  12. package/dist/components/conversation-delete/index.js +5 -2
  13. package/dist/components/excel-components/ExcelExcuting.js +28 -23
  14. package/dist/components/excel-components/ExcelFailCard.js +4 -1
  15. package/dist/components/excel-components/ExcelSuccessCard.js +8 -5
  16. package/dist/components/excel-components/index.module.css +1 -1
  17. package/dist/components/file-card/fileCardSidebar.js +7 -2
  18. package/dist/components/file-card/index.js +10 -5
  19. package/dist/components/file-card/index.module.css +3 -1
  20. package/dist/components/file-upload/index.js +15 -7
  21. package/dist/components/file-upload/uploadV1.js +15 -8
  22. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +10 -2
  23. package/dist/components/knowledge-trace/classList.js +11 -4
  24. package/dist/components/knowledge-trace/documentList.js +11 -4
  25. package/dist/components/knowledge-trace/index.js +6 -3
  26. package/dist/components/knowledge-trace/index.module.css +6 -3
  27. package/dist/components/knowledge-trace/videoList.js +16 -6
  28. package/dist/components/message-actions/CopyButton.js +4 -1
  29. package/dist/components/message-actions/LikeButton.js +4 -1
  30. package/dist/components/message-actions/RegenerateButton.js +5 -2
  31. package/dist/components/message-actions/UnLikeButton.js +4 -1
  32. package/dist/components/message-actions/VoicePlay.js +6 -2
  33. package/dist/components/no-microphone-root/index.js +9 -7
  34. package/dist/components/no-microphone-root/index.module.css +10 -1
  35. package/dist/components/product-tag/index.js +10 -7
  36. package/dist/components/quoted-content/index.js +17 -12
  37. package/dist/components/reasoning-content/index.js +8 -5
  38. package/dist/components/reasoning-search/index.d.ts +1 -1
  39. package/dist/components/reasoning-search/index.js +15 -6
  40. package/dist/components/reference-content/index.js +10 -3
  41. package/dist/components/search-course-list/index.js +13 -6
  42. package/dist/components/search-course-list/index.module.css +6 -3
  43. package/dist/components/search-course-list/sidebar.js +7 -2
  44. package/dist/components/templates/GimiChatComponent.js +5 -1
  45. package/dist/components/unified-sidebar/FileListContent.js +8 -2
  46. package/dist/components/unified-sidebar/KnowledgeTraceContent.d.ts +1 -0
  47. package/dist/components/unified-sidebar/KnowledgeTraceContent.js +33 -3
  48. package/dist/components/unified-sidebar/SearchCourseListContent.js +8 -4
  49. package/dist/components/unified-sidebar/index.js +14 -8
  50. package/dist/components/upload-list/index.js +6 -3
  51. package/dist/components/voice-recording/index.js +10 -7
  52. package/dist/components/work-flow-content/index.js +7 -1
  53. package/dist/hooks/useChatActions.js +9 -6
  54. package/dist/hooks/useChatHistory.js +4 -1
  55. package/dist/hooks/useChatRecommend.js +7 -4
  56. package/dist/hooks/useChatStream.js +12 -2
  57. package/dist/hooks/useChatVoice.js +12 -6
  58. package/dist/hooks/useCommonChatAPI.js +25 -21
  59. package/dist/hooks/useFile.js +14 -9
  60. package/dist/hooks/useLongPoll.js +5 -2
  61. package/dist/hooks/useSearchCase.js +5 -2
  62. package/dist/i18n/GimiChatI18nProvider.d.ts +9 -0
  63. package/dist/i18n/GimiChatI18nProvider.js +25 -0
  64. package/dist/i18n/core.d.ts +12 -0
  65. package/dist/i18n/core.js +71 -0
  66. package/dist/i18n/index.d.ts +4 -0
  67. package/dist/i18n/index.js +3 -0
  68. package/dist/i18n/locales/en-US.d.ts +216 -0
  69. package/dist/i18n/locales/en-US.js +242 -0
  70. package/dist/i18n/locales/zh-CN.d.ts +216 -0
  71. package/dist/i18n/locales/zh-CN.js +242 -0
  72. package/dist/i18n/useGimiChatTranslation.d.ts +2 -0
  73. package/dist/i18n/useGimiChatTranslation.js +5 -0
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.js +1 -0
  76. package/dist/types/chat.d.ts +4 -1
  77. package/dist/types/modules.d.ts +1 -0
  78. package/dist/umd/index.min.js +1 -1
  79. package/dist/utils/tools.d.ts +1 -1
  80. package/dist/utils/tools.js +5 -5
  81. package/dist/utils/voice-stream.d.ts +2 -0
  82. package/dist/utils/voice-stream.js +43 -20
  83. package/package.json +6 -4
@@ -35,7 +35,7 @@ export declare function replaceBraces(str: string): string;
35
35
  * @returns {string} 格式化后的大小字符串(**KB 或 **MB)
36
36
  */
37
37
  export declare function formatSizeToKB(bytes: number): string;
38
- export declare const fileValidation: (fileList: FileItem[]) => "" | "文件上传失败,请重试" | "文件解析失败,请重试" | "文件正在上传中,请稍后" | "文件正在解析中,请稍后" | "文件正在重试处理中,请稍后";
38
+ export declare const fileValidation: (fileList: FileItem[]) => "" | "fileValidation.uploadFailed" | "fileValidation.parseFailed" | "fileValidation.uploading" | "fileValidation.parsing" | "fileValidation.retrying";
39
39
  /**
40
40
  * 过滤用户输出中与默认模版相同的模板部分
41
41
  * @param {*} prompt 我要生成一个{{模版名称}}....
@@ -320,15 +320,15 @@ export var fileValidation = function fileValidation(fileList) {
320
320
  if ((fileList === null || fileList === void 0 ? void 0 : fileList.length) === 0) return '';
321
321
  switch (fileList[0].status) {
322
322
  case FileStatus.UPLOAD_FAILED:
323
- return '文件上传失败,请重试';
323
+ return 'fileValidation.uploadFailed';
324
324
  case FileStatus.ANALYSE_FAILED:
325
- return '文件解析失败,请重试';
325
+ return 'fileValidation.parseFailed';
326
326
  case FileStatus.UPLOADING:
327
- return '文件正在上传中,请稍后';
327
+ return 'fileValidation.uploading';
328
328
  case FileStatus.PADDING:
329
- return '文件正在解析中,请稍后';
329
+ return 'fileValidation.parsing';
330
330
  case FileStatus.RETRING:
331
- return '文件正在重试处理中,请稍后';
331
+ return 'fileValidation.retrying';
332
332
  default:
333
333
  return '';
334
334
  }
@@ -71,6 +71,8 @@ export interface StartMessageParams {
71
71
  }
72
72
  export declare class VoiceRecorder {
73
73
  private mediaRecorder;
74
+ private t;
75
+ setTranslation(t: any): void;
74
76
  private audioPlayer;
75
77
  private ws;
76
78
  private onMessageCallback;
@@ -47,6 +47,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
47
47
  var _this = this;
48
48
  _classCallCheck(this, VoiceRecorder);
49
49
  _defineProperty(this, "mediaRecorder", null);
50
+ _defineProperty(this, "t", function (key) {
51
+ return key;
52
+ });
50
53
  // 新增:存储 TTS 流式播放器实例
51
54
  _defineProperty(this, "audioPlayer", null);
52
55
  _defineProperty(this, "ws", null);
@@ -125,7 +128,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
125
128
  _context.next = 28;
126
129
  break;
127
130
  }
128
- e = new Error((error === null || error === void 0 ? void 0 : error.message) || '麦克风权限被拒绝');
131
+ e = new Error((error === null || error === void 0 ? void 0 : error.message) || _this.t('voice.error.micPermissionDenied', {
132
+ message: ''
133
+ }));
129
134
  e.code = 'MIC_PERMISSION_DENIED';
130
135
  reject(e);
131
136
  return _context.abrupt("return");
@@ -144,6 +149,11 @@ export var VoiceRecorder = /*#__PURE__*/function () {
144
149
  });
145
150
  }
146
151
  _createClass(VoiceRecorder, [{
152
+ key: "setTranslation",
153
+ value: function setTranslation(t) {
154
+ this.t = t;
155
+ }
156
+ }, {
147
157
  key: "setOnMessageCallback",
148
158
  value: function setOnMessageCallback(cb) {
149
159
  this.onMessageCallback = cb;
@@ -362,7 +372,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
362
372
  };
363
373
  ws.onerror = function () {
364
374
  console.log('❌ WebSocket 连接错误', 'red');
365
- reject(new Error('连接失败'));
375
+ reject(new Error(_this2.t('voice.error.connectFailed')));
366
376
  };
367
377
  ws.onmessage = function (e) {
368
378
  if (typeof e.data === 'string') {
@@ -446,7 +456,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
446
456
  return new Promise(function (resolve, reject) {
447
457
  var ws = _this3.ws;
448
458
  if (!ws) {
449
- var errMsg = '请先建立WebSocket连接';
459
+ var errMsg = _this3.t('voice.error.needWebSocket');
450
460
  // eslint-disable-next-line no-promise-executor-return
451
461
  return reject(new Error(errMsg));
452
462
  }
@@ -469,7 +479,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
469
479
  ws.send(JSON.stringify(msg));
470
480
  resolve();
471
481
  } catch (e) {
472
- var _errMsg = "\u53D1\u9001start\u5931\u8D25: ".concat(e.message);
482
+ var _errMsg = _this3.t('voice.error.sendStartFailed', {
483
+ message: e.message
484
+ });
473
485
  reject(new Error(_errMsg));
474
486
  }
475
487
  });
@@ -526,7 +538,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
526
538
  case 14:
527
539
  _context3.prev = 14;
528
540
  _context3.t0 = _context3["catch"](0);
529
- errMsg = "\u9EA6\u514B\u98CE\u6743\u9650\u88AB\u62D2: ".concat(_context3.t0.message);
541
+ errMsg = _this4.t('voice.error.micPermissionDenied', {
542
+ message: _context3.t0.message
543
+ });
530
544
  reject(new Error(errMsg));
531
545
  case 18:
532
546
  case "end":
@@ -574,7 +588,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
574
588
  _context4.next = 14;
575
589
  break;
576
590
  case 12:
577
- errMsg = '不存在需要停止的录音';
591
+ errMsg = _this5.t('voice.error.noRecordToStop');
578
592
  reject(new Error(errMsg));
579
593
  case 14:
580
594
  _context4.next = 20;
@@ -582,7 +596,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
582
596
  case 16:
583
597
  _context4.prev = 16;
584
598
  _context4.t0 = _context4["catch"](0);
585
- _errMsg2 = "\u505C\u6B62\u5F55\u97F3\u5931\u8D25: ".concat(_context4.t0.message);
599
+ _errMsg2 = _this5.t('voice.error.stopRecordFailed', {
600
+ message: _context4.t0.message
601
+ });
586
602
  reject(new Error(_errMsg2));
587
603
  case 20:
588
604
  case "end":
@@ -612,14 +628,16 @@ export var VoiceRecorder = /*#__PURE__*/function () {
612
628
  return new Promise(function (resolve, reject) {
613
629
  var ws = _this6.ws;
614
630
  // eslint-disable-next-line no-promise-executor-return
615
- if (!ws) return reject(new Error('无有效连接'));
631
+ if (!ws) return reject(new Error(_this6.t('voice.error.noConnection')));
616
632
  try {
617
633
  ws.send(JSON.stringify({
618
634
  type: 'end'
619
635
  }));
620
636
  resolve();
621
637
  } catch (e) {
622
- var errMsg = "\u53D1\u9001end\u5931\u8D25: ".concat(e.message);
638
+ var errMsg = _this6.t('voice.error.sendEndFailed', {
639
+ message: e.message
640
+ });
623
641
  reject(new Error(errMsg));
624
642
  }
625
643
  });
@@ -846,17 +864,18 @@ export var VoiceRecorder = /*#__PURE__*/function () {
846
864
  }, {
847
865
  key: "blobToBase64",
848
866
  value: function blobToBase64(blob) {
867
+ var _this7 = this;
849
868
  return new Promise(function (resolve, reject) {
850
869
  var reader = new FileReader();
851
870
  reader.onload = function () {
852
871
  // 1. 类型守卫:确保 result 是字符串类型
853
872
  if (typeof reader.result !== 'string') {
854
- return reject(new Error('Blob 转换 Base64 失败:结果不是字符串类型'));
873
+ return reject(new Error(_this7.t('voice.error.blobError')));
855
874
  }
856
875
  // 2. 校验 Base64 格式是否正确
857
876
  var base64Parts = reader.result.split(',');
858
877
  if (base64Parts.length < 2) {
859
- return reject(new Error('Blob 转换 Base64 失败:格式异常'));
878
+ return reject(new Error(_this7.t('voice.error.blobFormatError')));
860
879
  }
861
880
  var base64 = base64Parts[1];
862
881
  resolve(base64);
@@ -900,7 +919,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
900
919
  _context9.next = 6;
901
920
  break;
902
921
  }
903
- throw new Error('腾讯云录音未初始化,无法停止');
922
+ throw new Error(this.t('voice.error.initFailed'));
904
923
  case 6:
905
924
  _context9.prev = 6;
906
925
  stream = tencentRecorder.stream, audioContext = tencentRecorder.audioContext, processor = tencentRecorder.processor, source = tencentRecorder.source;
@@ -1047,7 +1066,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
1047
1066
  return _context10.abrupt("return", _result);
1048
1067
  case 22:
1049
1068
  // 处理接口级别的错误
1050
- errorMsg = response_data.message || '请求失败';
1069
+ errorMsg = response_data.message || this.t('voice.error.requestFailed');
1051
1070
  throw new Error(errorMsg);
1052
1071
  case 24:
1053
1072
  _context10.next = 29;
@@ -1060,7 +1079,7 @@ export var VoiceRecorder = /*#__PURE__*/function () {
1060
1079
  case "end":
1061
1080
  return _context10.stop();
1062
1081
  }
1063
- }, _callee10, null, [[10, 26]]);
1082
+ }, _callee10, this, [[10, 26]]);
1064
1083
  }));
1065
1084
  function callTencentAsrApi(_x16) {
1066
1085
  return _callTencentAsrApi.apply(this, arguments);
@@ -1094,7 +1113,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
1094
1113
  case 11:
1095
1114
  _context11.prev = 11;
1096
1115
  _context11.t0 = _context11["catch"](1);
1097
- throw new Error("\u97F3\u9891\u6D41\u9519\u8BEF: ".concat(_context11.t0.message));
1116
+ throw new Error(this.t('voice.error.streamError', {
1117
+ message: _context11.t0.message
1118
+ }));
1098
1119
  case 14:
1099
1120
  case "end":
1100
1121
  return _context11.stop();
@@ -1119,19 +1140,19 @@ export var VoiceRecorder = /*#__PURE__*/function () {
1119
1140
  key: "sendTextForTTS",
1120
1141
  value: function () {
1121
1142
  var _sendTextForTTS = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(text) {
1122
- var _this7 = this;
1143
+ var _this8 = this;
1123
1144
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1124
1145
  while (1) switch (_context12.prev = _context12.next) {
1125
1146
  case 0:
1126
1147
  return _context12.abrupt("return", new Promise(function (resolve, reject) {
1127
- var ws = _this7.ws;
1148
+ var ws = _this8.ws;
1128
1149
  if (!ws || ws.readyState !== WebSocket.OPEN) {
1129
- var errMsg = '请先建立WebSocket连接';
1150
+ var errMsg = _this8.t('voice.error.needWebSocket');
1130
1151
  // eslint-disable-next-line no-promise-executor-return
1131
1152
  return reject(new Error(errMsg));
1132
1153
  }
1133
1154
  if (!text) {
1134
- var _errMsg3 = '请输入合成文本';
1155
+ var _errMsg3 = _this8.t('voice.error.inputEmpty');
1135
1156
  // eslint-disable-next-line no-promise-executor-return
1136
1157
  return reject(new Error(_errMsg3));
1137
1158
  }
@@ -1143,7 +1164,9 @@ export var VoiceRecorder = /*#__PURE__*/function () {
1143
1164
  ws.send(JSON.stringify(msg));
1144
1165
  resolve();
1145
1166
  } catch (e) {
1146
- var _errMsg4 = "\u53D1\u9001\u6587\u672C\u5931\u8D25: ".concat(e.message);
1167
+ var _errMsg4 = _this8.t('voice.error.sendTextFailed', {
1168
+ message: e.message
1169
+ });
1147
1170
  reject(new Error(_errMsg4));
1148
1171
  }
1149
1172
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myun/gimi-chat",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -31,11 +31,13 @@
31
31
  "@volcengine/rtc": "^4.68.0",
32
32
  "classnames": "^2.2.6",
33
33
  "crypto-js": "^4.2.0",
34
- "lodash": "^4.17.21",
34
+ "i18next": "^25.6.3",
35
+ "lodash": "4.17.21",
36
+ "react-i18next": "^16.2.0",
35
37
  "react-redux": "^8.1.3",
38
+ "react-virtuoso": "^4.18.1",
36
39
  "redux": "^5.0.1",
37
- "sass": "^1.69.5",
38
- "react-virtuoso": "^4.18.1"
40
+ "sass": "^1.69.5"
39
41
  },
40
42
  "devDependencies": {
41
43
  "father": "4.1.1",