rhua-chatgpt-web 1.0.75 → 1.0.76

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 (46) hide show
  1. package/dist/{api_chain-BixPHn86.cjs → api_chain-Cct--NmS.cjs} +1 -1
  2. package/dist/{api_chain-B3htIXeL.js → api_chain-CdqEyV93.js} +2 -2
  3. package/dist/{combine_docs_chain-DyJhshny.js → combine_docs_chain-DxTWH4t8.js} +2 -2
  4. package/dist/{combine_docs_chain-U5wOiYAn.cjs → combine_docs_chain-DyoMj0h_.cjs} +1 -1
  5. package/dist/{few_shot-pjtgAwqo.cjs → few_shot-BQgZM6p9.cjs} +1 -1
  6. package/dist/{few_shot-4uZaqdPp.js → few_shot-BXjYa1YP.js} +1 -1
  7. package/dist/{index-C6oxpwXc.cjs → index--szDRpgj.cjs} +1 -1
  8. package/dist/{index-DWfOO1dH.js → index-B1Z2Kf_V.js} +1 -1
  9. package/dist/{index-CJjZccPP.js → index-B3g_8T4S.js} +2 -2
  10. package/dist/index-BHClW2mc.js +4 -0
  11. package/dist/{index-BxoVOiWc.cjs → index-BJXSjtzE.cjs} +1 -1
  12. package/dist/{index-CWvbg9Jy.js → index-BOX2c0Zi.js} +1 -1
  13. package/dist/{index-C5AYB5P5.cjs → index-BcBr4F-i.cjs} +1 -1
  14. package/dist/{index-Cp25UTp0.cjs → index-BjAlefwq.cjs} +1 -1
  15. package/dist/{index-BNQoSUuy.cjs → index-BnNS49C7.cjs} +11 -11
  16. package/dist/index-BzfThgvk.js +4 -0
  17. package/dist/{index-DTmlEuiy.js → index-C7gaQVOO.js} +2 -2
  18. package/dist/{index-BEJ74O6p.cjs → index-C7uLtXRs.cjs} +1 -1
  19. package/dist/{index-De0muNHT.js → index-CL5Pjdqd.js} +1 -1
  20. package/dist/{index-BnwTvB_u.cjs → index-CRryl5hc.cjs} +1 -1
  21. package/dist/{index-DIULpQc2.cjs → index-CsYFObD4.cjs} +1 -1
  22. package/dist/{index-BXNajX-T.cjs → index-D8nD5Otb.cjs} +1 -1
  23. package/dist/{index-se7bD8Im.js → index-DC207T_n.js} +760 -281
  24. package/dist/{index-CTwISWUK.js → index-DPa2so8s.js} +1 -1
  25. package/dist/{index-bWxr_czJ.js → index-DS70k1Qn.js} +1 -1
  26. package/dist/{index-D4C7a8oW.cjs → index-DTHrcYSR.cjs} +1 -1
  27. package/dist/{index-D_vQzUdM.cjs → index-DcU5fZTv.cjs} +1 -1
  28. package/dist/index-Df_rTktv.js +4 -0
  29. package/dist/index-DhIN0wum.js +4 -0
  30. package/dist/{index-BrriBP07.cjs → index-fyBmMTPC.cjs} +1 -1
  31. package/dist/index.cjs.js +1 -1
  32. package/dist/{index.es-C1pPA0i2.js → index.es-C959LfHw.js} +1316 -930
  33. package/dist/{index.es-Ut2rJg5g.cjs → index.es-DV6R3duY.cjs} +4 -4
  34. package/dist/index.esm.js +1 -1
  35. package/dist/{llm_chain-CVod3WTv.js → llm_chain-B9EUYWx_.js} +1 -1
  36. package/dist/{llm_chain-DiD-9mu8.cjs → llm_chain-DRq-Ygvd.cjs} +1 -1
  37. package/dist/{sequential_chain-BWkjviYN.cjs → sequential_chain-7kerSIqZ.cjs} +1 -1
  38. package/dist/{sequential_chain-BzVPL3fD.js → sequential_chain-D_5KYvTs.js} +1 -1
  39. package/dist/style.css +1 -1
  40. package/dist/{vector_db_qa-CMop95Y6.js → vector_db_qa-Bz3hlL-C.js} +3 -3
  41. package/dist/{vector_db_qa-CVWk2yCQ.cjs → vector_db_qa-rjR0tJ9Y.cjs} +1 -1
  42. package/package.json +2 -2
  43. package/dist/index-BmStnFbF.js +0 -4
  44. package/dist/index-CIRYHjx7.js +0 -4
  45. package/dist/index-DIkrqrIg.js +0 -4
  46. package/dist/index-b_WNgJEr.js +0 -4
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import React__default, { useState, useRef, useCallback, useEffect, useMemo, createRef, forwardRef, useLayoutEffect, useImperativeHandle } from "react";
5
- import { Button, Input, Select, Checkbox, Tooltip, Toast, Typography, Collapsible, Dropdown, Tag, Avatar, Spin, Layout, Switch, Modal, TextArea, Empty, Form, TagGroup, Divider, Tree } from "@douyinfe/semi-ui";
6
- import { IconChevronDown, IconClose, IconShareStroked, IconPlus, IconSearch, IconEdit2Stroked, IconDeleteStroked, IconCopyStroked, IconDownCircleStroked, IconBulb, IconChevronUp, IconLink, IconTreeTriangleDown, IconImage, IconArrowLeft, IconBolt, IconEditStroked, IconComment, IconDelete, IconFile, IconCloud, IconSend, IconChevronLeft, IconArrowUp, IconRefresh } from "@douyinfe/semi-icons";
5
+ import { Button, Input, Select, Checkbox, Tooltip, Toast, Typography, Collapsible, Dropdown, Tag, Avatar, Spin, Layout, Switch, Modal, TextArea, Empty, Form, TagGroup, Divider, Tree, SideSheet } from "@douyinfe/semi-ui";
6
+ import { IconChevronDown, IconClose, IconShareStroked, IconPlus, IconSearch, IconEdit2Stroked, IconDeleteStroked, IconCopyStroked, IconDownCircleStroked, IconBulb, IconChevronUp, IconLink, IconTreeTriangleDown, IconImage, IconFile, IconArrowLeft, IconBolt, IconEditStroked, IconComment, IconDelete, IconCloud, IconSend, IconChevronLeft, IconArrowUp, IconRefresh, IconHistory } from "@douyinfe/semi-icons";
7
7
  import styled from "styled-components";
8
8
  import { useNavigate, useSearchParams } from "react-router-dom";
9
9
  import localforage from "localforage";
@@ -1276,7 +1276,7 @@ const allAgentList = agentList;
1276
1276
  const getAgentList = async (type = "app") => {
1277
1277
  let preApi = location.hostname === "localhost" ? "http://111.6.44.42:30001" : location.origin;
1278
1278
  let baseApi = `${preApi}/prod-api/system/apps/list?pageNum=1&pageSize=100&type=${type}`;
1279
- let token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImxvZ2luX3VzZXJfa2V5IjoiNjg3MGQ5OWEtODgyYS00OGI5LTllN2YtNjE0YzRlZTA3MjNmIn0.13eL7VgD1rhtqI3zi-AYyvx7_dT1k2FqYW4Zl-jzykbU_2GL7LYS2LGFoqi2RfwbtmRByMMKJ7LMb6MsD6d82Q";
1279
+ let token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0XzIiLCJsb2dpbl91c2VyX2tleSI6IjRlODBmNzExLTVlNWItNDdmZC1iMGE4LTk1ZDhhODUzMzM4ZiJ9.GoWo55WVu6zcC73SIYVtdh9SQnW3FW3Mjz2m-jXZrIG9MEhEAaq72JMrU3jq2zxlc-JaB85V6T6Ss_iAPF2rJw";
1280
1280
  try {
1281
1281
  const cacheData = localStorage.getItem("agentWebCache");
1282
1282
  console.log("cacheData", cacheData);
@@ -42067,7 +42067,7 @@ const MarkdownBox = React__default.memo(({ content: content2, themeMode = "light
42067
42067
  let suggested_questions = [];
42068
42068
  let opening_statement = "我是您的AI助手";
42069
42069
  const messageEqual = (prevProps, currentProps) => {
42070
- return prevProps.message.completed === currentProps.message.completed && prevProps.message.content === currentProps.message.content;
42070
+ return prevProps.message.completed === currentProps.message.completed && prevProps.message.content === currentProps.message.content && JSON.stringify(prevProps.message.references) === JSON.stringify(currentProps.message.references);
42071
42071
  };
42072
42072
  const UserMessageBox = React__default.memo(
42073
42073
  ({
@@ -42354,6 +42354,84 @@ const BotMessageBox = React__default.memo(
42354
42354
  index2
42355
42355
  ))
42356
42356
  }
42357
+ ),
42358
+ message.references && message.references.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(
42359
+ "div",
42360
+ {
42361
+ style: {
42362
+ marginTop: "16px",
42363
+ paddingTop: "16px",
42364
+ borderTop: "1px solid rgba(0, 0, 0, 0.1)"
42365
+ },
42366
+ children: [
42367
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
42368
+ "div",
42369
+ {
42370
+ style: {
42371
+ fontSize: "14px",
42372
+ fontWeight: 600,
42373
+ marginBottom: "8px",
42374
+ color: themeMode === "dark" ? "#fff" : "#333"
42375
+ },
42376
+ children: "引用"
42377
+ }
42378
+ ),
42379
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
42380
+ "div",
42381
+ {
42382
+ style: {
42383
+ display: "flex",
42384
+ flexDirection: "column",
42385
+ gap: "8px"
42386
+ },
42387
+ children: message.references.map((ref, index2) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
42388
+ "div",
42389
+ {
42390
+ style: {
42391
+ display: "flex",
42392
+ alignItems: "center",
42393
+ gap: "8px",
42394
+ padding: "8px",
42395
+ backgroundColor: themeMode === "dark" ? "rgba(255, 255, 255, 0.05)" : "rgba(0, 0, 0, 0.02)",
42396
+ borderRadius: "4px",
42397
+ cursor: ref.url ? "pointer" : "default"
42398
+ },
42399
+ onClick: () => {
42400
+ if (ref.url) {
42401
+ window.open(ref.url, "_blank");
42402
+ }
42403
+ },
42404
+ children: [
42405
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
42406
+ IconFile,
42407
+ {
42408
+ style: {
42409
+ color: themeMode === "dark" ? "rgba(255, 255, 255, 0.7)" : "rgba(0, 0, 0, 0.6)"
42410
+ }
42411
+ }
42412
+ ),
42413
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
42414
+ "span",
42415
+ {
42416
+ style: {
42417
+ fontSize: "14px",
42418
+ color: themeMode === "dark" ? "rgba(255, 255, 255, 0.9)" : "rgba(0, 0, 0, 0.8)",
42419
+ flex: 1,
42420
+ overflow: "hidden",
42421
+ textOverflow: "ellipsis",
42422
+ whiteSpace: "nowrap"
42423
+ },
42424
+ children: ref.name
42425
+ }
42426
+ )
42427
+ ]
42428
+ },
42429
+ index2
42430
+ ))
42431
+ }
42432
+ )
42433
+ ]
42434
+ }
42357
42435
  )
42358
42436
  ] }) }),
42359
42437
  !message.isNewChat && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `csh-${message.id}`, className: "comment-single-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -42960,7 +43038,8 @@ const FileUploadBox = ({
42960
43038
  accept = "*/*",
42961
43039
  multiple = false,
42962
43040
  uploadedFiles: externalUploadedFiles,
42963
- onFileDelete
43041
+ onFileDelete,
43042
+ maxFiles
42964
43043
  }) => {
42965
43044
  const defaultUploadUrl = uploadUrl || `${CommonUtil.getDifyApiBaseUrl()}/v1/files/upload`;
42966
43045
  const { Text } = Typography;
@@ -42987,9 +43066,30 @@ const FileUploadBox = ({
42987
43066
  if (!files || files.length === 0) {
42988
43067
  return;
42989
43068
  }
43069
+ const currentFileCount = uploadedFiles.length;
43070
+ const filesToUpload = Array.from(files);
43071
+ const totalFileCount = currentFileCount + filesToUpload.length;
43072
+ if (maxFiles !== void 0 && totalFileCount > maxFiles) {
43073
+ const allowedCount = maxFiles - currentFileCount;
43074
+ if (allowedCount <= 0) {
43075
+ Toast.error({
43076
+ content: `已达到最大文件数量限制(${maxFiles}个)`,
43077
+ duration: 3
43078
+ });
43079
+ if (fileInputRef.current) {
43080
+ fileInputRef.current.value = "";
43081
+ }
43082
+ return;
43083
+ } else {
43084
+ Toast.warning({
43085
+ content: `最多只能上传${maxFiles}个文件,当前已上传${currentFileCount}个,本次只能上传${allowedCount}个文件`,
43086
+ duration: 3
43087
+ });
43088
+ filesToUpload.splice(allowedCount);
43089
+ }
43090
+ }
42990
43091
  setUploading(true);
42991
43092
  try {
42992
- const filesToUpload = Array.from(files);
42993
43093
  const uploadPromises = filesToUpload.map(async (file) => {
42994
43094
  const formData = new FormData();
42995
43095
  formData.append("file", file);
@@ -43031,8 +43131,10 @@ const FileUploadBox = ({
43031
43131
  return uploadedFile;
43032
43132
  });
43033
43133
  const uploadedFileList = await Promise.all(uploadPromises);
43134
+ const finalFileCount = uploadedFiles.length + uploadedFileList.length;
43135
+ const successMessage = maxFiles !== void 0 && finalFileCount >= maxFiles ? `成功上传 ${uploadedFileList.length} 个文件,已达到最大文件数量限制(${maxFiles}个)` : `成功上传 ${uploadedFileList.length} 个文件`;
43034
43136
  Toast.success({
43035
- content: `成功上传 ${uploadedFileList.length} 个文件`,
43137
+ content: successMessage,
43036
43138
  duration: 2
43037
43139
  });
43038
43140
  } catch (error) {
@@ -43092,19 +43194,28 @@ const FileUploadBox = ({
43092
43194
  }
43093
43195
  )
43094
43196
  ] }, file.id)) }),
43095
- !multiple && uploadedFiles.length === 0 || multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx(
43096
- Button,
43097
- {
43098
- className: "file-upload-button",
43099
- theme: "light",
43100
- type: "tertiary",
43101
- icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloud, {}),
43102
- onClick: handleFileSelect,
43103
- loading: uploading,
43104
- disabled: uploading,
43105
- children: "从本地上传"
43106
- }
43107
- ) : null
43197
+ !multiple && uploadedFiles.length === 0 || multiple ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }, children: [
43198
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43199
+ Button,
43200
+ {
43201
+ className: "file-upload-button",
43202
+ theme: "light",
43203
+ type: "tertiary",
43204
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloud, {}),
43205
+ onClick: handleFileSelect,
43206
+ loading: uploading,
43207
+ disabled: uploading || maxFiles !== void 0 && uploadedFiles.length >= maxFiles,
43208
+ children: "从本地上传"
43209
+ }
43210
+ ),
43211
+ maxFiles !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { style: { fontSize: "12px", color: "var(--semi-color-text-2)" }, children: [
43212
+ "已上传 ",
43213
+ uploadedFiles.length,
43214
+ " / ",
43215
+ maxFiles,
43216
+ " 个文件"
43217
+ ] })
43218
+ ] }) : null
43108
43219
  ] });
43109
43220
  };
43110
43221
  const ForensicForm = ({
@@ -43113,7 +43224,8 @@ const ForensicForm = ({
43113
43224
  uploadUrl,
43114
43225
  apiKey,
43115
43226
  onTextChange,
43116
- getFormData
43227
+ getFormData,
43228
+ maxFiles
43117
43229
  }) => {
43118
43230
  const defaultUploadUrl = uploadUrl || `${CommonUtil.getDifyApiBaseUrl()}/v1/files/upload`;
43119
43231
  const { Text } = Typography;
@@ -43121,18 +43233,18 @@ const ForensicForm = ({
43121
43233
  const medicalInputRef = useRef(null);
43122
43234
  const [appraisalUploading, setAppraisalUploading] = useState(false);
43123
43235
  const [medicalUploading, setMedicalUploading] = useState(false);
43124
- const [appraisalFile, setAppraisalFile] = useState(null);
43125
- const [medicalFile, setMedicalFile] = useState(null);
43236
+ const [appraisalFiles, setAppraisalFiles] = useState([]);
43237
+ const [medicalFiles, setMedicalFiles] = useState([]);
43126
43238
  const [examinationText, setExaminationText] = useState("");
43127
43239
  useEffect(() => {
43128
43240
  if (getFormData) {
43129
43241
  getFormData(() => ({
43130
- confirmation: appraisalFile == null ? void 0 : appraisalFile.id,
43131
- medical_report: medicalFile == null ? void 0 : medicalFile.id,
43242
+ confirmation: appraisalFiles.length > 0 ? appraisalFiles.map((f) => f.id) : void 0,
43243
+ medical_report: medicalFiles.length > 0 ? medicalFiles.map((f) => f.id) : void 0,
43132
43244
  inspection_res: examinationText
43133
43245
  }));
43134
43246
  }
43135
- }, [appraisalFile, medicalFile, examinationText, getFormData]);
43247
+ }, [appraisalFiles, medicalFiles, examinationText, getFormData]);
43136
43248
  const formatFileSize = (bytes) => {
43137
43249
  if (bytes < 1024) return `${bytes.toFixed(2)}B`;
43138
43250
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)}KB`;
@@ -43143,43 +43255,67 @@ const ForensicForm = ({
43143
43255
  const ext = ((_a2 = fileName.split(".").pop()) == null ? void 0 : _a2.toUpperCase()) || "";
43144
43256
  return ext || "FILE";
43145
43257
  };
43146
- const handleFileUpload = async (file, section, setUploading, setFile) => {
43258
+ const handleFileUpload = async (files, section, setUploading, currentFiles, setFiles) => {
43259
+ const currentFileCount = currentFiles.length;
43260
+ const totalFileCount = currentFileCount + files.length;
43261
+ if (maxFiles !== void 0 && totalFileCount > maxFiles) {
43262
+ const allowedCount = maxFiles - currentFileCount;
43263
+ if (allowedCount <= 0) {
43264
+ Toast.error({
43265
+ content: `已达到最大文件数量限制(${maxFiles}个)`,
43266
+ duration: 3
43267
+ });
43268
+ return;
43269
+ } else {
43270
+ Toast.warning({
43271
+ content: `最多只能上传${maxFiles}个文件,当前已上传${currentFileCount}个,本次只能上传${allowedCount}个文件`,
43272
+ duration: 3
43273
+ });
43274
+ files = files.slice(0, allowedCount);
43275
+ }
43276
+ }
43147
43277
  setUploading(true);
43148
43278
  try {
43149
- const formData = new FormData();
43150
- formData.append("file", file);
43151
- const headers = {};
43152
- if (apiKey) {
43153
- headers["Authorization"] = `Bearer ${apiKey}`;
43154
- }
43155
- const response = await fetch(defaultUploadUrl, {
43156
- method: "POST",
43157
- headers,
43158
- body: formData
43159
- });
43160
- if (!response.ok) {
43161
- throw new Error(`上传失败: ${response.statusText}`);
43162
- }
43163
- const result = await response.json();
43164
- console.log("文件上传API返回结果:", result);
43165
- const fileId = result.id || result.upload_file_id || result.file_id || result.fileId || "";
43166
- const fileName = result.name || result.file_name || result.fileName || file.name;
43167
- if (fileId) {
43279
+ const uploadPromises = files.map(async (file) => {
43280
+ const formData = new FormData();
43281
+ formData.append("file", file);
43282
+ const headers = {};
43283
+ if (apiKey) {
43284
+ headers["Authorization"] = `Bearer ${apiKey}`;
43285
+ }
43286
+ const response = await fetch(defaultUploadUrl, {
43287
+ method: "POST",
43288
+ headers,
43289
+ body: formData
43290
+ });
43291
+ if (!response.ok) {
43292
+ throw new Error(`上传失败: ${response.statusText}`);
43293
+ }
43294
+ const result = await response.json();
43295
+ console.log("文件上传API返回结果:", result);
43296
+ const fileId = result.id || result.upload_file_id || result.file_id || result.fileId || "";
43297
+ const fileName = result.name || result.file_name || result.fileName || file.name;
43298
+ if (!fileId) {
43299
+ throw new Error("无法从API响应中提取文件ID");
43300
+ }
43168
43301
  const uploadedFile = {
43169
43302
  id: fileId,
43170
43303
  name: fileName,
43171
43304
  size: formatFileSize(file.size),
43172
43305
  type: getFileType(fileName)
43173
43306
  };
43174
- setFile(uploadedFile);
43175
- Toast.success({
43176
- content: `文件上传成功: ${fileName}`,
43177
- duration: 2
43178
- });
43179
43307
  onUploadSuccess == null ? void 0 : onUploadSuccess(fileId, fileName, section);
43180
- } else {
43181
- throw new Error("无法从API响应中提取文件ID");
43182
- }
43308
+ return uploadedFile;
43309
+ });
43310
+ const uploadedFileList = await Promise.all(uploadPromises);
43311
+ const newFiles = [...currentFiles, ...uploadedFileList];
43312
+ setFiles(newFiles);
43313
+ const finalFileCount = newFiles.length;
43314
+ const successMessage = maxFiles !== void 0 && finalFileCount >= maxFiles ? `成功上传 ${uploadedFileList.length} 个文件,已达到最大文件数量限制(${maxFiles}个)` : `成功上传 ${uploadedFileList.length} 个文件`;
43315
+ Toast.success({
43316
+ content: successMessage,
43317
+ duration: 2
43318
+ });
43183
43319
  } catch (error) {
43184
43320
  const errorMessage = error instanceof Error ? error.message : "上传失败,请重试";
43185
43321
  Toast.error({
@@ -43192,40 +43328,38 @@ const ForensicForm = ({
43192
43328
  }
43193
43329
  };
43194
43330
  const handleAppraisalFileChange = async (event) => {
43195
- var _a2;
43196
- const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
43197
- if (!file) return;
43331
+ const files = event.target.files;
43332
+ if (!files || files.length === 0) return;
43198
43333
  await handleFileUpload(
43199
- file,
43334
+ Array.from(files),
43200
43335
  "confirmation",
43201
- // 使用标准的参数名
43202
43336
  setAppraisalUploading,
43203
- setAppraisalFile
43337
+ appraisalFiles,
43338
+ setAppraisalFiles
43204
43339
  );
43205
43340
  if (appraisalInputRef.current) {
43206
43341
  appraisalInputRef.current.value = "";
43207
43342
  }
43208
43343
  };
43209
43344
  const handleMedicalFileChange = async (event) => {
43210
- var _a2;
43211
- const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
43212
- if (!file) return;
43345
+ const files = event.target.files;
43346
+ if (!files || files.length === 0) return;
43213
43347
  await handleFileUpload(
43214
- file,
43348
+ Array.from(files),
43215
43349
  "medical_report",
43216
- // 使用标准的参数名
43217
43350
  setMedicalUploading,
43218
- setMedicalFile
43351
+ medicalFiles,
43352
+ setMedicalFiles
43219
43353
  );
43220
43354
  if (medicalInputRef.current) {
43221
43355
  medicalInputRef.current.value = "";
43222
43356
  }
43223
43357
  };
43224
- const handleDeleteFile = (section) => {
43358
+ const handleDeleteFile = (fileId, section) => {
43225
43359
  if (section === "confirmation") {
43226
- setAppraisalFile(null);
43360
+ setAppraisalFiles((prev) => prev.filter((f) => f.id !== fileId));
43227
43361
  } else if (section === "medical_report") {
43228
- setMedicalFile(null);
43362
+ setMedicalFiles((prev) => prev.filter((f) => f.id !== fileId));
43229
43363
  }
43230
43364
  };
43231
43365
  const handleTextChange = (value) => {
@@ -43235,17 +43369,41 @@ const ForensicForm = ({
43235
43369
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-form", children: [
43236
43370
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-form-section", children: [
43237
43371
  /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-section-title", children: "鉴定事项确认书" }),
43238
- !appraisalFile ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
43372
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43373
+ "input",
43374
+ {
43375
+ ref: appraisalInputRef,
43376
+ type: "file",
43377
+ style: { display: "none" },
43378
+ onChange: handleAppraisalFileChange,
43379
+ accept: "*/*",
43380
+ multiple: true
43381
+ }
43382
+ ),
43383
+ appraisalFiles.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "forensic-file-list", children: appraisalFiles.map((file) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-display", children: [
43384
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-info", children: [
43385
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "forensic-file-icon" }),
43386
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-details", children: [
43387
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-file-name", children: file.name }),
43388
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "forensic-file-meta", children: [
43389
+ file.type,
43390
+ " · ",
43391
+ file.size
43392
+ ] })
43393
+ ] })
43394
+ ] }),
43239
43395
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43240
- "input",
43396
+ Button,
43241
43397
  {
43242
- ref: appraisalInputRef,
43243
- type: "file",
43244
- style: { display: "none" },
43245
- onChange: handleAppraisalFileChange,
43246
- accept: "*/*"
43398
+ theme: "borderless",
43399
+ type: "tertiary",
43400
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43401
+ onClick: () => handleDeleteFile(file.id, "confirmation"),
43402
+ className: "forensic-delete-button"
43247
43403
  }
43248
- ),
43404
+ )
43405
+ ] }, file.id)) }),
43406
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }, children: [
43249
43407
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43250
43408
  Button,
43251
43409
  {
@@ -43258,19 +43416,41 @@ const ForensicForm = ({
43258
43416
  return (_a2 = appraisalInputRef.current) == null ? void 0 : _a2.click();
43259
43417
  },
43260
43418
  loading: appraisalUploading,
43261
- disabled: appraisalUploading,
43419
+ disabled: appraisalUploading || maxFiles !== void 0 && appraisalFiles.length >= maxFiles,
43262
43420
  children: "从本地上传"
43263
43421
  }
43264
- )
43265
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-display", children: [
43422
+ ),
43423
+ maxFiles !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { style: { fontSize: "12px", color: "var(--semi-color-text-2)" }, children: [
43424
+ "已上传 ",
43425
+ appraisalFiles.length,
43426
+ " / ",
43427
+ maxFiles,
43428
+ " 个文件"
43429
+ ] })
43430
+ ] })
43431
+ ] }),
43432
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-form-section", children: [
43433
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-section-title", children: "医疗检验报告" }),
43434
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43435
+ "input",
43436
+ {
43437
+ ref: medicalInputRef,
43438
+ type: "file",
43439
+ style: { display: "none" },
43440
+ onChange: handleMedicalFileChange,
43441
+ accept: "*/*",
43442
+ multiple: true
43443
+ }
43444
+ ),
43445
+ medicalFiles.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "forensic-file-list", children: medicalFiles.map((file) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-display", children: [
43266
43446
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-info", children: [
43267
43447
  /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "forensic-file-icon" }),
43268
43448
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-details", children: [
43269
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-file-name", children: appraisalFile.name }),
43449
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-file-name", children: file.name }),
43270
43450
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "forensic-file-meta", children: [
43271
- appraisalFile.type,
43451
+ file.type,
43272
43452
  " · ",
43273
- appraisalFile.size
43453
+ file.size
43274
43454
  ] })
43275
43455
  ] })
43276
43456
  ] }),
@@ -43280,25 +43460,12 @@ const ForensicForm = ({
43280
43460
  theme: "borderless",
43281
43461
  type: "tertiary",
43282
43462
  icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43283
- onClick: () => handleDeleteFile("confirmation"),
43463
+ onClick: () => handleDeleteFile(file.id, "medical_report"),
43284
43464
  className: "forensic-delete-button"
43285
43465
  }
43286
43466
  )
43287
- ] })
43288
- ] }),
43289
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-form-section", children: [
43290
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-section-title", children: "医疗检验报告" }),
43291
- !medicalFile ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
43292
- /* @__PURE__ */ jsxRuntimeExports.jsx(
43293
- "input",
43294
- {
43295
- ref: medicalInputRef,
43296
- type: "file",
43297
- style: { display: "none" },
43298
- onChange: handleMedicalFileChange,
43299
- accept: "*/*"
43300
- }
43301
- ),
43467
+ ] }, file.id)) }),
43468
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }, children: [
43302
43469
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43303
43470
  Button,
43304
43471
  {
@@ -43311,32 +43478,17 @@ const ForensicForm = ({
43311
43478
  return (_a2 = medicalInputRef.current) == null ? void 0 : _a2.click();
43312
43479
  },
43313
43480
  loading: medicalUploading,
43314
- disabled: medicalUploading,
43481
+ disabled: medicalUploading || maxFiles !== void 0 && medicalFiles.length >= maxFiles,
43315
43482
  children: "从本地上传"
43316
43483
  }
43317
- )
43318
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-display", children: [
43319
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-info", children: [
43320
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "forensic-file-icon" }),
43321
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-file-details", children: [
43322
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "forensic-file-name", children: medicalFile.name }),
43323
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "forensic-file-meta", children: [
43324
- medicalFile.type,
43325
- " · ",
43326
- medicalFile.size
43327
- ] })
43328
- ] })
43329
- ] }),
43330
- /* @__PURE__ */ jsxRuntimeExports.jsx(
43331
- Button,
43332
- {
43333
- theme: "borderless",
43334
- type: "tertiary",
43335
- icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43336
- onClick: () => handleDeleteFile("medical_report"),
43337
- className: "forensic-delete-button"
43338
- }
43339
- )
43484
+ ),
43485
+ maxFiles !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { style: { fontSize: "12px", color: "var(--semi-color-text-2)" }, children: [
43486
+ "已上传 ",
43487
+ medicalFiles.length,
43488
+ " / ",
43489
+ maxFiles,
43490
+ " 个文件"
43491
+ ] })
43340
43492
  ] })
43341
43493
  ] }),
43342
43494
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "forensic-form-section", children: [
@@ -43360,7 +43512,8 @@ const AutopsyForm = ({
43360
43512
  uploadUrl,
43361
43513
  apiKey,
43362
43514
  getFormData,
43363
- initialData
43515
+ initialData,
43516
+ maxFiles
43364
43517
  }) => {
43365
43518
  const defaultUploadUrl = uploadUrl || `${CommonUtil.getDifyApiBaseUrl()}/v1/files/upload`;
43366
43519
  const { Text } = Typography;
@@ -43368,16 +43521,16 @@ const AutopsyForm = ({
43368
43521
  const medicalInputRef = useRef(null);
43369
43522
  const [confirmationUploading, setConfirmationUploading] = useState(false);
43370
43523
  const [medicalUploading, setMedicalUploading] = useState(false);
43371
- const [confirmationFile, setConfirmationFile] = useState(null);
43372
- const [medicalFile, setMedicalFile] = useState(null);
43524
+ const [confirmationFiles, setConfirmationFiles] = useState([]);
43525
+ const [medicalFiles, setMedicalFiles] = useState([]);
43373
43526
  useEffect(() => {
43374
43527
  if (getFormData) {
43375
43528
  getFormData(() => ({
43376
- confirmation: confirmationFile == null ? void 0 : confirmationFile.id,
43377
- medical_report: medicalFile == null ? void 0 : medicalFile.id
43529
+ confirmation: confirmationFiles.length > 0 ? confirmationFiles.map((f) => f.id) : void 0,
43530
+ medical_report: medicalFiles.length > 0 ? medicalFiles.map((f) => f.id) : void 0
43378
43531
  }));
43379
43532
  }
43380
- }, [confirmationFile, medicalFile, getFormData]);
43533
+ }, [confirmationFiles, medicalFiles, getFormData]);
43381
43534
  const formatFileSize = (bytes) => {
43382
43535
  if (bytes < 1024) return `${bytes.toFixed(2)}B`;
43383
43536
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)}KB`;
@@ -43388,43 +43541,67 @@ const AutopsyForm = ({
43388
43541
  const ext = ((_a2 = fileName.split(".").pop()) == null ? void 0 : _a2.toUpperCase()) || "";
43389
43542
  return ext || "FILE";
43390
43543
  };
43391
- const handleFileUpload = async (file, section, setUploading, setFile) => {
43544
+ const handleFileUpload = async (files, section, setUploading, currentFiles, setFiles) => {
43545
+ const currentFileCount = currentFiles.length;
43546
+ const totalFileCount = currentFileCount + files.length;
43547
+ if (maxFiles !== void 0 && totalFileCount > maxFiles) {
43548
+ const allowedCount = maxFiles - currentFileCount;
43549
+ if (allowedCount <= 0) {
43550
+ Toast.error({
43551
+ content: `已达到最大文件数量限制(${maxFiles}个)`,
43552
+ duration: 3
43553
+ });
43554
+ return;
43555
+ } else {
43556
+ Toast.warning({
43557
+ content: `最多只能上传${maxFiles}个文件,当前已上传${currentFileCount}个,本次只能上传${allowedCount}个文件`,
43558
+ duration: 3
43559
+ });
43560
+ files = files.slice(0, allowedCount);
43561
+ }
43562
+ }
43392
43563
  setUploading(true);
43393
43564
  try {
43394
- const formData = new FormData();
43395
- formData.append("file", file);
43396
- const headers = {};
43397
- if (apiKey) {
43398
- headers["Authorization"] = `Bearer ${apiKey}`;
43399
- }
43400
- const response = await fetch(defaultUploadUrl, {
43401
- method: "POST",
43402
- headers,
43403
- body: formData
43404
- });
43405
- if (!response.ok) {
43406
- throw new Error(`上传失败: ${response.statusText}`);
43407
- }
43408
- const result = await response.json();
43409
- console.log("文件上传API返回结果:", result);
43410
- const fileId = result.id || result.upload_file_id || result.file_id || result.fileId || "";
43411
- const fileName = result.name || result.file_name || result.fileName || file.name;
43412
- if (fileId) {
43565
+ const uploadPromises = files.map(async (file) => {
43566
+ const formData = new FormData();
43567
+ formData.append("file", file);
43568
+ const headers = {};
43569
+ if (apiKey) {
43570
+ headers["Authorization"] = `Bearer ${apiKey}`;
43571
+ }
43572
+ const response = await fetch(defaultUploadUrl, {
43573
+ method: "POST",
43574
+ headers,
43575
+ body: formData
43576
+ });
43577
+ if (!response.ok) {
43578
+ throw new Error(`上传失败: ${response.statusText}`);
43579
+ }
43580
+ const result = await response.json();
43581
+ console.log("文件上传API返回结果:", result);
43582
+ const fileId = result.id || result.upload_file_id || result.file_id || result.fileId || "";
43583
+ const fileName = result.name || result.file_name || result.fileName || file.name;
43584
+ if (!fileId) {
43585
+ throw new Error("无法从API响应中提取文件ID");
43586
+ }
43413
43587
  const uploadedFile = {
43414
43588
  id: fileId,
43415
43589
  name: fileName,
43416
43590
  size: formatFileSize(file.size),
43417
43591
  type: getFileType(fileName)
43418
43592
  };
43419
- setFile(uploadedFile);
43420
- Toast.success({
43421
- content: `文件上传成功: ${fileName}`,
43422
- duration: 2
43423
- });
43424
43593
  onUploadSuccess == null ? void 0 : onUploadSuccess(fileId, fileName, section);
43425
- } else {
43426
- throw new Error("无法从API响应中提取文件ID");
43427
- }
43594
+ return uploadedFile;
43595
+ });
43596
+ const uploadedFileList = await Promise.all(uploadPromises);
43597
+ const newFiles = [...currentFiles, ...uploadedFileList];
43598
+ setFiles(newFiles);
43599
+ const finalFileCount = newFiles.length;
43600
+ const successMessage = maxFiles !== void 0 && finalFileCount >= maxFiles ? `成功上传 ${uploadedFileList.length} 个文件,已达到最大文件数量限制(${maxFiles}个)` : `成功上传 ${uploadedFileList.length} 个文件`;
43601
+ Toast.success({
43602
+ content: successMessage,
43603
+ duration: 2
43604
+ });
43428
43605
  } catch (error) {
43429
43606
  const errorMessage = error instanceof Error ? error.message : "上传失败,请重试";
43430
43607
  Toast.error({
@@ -43437,54 +43614,78 @@ const AutopsyForm = ({
43437
43614
  }
43438
43615
  };
43439
43616
  const handleConfirmationFileChange = async (event) => {
43440
- var _a2;
43441
- const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
43442
- if (!file) return;
43617
+ const files = event.target.files;
43618
+ if (!files || files.length === 0) return;
43443
43619
  await handleFileUpload(
43444
- file,
43620
+ Array.from(files),
43445
43621
  "confirmation",
43446
43622
  setConfirmationUploading,
43447
- setConfirmationFile
43623
+ confirmationFiles,
43624
+ setConfirmationFiles
43448
43625
  );
43449
43626
  if (confirmationInputRef.current) {
43450
43627
  confirmationInputRef.current.value = "";
43451
43628
  }
43452
43629
  };
43453
43630
  const handleMedicalFileChange = async (event) => {
43454
- var _a2;
43455
- const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
43456
- if (!file) return;
43631
+ const files = event.target.files;
43632
+ if (!files || files.length === 0) return;
43457
43633
  await handleFileUpload(
43458
- file,
43634
+ Array.from(files),
43459
43635
  "medical_report",
43460
43636
  setMedicalUploading,
43461
- setMedicalFile
43637
+ medicalFiles,
43638
+ setMedicalFiles
43462
43639
  );
43463
43640
  if (medicalInputRef.current) {
43464
43641
  medicalInputRef.current.value = "";
43465
43642
  }
43466
43643
  };
43467
- const handleDeleteFile = (section) => {
43644
+ const handleDeleteFile = (fileId, section) => {
43468
43645
  if (section === "confirmation") {
43469
- setConfirmationFile(null);
43646
+ setConfirmationFiles((prev) => prev.filter((f) => f.id !== fileId));
43470
43647
  } else if (section === "medical_report") {
43471
- setMedicalFile(null);
43648
+ setMedicalFiles((prev) => prev.filter((f) => f.id !== fileId));
43472
43649
  }
43473
43650
  };
43474
43651
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-form", children: [
43475
43652
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-form-section", children: [
43476
43653
  /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-section-title", children: "鉴定事项确认书" }),
43477
- !confirmationFile ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
43654
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43655
+ "input",
43656
+ {
43657
+ ref: confirmationInputRef,
43658
+ type: "file",
43659
+ style: { display: "none" },
43660
+ onChange: handleConfirmationFileChange,
43661
+ accept: "*/*",
43662
+ multiple: true
43663
+ }
43664
+ ),
43665
+ confirmationFiles.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "autopsy-file-list", children: confirmationFiles.map((file) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-display", children: [
43666
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-info", children: [
43667
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "autopsy-file-icon" }),
43668
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-details", children: [
43669
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-file-name", children: file.name }),
43670
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "autopsy-file-meta", children: [
43671
+ file.type,
43672
+ " · ",
43673
+ file.size
43674
+ ] })
43675
+ ] })
43676
+ ] }),
43478
43677
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43479
- "input",
43678
+ Button,
43480
43679
  {
43481
- ref: confirmationInputRef,
43482
- type: "file",
43483
- style: { display: "none" },
43484
- onChange: handleConfirmationFileChange,
43485
- accept: "*/*"
43680
+ theme: "borderless",
43681
+ type: "tertiary",
43682
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43683
+ onClick: () => handleDeleteFile(file.id, "confirmation"),
43684
+ className: "autopsy-delete-button"
43486
43685
  }
43487
- ),
43686
+ )
43687
+ ] }, file.id)) }),
43688
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }, children: [
43488
43689
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43489
43690
  Button,
43490
43691
  {
@@ -43497,19 +43698,41 @@ const AutopsyForm = ({
43497
43698
  return (_a2 = confirmationInputRef.current) == null ? void 0 : _a2.click();
43498
43699
  },
43499
43700
  loading: confirmationUploading,
43500
- disabled: confirmationUploading,
43701
+ disabled: confirmationUploading || maxFiles !== void 0 && confirmationFiles.length >= maxFiles,
43501
43702
  children: "从本地上传"
43502
43703
  }
43503
- )
43504
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-display", children: [
43704
+ ),
43705
+ maxFiles !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { style: { fontSize: "12px", color: "var(--semi-color-text-2)" }, children: [
43706
+ "已上传 ",
43707
+ confirmationFiles.length,
43708
+ " / ",
43709
+ maxFiles,
43710
+ " 个文件"
43711
+ ] })
43712
+ ] })
43713
+ ] }),
43714
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-form-section", children: [
43715
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-section-title", children: "医疗检验报告(含检验报告、病历,只限于文字内容,至少上传一个文件)" }),
43716
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43717
+ "input",
43718
+ {
43719
+ ref: medicalInputRef,
43720
+ type: "file",
43721
+ style: { display: "none" },
43722
+ onChange: handleMedicalFileChange,
43723
+ accept: "*/*",
43724
+ multiple: true
43725
+ }
43726
+ ),
43727
+ medicalFiles.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "autopsy-file-list", children: medicalFiles.map((file) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-display", children: [
43505
43728
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-info", children: [
43506
43729
  /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "autopsy-file-icon" }),
43507
43730
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-details", children: [
43508
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-file-name", children: confirmationFile.name }),
43731
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-file-name", children: file.name }),
43509
43732
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "autopsy-file-meta", children: [
43510
- confirmationFile.type,
43733
+ file.type,
43511
43734
  " · ",
43512
- confirmationFile.size
43735
+ file.size
43513
43736
  ] })
43514
43737
  ] })
43515
43738
  ] }),
@@ -43519,25 +43742,12 @@ const AutopsyForm = ({
43519
43742
  theme: "borderless",
43520
43743
  type: "tertiary",
43521
43744
  icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43522
- onClick: () => handleDeleteFile("confirmation"),
43745
+ onClick: () => handleDeleteFile(file.id, "medical_report"),
43523
43746
  className: "autopsy-delete-button"
43524
43747
  }
43525
43748
  )
43526
- ] })
43527
- ] }),
43528
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-form-section", children: [
43529
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-section-title", children: "医疗检验报告(含检验报告、病历,只限于文字内容,至少上传一个文件)" }),
43530
- !medicalFile ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
43531
- /* @__PURE__ */ jsxRuntimeExports.jsx(
43532
- "input",
43533
- {
43534
- ref: medicalInputRef,
43535
- type: "file",
43536
- style: { display: "none" },
43537
- onChange: handleMedicalFileChange,
43538
- accept: "*/*"
43539
- }
43540
- ),
43749
+ ] }, file.id)) }),
43750
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }, children: [
43541
43751
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43542
43752
  Button,
43543
43753
  {
@@ -43550,32 +43760,17 @@ const AutopsyForm = ({
43550
43760
  return (_a2 = medicalInputRef.current) == null ? void 0 : _a2.click();
43551
43761
  },
43552
43762
  loading: medicalUploading,
43553
- disabled: medicalUploading,
43763
+ disabled: medicalUploading || maxFiles !== void 0 && medicalFiles.length >= maxFiles,
43554
43764
  children: "从本地上传"
43555
43765
  }
43556
- )
43557
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-display", children: [
43558
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-info", children: [
43559
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "autopsy-file-icon" }),
43560
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "autopsy-file-details", children: [
43561
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: "autopsy-file-name", children: medicalFile.name }),
43562
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: "autopsy-file-meta", children: [
43563
- medicalFile.type,
43564
- " · ",
43565
- medicalFile.size
43566
- ] })
43567
- ] })
43568
- ] }),
43569
- /* @__PURE__ */ jsxRuntimeExports.jsx(
43570
- Button,
43571
- {
43572
- theme: "borderless",
43573
- type: "tertiary",
43574
- icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDelete, {}),
43575
- onClick: () => handleDeleteFile("medical_report"),
43576
- className: "autopsy-delete-button"
43577
- }
43578
- )
43766
+ ),
43767
+ maxFiles !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { style: { fontSize: "12px", color: "var(--semi-color-text-2)" }, children: [
43768
+ "已上传 ",
43769
+ medicalFiles.length,
43770
+ " / ",
43771
+ maxFiles,
43772
+ " 个文件"
43773
+ ] })
43579
43774
  ] })
43580
43775
  ] })
43581
43776
  ] });
@@ -44392,27 +44587,25 @@ const FORM_CONFIGS = {
44392
44587
  component: ForensicForm,
44393
44588
  buildRequestBody: ({ formData, tipMessage, lastUserChatContent }) => {
44394
44589
  const forensicData = formData;
44590
+ const confirmationFiles = Array.isArray(forensicData == null ? void 0 : forensicData.confirmation) ? forensicData.confirmation : (forensicData == null ? void 0 : forensicData.confirmation) ? [forensicData.confirmation] : [];
44591
+ const medicalReportFiles = Array.isArray(forensicData == null ? void 0 : forensicData.medical_report) ? forensicData.medical_report : (forensicData == null ? void 0 : forensicData.medical_report) ? [forensicData.medical_report] : [];
44395
44592
  return {
44396
44593
  files: [],
44397
44594
  response_mode: "streaming",
44398
44595
  query: tipMessage || lastUserChatContent || "",
44399
44596
  inputs: {
44400
- confirmation: (forensicData == null ? void 0 : forensicData.confirmation) ? [
44401
- {
44402
- type: "document",
44403
- transfer_method: "local_file",
44404
- url: "",
44405
- upload_file_id: forensicData.confirmation
44406
- }
44407
- ] : [],
44408
- medical_report: (forensicData == null ? void 0 : forensicData.medical_report) ? [
44409
- {
44410
- type: "document",
44411
- transfer_method: "local_file",
44412
- url: "",
44413
- upload_file_id: forensicData.medical_report
44414
- }
44415
- ] : [],
44597
+ confirmation: confirmationFiles.map((fileId) => ({
44598
+ type: "document",
44599
+ transfer_method: "local_file",
44600
+ url: "",
44601
+ upload_file_id: fileId
44602
+ })),
44603
+ medical_report: medicalReportFiles.map((fileId) => ({
44604
+ type: "document",
44605
+ transfer_method: "local_file",
44606
+ url: "",
44607
+ upload_file_id: fileId
44608
+ })),
44416
44609
  inspection_res: (forensicData == null ? void 0 : forensicData.inspection_res) || ""
44417
44610
  },
44418
44611
  user: "admin1"
@@ -44427,27 +44620,25 @@ const FORM_CONFIGS = {
44427
44620
  component: AutopsyForm,
44428
44621
  buildRequestBody: ({ formData, tipMessage, lastUserChatContent, conversationId }) => {
44429
44622
  const autopsyData = formData;
44623
+ const confirmationFiles = Array.isArray(autopsyData == null ? void 0 : autopsyData.confirmation) ? autopsyData.confirmation : (autopsyData == null ? void 0 : autopsyData.confirmation) ? [autopsyData.confirmation] : [];
44624
+ const medicalReportFiles = Array.isArray(autopsyData == null ? void 0 : autopsyData.medical_report) ? autopsyData.medical_report : (autopsyData == null ? void 0 : autopsyData.medical_report) ? [autopsyData.medical_report] : [];
44430
44625
  return {
44431
44626
  user: "admin1",
44432
44627
  response_mode: "streaming",
44433
44628
  files: [],
44434
44629
  inputs: {
44435
- confirmation: (autopsyData == null ? void 0 : autopsyData.confirmation) ? [
44436
- {
44437
- type: "custom",
44438
- transfer_method: "local_file",
44439
- url: "",
44440
- upload_file_id: autopsyData.confirmation
44441
- }
44442
- ] : [],
44443
- medical_report: (autopsyData == null ? void 0 : autopsyData.medical_report) ? [
44444
- {
44445
- type: "document",
44446
- transfer_method: "local_file",
44447
- url: "",
44448
- upload_file_id: autopsyData.medical_report
44449
- }
44450
- ] : []
44630
+ confirmation: confirmationFiles.map((fileId) => ({
44631
+ type: "custom",
44632
+ transfer_method: "local_file",
44633
+ url: "",
44634
+ upload_file_id: fileId
44635
+ })),
44636
+ medical_report: medicalReportFiles.map((fileId) => ({
44637
+ type: "document",
44638
+ transfer_method: "local_file",
44639
+ url: "",
44640
+ upload_file_id: fileId
44641
+ }))
44451
44642
  },
44452
44643
  query: tipMessage || lastUserChatContent || "",
44453
44644
  conversation_id: conversationId || ""
@@ -45390,7 +45581,9 @@ function CommentIndex({
45390
45581
  }
45391
45582
  } else if (formConfig.id === 3 && getForensicFormDataRef.current) {
45392
45583
  const formData = getForensicFormDataRef.current();
45393
- if (!formData.confirmation || !formData.medical_report) {
45584
+ const confirmationFiles = Array.isArray(formData.confirmation) ? formData.confirmation : formData.confirmation ? [formData.confirmation] : [];
45585
+ const medicalReportFiles = Array.isArray(formData.medical_report) ? formData.medical_report : formData.medical_report ? [formData.medical_report] : [];
45586
+ if (confirmationFiles.length === 0 || medicalReportFiles.length === 0) {
45394
45587
  Toast.warning({
45395
45588
  showClose: true,
45396
45589
  duration: 3,
@@ -45408,7 +45601,9 @@ function CommentIndex({
45408
45601
  }
45409
45602
  } else if (formConfig.id === 4 && getAutopsyFormDataRef.current) {
45410
45603
  const formData = getAutopsyFormDataRef.current();
45411
- if (!formData.confirmation || !formData.medical_report) {
45604
+ const confirmationFiles = Array.isArray(formData.confirmation) ? formData.confirmation : formData.confirmation ? [formData.confirmation] : [];
45605
+ const medicalReportFiles = Array.isArray(formData.medical_report) ? formData.medical_report : formData.medical_report ? [formData.medical_report] : [];
45606
+ if (confirmationFiles.length === 0 || medicalReportFiles.length === 0) {
45412
45607
  Toast.warning({
45413
45608
  showClose: true,
45414
45609
  duration: 3,
@@ -45736,6 +45931,76 @@ function CommentIndex({
45736
45931
  return;
45737
45932
  }
45738
45933
  const parsed = JSON.parse(data);
45934
+ if (parsed.event === "message_end") {
45935
+ setCommentChatList((chatList) => {
45936
+ var _a5, _b3, _c, _d, _e;
45937
+ const findIndex = chatList.findIndex(
45938
+ (message) => message.id === botMessage.id
45939
+ );
45940
+ if (findIndex < 0) return chatList;
45941
+ const currentMessage = chatList[findIndex];
45942
+ const newChatList = [...chatList];
45943
+ let references = [];
45944
+ if (((_a5 = parsed.metadata) == null ? void 0 : _a5.retriever_resources) && Array.isArray(parsed.metadata.retriever_resources)) {
45945
+ references = parsed.metadata.retriever_resources.map((resource) => ({
45946
+ id: resource.document_id || resource.id,
45947
+ name: resource.document_name || resource.name || resource.title || "未知文档",
45948
+ type: resource.data_source_type || resource.type || "document",
45949
+ url: resource.url || resource.document_url
45950
+ }));
45951
+ } else if (((_c = (_b3 = parsed.message) == null ? void 0 : _b3.metadata) == null ? void 0 : _c.retriever_resources) && Array.isArray(parsed.message.metadata.retriever_resources)) {
45952
+ references = parsed.message.metadata.retriever_resources.map((resource) => ({
45953
+ id: resource.document_id || resource.id,
45954
+ name: resource.document_name || resource.name || resource.title || "未知文档",
45955
+ type: resource.data_source_type || resource.type || "document",
45956
+ url: resource.url || resource.document_url
45957
+ }));
45958
+ } else if ((_d = parsed.message) == null ? void 0 : _d.retriever_resources) {
45959
+ references = parsed.message.retriever_resources.map((resource) => ({
45960
+ id: resource.document_id || resource.id,
45961
+ name: resource.document_name || resource.name || resource.title || "未知文档",
45962
+ type: resource.data_source_type || resource.type || "document",
45963
+ url: resource.url || resource.document_url
45964
+ }));
45965
+ } else if ((_e = parsed.message) == null ? void 0 : _e.files) {
45966
+ references = parsed.message.files.map((file) => ({
45967
+ id: file.id || file.file_id,
45968
+ name: file.name || file.file_name || "未知文件",
45969
+ type: file.type || "file",
45970
+ url: file.url || file.file_url
45971
+ }));
45972
+ } else if (parsed.retriever_resources) {
45973
+ references = parsed.retriever_resources.map((resource) => ({
45974
+ id: resource.document_id || resource.id,
45975
+ name: resource.document_name || resource.name || resource.title || "未知文档",
45976
+ type: resource.data_source_type || resource.type || "document",
45977
+ url: resource.url || resource.document_url
45978
+ }));
45979
+ } else if (parsed.files) {
45980
+ references = parsed.files.map((file) => ({
45981
+ id: file.id || file.file_id,
45982
+ name: file.name || file.file_name || "未知文件",
45983
+ type: file.type || "file",
45984
+ url: file.url || file.file_url
45985
+ }));
45986
+ }
45987
+ if (references.length > 0) {
45988
+ console.log("解析到引用文献:", references);
45989
+ } else {
45990
+ console.log("未找到引用文献数据,parsed 数据:", parsed);
45991
+ }
45992
+ newChatList[findIndex] = {
45993
+ ...currentMessage,
45994
+ completed: true,
45995
+ references: references.length > 0 ? references : currentMessage.references
45996
+ };
45997
+ return newChatList;
45998
+ });
45999
+ setTimeout(() => {
46000
+ commentContentBoxScrollBottom();
46001
+ }, 0);
46002
+ continue;
46003
+ }
45739
46004
  if (parsed.conversation_id && currentCommentSessionId) {
45740
46005
  LocalForageService.getItem("session_list").then((sessionList2) => {
45741
46006
  if (sessionList2) {
@@ -46128,10 +46393,25 @@ function CommentIndex({
46128
46393
  console.log("提取的推荐问题:", openingPrompts);
46129
46394
  const fileUploadEnabled2 = ((_a3 = result.file_upload) == null ? void 0 : _a3.enabled) === true;
46130
46395
  console.log("提取的文件上传配置 (file_upload.enabled):", fileUploadEnabled2);
46396
+ let maxFileCount = void 0;
46397
+ if (result.user_input_form && Array.isArray(result.user_input_form)) {
46398
+ console.log("user_input_form 数据:", result.user_input_form);
46399
+ for (const item of result.user_input_form) {
46400
+ if (item && typeof item === "object" && "file-list" in item) {
46401
+ const fileListConfig = item["file-list"];
46402
+ if (fileListConfig && typeof fileListConfig === "object" && fileListConfig.type === "file-list" && typeof fileListConfig.max_length === "number") {
46403
+ maxFileCount = fileListConfig.max_length;
46404
+ console.log("提取的文件上传数量限制 (max_length):", maxFileCount);
46405
+ break;
46406
+ }
46407
+ }
46408
+ }
46409
+ }
46131
46410
  return {
46132
46411
  openingStatement,
46133
46412
  openingPrompts: Array.isArray(openingPrompts) ? openingPrompts : null,
46134
- fileUploadEnabled: fileUploadEnabled2
46413
+ fileUploadEnabled: fileUploadEnabled2,
46414
+ maxFileCount
46135
46415
  };
46136
46416
  } catch (error) {
46137
46417
  console.error("获取开场白和推荐问题失败:", error);
@@ -46146,6 +46426,7 @@ function CommentIndex({
46146
46426
  let openingContent = agent.description || `你好!我是${agent.name},很高兴为您服务!有什么我可以帮助您的吗?`;
46147
46427
  let openingPrompts = ((_a3 = agent.config) == null ? void 0 : _a3.openingPrompts) || void 0;
46148
46428
  let fileUploadEnabledValue = false;
46429
+ let maxFileCountValue = void 0;
46149
46430
  if (agent.apiKeys) {
46150
46431
  try {
46151
46432
  console.log(
@@ -46171,6 +46452,10 @@ function CommentIndex({
46171
46452
  setFileUploadEnabled(openingData.fileUploadEnabled);
46172
46453
  console.log(`[推荐词接口] 文件上传功能启用状态:`, openingData.fileUploadEnabled);
46173
46454
  }
46455
+ if (openingData.maxFileCount !== void 0) {
46456
+ maxFileCountValue = openingData.maxFileCount;
46457
+ console.log(`[推荐词接口] 文件上传数量限制:`, maxFileCountValue);
46458
+ }
46174
46459
  } else {
46175
46460
  console.log(`[推荐词接口] 接口返回null,使用默认配置`);
46176
46461
  }
@@ -46276,6 +46561,8 @@ function CommentIndex({
46276
46561
  openingPrompts,
46277
46562
  fileUploadEnabled: fileUploadEnabledValue,
46278
46563
  // 保存文件上传按钮显示状态
46564
+ maxFileCount: maxFileCountValue,
46565
+ // 保存文件上传数量限制
46279
46566
  // 根据 uiType 配置初始化表单数据
46280
46567
  ...initialFormData.translationData && {
46281
46568
  translationData: initialFormData.translationData
@@ -46898,7 +47185,9 @@ function CommentIndex({
46898
47185
  agentListVisible,
46899
47186
  onNavigateView,
46900
47187
  currentAgentName: (currentCommentSession == null ? void 0 : currentCommentSession.agentName) || ((_a2 = agentList2.find((agent) => agent.id === selectedAgentId)) == null ? void 0 : _a2.name) || "",
46901
- currentAgentCustomize: (_b = agentList2.find((agent) => agent.id === selectedAgentId)) == null ? void 0 : _b.customize,
47188
+ currentAgentCustomize: (_b = agentList2.find(
47189
+ (agent) => agent.id === (currentCommentSession == null ? void 0 : currentCommentSession.agentId) || agent.id === selectedAgentId
47190
+ )) == null ? void 0 : _b.customize,
46902
47191
  isThinkInitial: isThink,
46903
47192
  onBackToAiList,
46904
47193
  showBackButton: pageType === "xinXiaoYi" ? false : true,
@@ -47031,6 +47320,7 @@ function CommentIndex({
47031
47320
  {
47032
47321
  uploadUrl: `${CommonUtil.getDifyApiBaseUrl()}/v1/files/upload`,
47033
47322
  apiKey: sessionAgent == null ? void 0 : sessionAgent.apiKeys,
47323
+ maxFiles: currentCommentSession == null ? void 0 : currentCommentSession.maxFileCount,
47034
47324
  getFormData: (getData) => {
47035
47325
  getForensicFormDataRef.current = getData;
47036
47326
  },
@@ -47051,9 +47341,11 @@ function CommentIndex({
47051
47341
  inspection_res: ""
47052
47342
  };
47053
47343
  if (section === "confirmation") {
47054
- forensicData.confirmation = fileId;
47344
+ const existing = Array.isArray(forensicData.confirmation) ? forensicData.confirmation : forensicData.confirmation ? [forensicData.confirmation] : [];
47345
+ forensicData.confirmation = [...existing, fileId];
47055
47346
  } else if (section === "medical_report") {
47056
- forensicData.medical_report = fileId;
47347
+ const existing = Array.isArray(forensicData.medical_report) ? forensicData.medical_report : forensicData.medical_report ? [forensicData.medical_report] : [];
47348
+ forensicData.medical_report = [...existing, fileId];
47057
47349
  }
47058
47350
  newSessionList[sessionIndex] = {
47059
47351
  ...currentSession,
@@ -47098,6 +47390,7 @@ function CommentIndex({
47098
47390
  {
47099
47391
  uploadUrl: `${CommonUtil.getDifyApiBaseUrl()}/v1/files/upload`,
47100
47392
  apiKey: sessionAgent == null ? void 0 : sessionAgent.apiKeys,
47393
+ maxFiles: currentCommentSession == null ? void 0 : currentCommentSession.maxFileCount,
47101
47394
  getFormData: (getData) => {
47102
47395
  getAutopsyFormDataRef.current = getData;
47103
47396
  },
@@ -47118,9 +47411,11 @@ function CommentIndex({
47118
47411
  medical_report: void 0
47119
47412
  };
47120
47413
  if (section === "confirmation") {
47121
- autopsyData.confirmation = fileId;
47414
+ const existing = Array.isArray(autopsyData.confirmation) ? autopsyData.confirmation : autopsyData.confirmation ? [autopsyData.confirmation] : [];
47415
+ autopsyData.confirmation = [...existing, fileId];
47122
47416
  } else if (section === "medical_report") {
47123
- autopsyData.medical_report = fileId;
47417
+ const existing = Array.isArray(autopsyData.medical_report) ? autopsyData.medical_report : autopsyData.medical_report ? [autopsyData.medical_report] : [];
47418
+ autopsyData.medical_report = [...existing, fileId];
47124
47419
  }
47125
47420
  newSessionList[sessionIndex] = {
47126
47421
  ...currentSession,
@@ -47451,6 +47746,7 @@ function CommentIndex({
47451
47746
  accept: formConfig.id === 10 ? "audio/*" : "*/*",
47452
47747
  multiple: isMultiple,
47453
47748
  uploadedFiles: getUploadedFiles(),
47749
+ maxFiles: currentCommentSession == null ? void 0 : currentCommentSession.maxFileCount,
47454
47750
  onUploadSuccess: (fileId, fileName) => {
47455
47751
  if (currentCommentSessionId) {
47456
47752
  LocalForageService.getItem("session_list").then((sessionList) => {
@@ -47874,7 +48170,7 @@ const BlockEdit = ({
47874
48170
  const initVueEditor = async () => {
47875
48171
  if (editorRef.current) {
47876
48172
  try {
47877
- const BlockNoteEditorModule = await import("./index.es-C1pPA0i2.js");
48173
+ const BlockNoteEditorModule = await import("./index.es-C959LfHw.js");
47878
48174
  const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
47879
48175
  const theme = {
47880
48176
  colors: {
@@ -48373,7 +48669,7 @@ const Chat3 = forwardRef(
48373
48669
  query.content = `${query.content} 以下内容:${aiActionText}`;
48374
48670
  }
48375
48671
  console.log("query123", query);
48376
- let apiUrl = (baseUrl == null ? void 0 : baseUrl.difyApi) || localStorage.getItem("difyApi") || "http://62.168.243.3:8899";
48672
+ let apiUrl = (baseUrl == null ? void 0 : baseUrl.difyApi) || localStorage.getItem("difyApi") || "http://111.6.44.42:30000";
48377
48673
  const intelligentQaApiKey = ((_a2 = baseUrl == null ? void 0 : baseUrl.aiAnswerAgent) == null ? void 0 : _a2.tokens) || ((_b = JSON.parse(localStorage.getItem("aiAnswerAgent") || "{}")) == null ? void 0 : _b.tokens) || "app-U9WTcWVUrU9LL6Z01FHxsMMS";
48378
48674
  const requestBody = {
48379
48675
  files: [],
@@ -48409,7 +48705,6 @@ const Chat3 = forwardRef(
48409
48705
  };
48410
48706
  return newList;
48411
48707
  });
48412
- console.log("response123", errorData.error, "currentIndex");
48413
48708
  return;
48414
48709
  }
48415
48710
  const reader = (_c = response.body) == null ? void 0 : _c.getReader();
@@ -48430,7 +48725,6 @@ const Chat3 = forwardRef(
48430
48725
  if (line.startsWith("data: ")) {
48431
48726
  const data = line.slice(6);
48432
48727
  const parsed = JSON.parse(data);
48433
- console.log("data123", data);
48434
48728
  if (data === "[DONE]" || parsed.event === "message_end") {
48435
48729
  setMsgList((prev) => {
48436
48730
  const msgIndex = prev.findIndex(
@@ -48451,12 +48745,15 @@ const Chat3 = forwardRef(
48451
48745
  }, 100);
48452
48746
  continue;
48453
48747
  }
48454
- const content_msg = parsed == null ? void 0 : parsed.answer;
48748
+ let content_msg = parsed == null ? void 0 : parsed.answer;
48455
48749
  const conversation_id = parsed == null ? void 0 : parsed.conversation_id;
48456
48750
  if (aiAction) {
48457
48751
  setConversationId(conversation_id || "");
48458
48752
  }
48459
48753
  if (content_msg !== void 0 && content_msg !== null && content_msg !== "") {
48754
+ if (content_msg.indexOf("<think>") !== -1) {
48755
+ content_msg = content_msg.replace("<think>", "");
48756
+ }
48460
48757
  setMsgList((prev) => {
48461
48758
  const msgIndex = prev.findIndex(
48462
48759
  (item) => item.id === id && item.type === "ai"
@@ -48707,6 +49004,7 @@ const style = {
48707
49004
  backgroundColor: "transparent",
48708
49005
  color: "#333"
48709
49006
  };
49007
+ const HISTORY_PAGE_SIZE = 20;
48710
49008
  const AiBlockEdit = ({
48711
49009
  getSetBlockContent,
48712
49010
  baseUrl,
@@ -48726,11 +49024,16 @@ const AiBlockEdit = ({
48726
49024
  const [exporting, setExporting] = useState(false);
48727
49025
  useRef(false);
48728
49026
  const [editorReady, setEditorReady] = useState(false);
49027
+ const [historyVisible, setHistoryVisible] = useState(false);
49028
+ const [historyList, setHistoryList] = useState([]);
49029
+ const [historyLoading, setHistoryLoading] = useState(false);
49030
+ const [historyHasMore, setHistoryHasMore] = useState(true);
49031
+ const [currentConversationId, setCurrentConversationId] = useState("");
48729
49032
  useEffect(() => {
48730
49033
  const initVueEditor = async () => {
48731
49034
  if (editorRef.current) {
48732
49035
  try {
48733
- const BlockNoteEditorModule = await import("./index.es-C1pPA0i2.js");
49036
+ const BlockNoteEditorModule = await import("./index.es-C959LfHw.js");
48734
49037
  const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
48735
49038
  const theme = {
48736
49039
  colors: {
@@ -49087,6 +49390,135 @@ const AiBlockEdit = ({
49087
49390
  getSetBlockContent(setBlockContent);
49088
49391
  }
49089
49392
  }, [getSetBlockContent]);
49393
+ const getHistory = async (lastId) => {
49394
+ var _a2, _b;
49395
+ if (historyLoading) return;
49396
+ setHistoryLoading(true);
49397
+ let apiUrl = (baseUrl == null ? void 0 : baseUrl.difyApi) || localStorage.getItem("difyApi") || "http://111.6.44.42:30000";
49398
+ const intelligentQaApiKey = ((_a2 = baseUrl == null ? void 0 : baseUrl.aiWritingAgent) == null ? void 0 : _a2.tokens) || ((_b = JSON.parse(localStorage.getItem("aiWritingAgent") || "{}")) == null ? void 0 : _b.tokens) || "app-tQ4LITOR6HCUYd1RqZe5LRHS";
49399
+ try {
49400
+ const query = new URLSearchParams({
49401
+ user: "admin1",
49402
+ last_id: lastId || "",
49403
+ limit: String(HISTORY_PAGE_SIZE)
49404
+ });
49405
+ const response = await fetch(
49406
+ `${apiUrl}/v1/conversations?${query.toString()}`,
49407
+ {
49408
+ method: "GET",
49409
+ headers: {
49410
+ Authorization: `Bearer ${intelligentQaApiKey}`,
49411
+ "Content-Type": "application/json"
49412
+ }
49413
+ }
49414
+ );
49415
+ const data = await response.json();
49416
+ if (!response.ok) {
49417
+ throw new Error((data == null ? void 0 : data.message) || "获取历史记录失败");
49418
+ }
49419
+ const list2 = Array.isArray(data == null ? void 0 : data.data) ? data.data : [];
49420
+ setHistoryList((prev) => lastId ? [...prev, ...list2] : list2);
49421
+ if (typeof (data == null ? void 0 : data.has_more) === "boolean") {
49422
+ setHistoryHasMore(data.has_more);
49423
+ } else {
49424
+ setHistoryHasMore(list2.length === HISTORY_PAGE_SIZE);
49425
+ }
49426
+ } catch (error) {
49427
+ console.error("获取历史记录失败:", error);
49428
+ Toast.error("获取历史记录失败,请重试或查看控制台日志");
49429
+ } finally {
49430
+ setHistoryLoading(false);
49431
+ }
49432
+ };
49433
+ const deleteHistory = async (id) => {
49434
+ Modal.confirm({
49435
+ title: "删除历史记录",
49436
+ content: "确定要删除该历史记录吗?",
49437
+ onOk: async () => {
49438
+ var _a2, _b;
49439
+ try {
49440
+ const apiUrl = (baseUrl == null ? void 0 : baseUrl.difyApi) || localStorage.getItem("difyApi") || "http://111.6.44.42:30000";
49441
+ const intelligentQaApiKey = ((_a2 = baseUrl == null ? void 0 : baseUrl.aiWritingAgent) == null ? void 0 : _a2.tokens) || ((_b = JSON.parse(localStorage.getItem("aiWritingAgent") || "{}")) == null ? void 0 : _b.tokens) || "app-tQ4LITOR6HCUYd1RqZe5LRHS";
49442
+ const response = await fetch(`${apiUrl}/v1/conversations/${id}`, {
49443
+ method: "DELETE",
49444
+ headers: {
49445
+ Authorization: `Bearer ${intelligentQaApiKey}`,
49446
+ "Content-Type": "application/json"
49447
+ },
49448
+ body: JSON.stringify({
49449
+ user: "admin1"
49450
+ })
49451
+ });
49452
+ const data = await response.json();
49453
+ if (!response.ok) {
49454
+ Toast.error((data == null ? void 0 : data.message) || "删除历史记录失败");
49455
+ throw new Error((data == null ? void 0 : data.message) || "删除历史记录失败");
49456
+ }
49457
+ Toast.success("删除历史记录成功");
49458
+ setHistoryList((prev) => prev.filter((item) => item.id !== id));
49459
+ } catch (error) {
49460
+ console.error("删除历史记录失败:", error);
49461
+ Toast.error("删除历史记录失败,请重试或查看控制台日志");
49462
+ }
49463
+ },
49464
+ onCancel: () => {
49465
+ return;
49466
+ }
49467
+ });
49468
+ };
49469
+ const getHistoryDetail = async (id) => {
49470
+ var _a2, _b, _c, _d;
49471
+ setCurrentConversationId(id);
49472
+ const apiUrl = (baseUrl == null ? void 0 : baseUrl.difyApi) || localStorage.getItem("difyApi") || "http://111.6.44.42:30000";
49473
+ const intelligentQaApiKey = ((_a2 = baseUrl == null ? void 0 : baseUrl.aiWritingAgent) == null ? void 0 : _a2.tokens) || ((_b = JSON.parse(localStorage.getItem("aiWritingAgent") || "{}")) == null ? void 0 : _b.tokens) || "app-tQ4LITOR6HCUYd1RqZe5LRHS";
49474
+ const response = await fetch(
49475
+ `${apiUrl}/v1/messages?user=admin1&conversation_id=${id}`,
49476
+ {
49477
+ method: "GET",
49478
+ headers: {
49479
+ Authorization: `Bearer ${intelligentQaApiKey}`,
49480
+ "Content-Type": "application/json"
49481
+ }
49482
+ }
49483
+ );
49484
+ const data = await response.json();
49485
+ if (!response.ok || !(data == null ? void 0 : data.data)) {
49486
+ Toast.error((data == null ? void 0 : data.message) || "获取历史记录详情失败");
49487
+ throw new Error((data == null ? void 0 : data.message) || "获取历史记录详情失败");
49488
+ }
49489
+ if (((_c = data == null ? void 0 : data.data) == null ? void 0 : _c.length) > 0) {
49490
+ let message = (_d = data == null ? void 0 : data.data[0]) == null ? void 0 : _d.answer;
49491
+ if (message && message.indexOf("<think>") !== -1) {
49492
+ message = message.split("<think>")[1];
49493
+ }
49494
+ console.log("message123", message);
49495
+ if (message) {
49496
+ setBlockContent(message);
49497
+ } else {
49498
+ Toast.info("获取历史记录详情为空");
49499
+ }
49500
+ }
49501
+ };
49502
+ const openDrawer = () => {
49503
+ setHistoryVisible(true);
49504
+ setHistoryList([]);
49505
+ setHistoryHasMore(true);
49506
+ void getHistory();
49507
+ };
49508
+ const handleHistoryScroll = (event) => {
49509
+ var _a2;
49510
+ const target = event.currentTarget;
49511
+ if (historyLoading || !historyHasMore || historyList.length === 0) {
49512
+ return;
49513
+ }
49514
+ const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
49515
+ if (distanceToBottom <= 40) {
49516
+ const lastId = (_a2 = historyList[historyList.length - 1]) == null ? void 0 : _a2.id;
49517
+ if (lastId) {
49518
+ void getHistory(lastId);
49519
+ }
49520
+ }
49521
+ };
49090
49522
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
49091
49523
  "div",
49092
49524
  {
@@ -49126,7 +49558,16 @@ const AiBlockEdit = ({
49126
49558
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "block-edit-right-content", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: editorRef, className: "vue-editor-container" }) })
49127
49559
  ] }),
49128
49560
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "block-edit-left", children: [
49129
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "block-edit-left-header", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "block-edit-left-header-title", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "AI对话" }) }) }),
49561
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "block-edit-left-header", children: [
49562
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "block-edit-left-header-title", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "AI对话" }) }),
49563
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { content: "历史记录", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49564
+ IconHistory,
49565
+ {
49566
+ className: "block-edit-left-header-history",
49567
+ onClick: () => openDrawer()
49568
+ }
49569
+ ) })
49570
+ ] }),
49130
49571
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "block-edit-left-content", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49131
49572
  Chat3,
49132
49573
  {
@@ -49150,7 +49591,45 @@ const AiBlockEdit = ({
49150
49591
  }
49151
49592
  }
49152
49593
  ) })
49153
- ] })
49594
+ ] }),
49595
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49596
+ SideSheet,
49597
+ {
49598
+ title: "历史记录",
49599
+ visible: historyVisible,
49600
+ onCancel: () => setHistoryVisible(false),
49601
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "side-sheet-content", onScroll: handleHistoryScroll, children: [
49602
+ historyList.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
49603
+ "div",
49604
+ {
49605
+ className: "side-sheet-content-list",
49606
+ style: {
49607
+ backgroundColor: currentConversationId === item.id ? "#f0f0f0" : "#fff"
49608
+ },
49609
+ children: [
49610
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49611
+ "div",
49612
+ {
49613
+ className: "side-sheet-content-list-item",
49614
+ onClick: () => getHistoryDetail(item.id),
49615
+ children: item.inputs.Title
49616
+ }
49617
+ ),
49618
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49619
+ IconClose,
49620
+ {
49621
+ className: "side-sheet-content-list-close",
49622
+ onClick: () => deleteHistory(item.id)
49623
+ }
49624
+ )
49625
+ ]
49626
+ },
49627
+ item.id
49628
+ )),
49629
+ historyLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "side-sheet-content-list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "side-sheet-content-list-item", children: "加载中..." }) })
49630
+ ] })
49631
+ }
49632
+ )
49154
49633
  ]
49155
49634
  }
49156
49635
  );
@@ -49474,7 +49953,7 @@ class BasePromptTemplate extends Runnable {
49474
49953
  return PromptTemplate2.deserialize({ ...data, _type: "prompt" });
49475
49954
  }
49476
49955
  case "few_shot": {
49477
- const { FewShotPromptTemplate } = await import("./few_shot-4uZaqdPp.js");
49956
+ const { FewShotPromptTemplate } = await import("./few_shot-BXjYa1YP.js");
49478
49957
  return FewShotPromptTemplate.deserialize(data);
49479
49958
  }
49480
49959
  default:
@@ -51046,35 +51525,35 @@ class BaseChain extends BaseLangChain {
51046
51525
  static async deserialize(data, values = {}) {
51047
51526
  switch (data._type) {
51048
51527
  case "llm_chain": {
51049
- const { LLMChain } = await import("./llm_chain-CVod3WTv.js");
51528
+ const { LLMChain } = await import("./llm_chain-B9EUYWx_.js");
51050
51529
  return LLMChain.deserialize(data);
51051
51530
  }
51052
51531
  case "sequential_chain": {
51053
- const { SequentialChain } = await import("./sequential_chain-BzVPL3fD.js");
51532
+ const { SequentialChain } = await import("./sequential_chain-D_5KYvTs.js");
51054
51533
  return SequentialChain.deserialize(data);
51055
51534
  }
51056
51535
  case "simple_sequential_chain": {
51057
- const { SimpleSequentialChain } = await import("./sequential_chain-BzVPL3fD.js");
51536
+ const { SimpleSequentialChain } = await import("./sequential_chain-D_5KYvTs.js");
51058
51537
  return SimpleSequentialChain.deserialize(data);
51059
51538
  }
51060
51539
  case "stuff_documents_chain": {
51061
- const { StuffDocumentsChain } = await import("./combine_docs_chain-DyJhshny.js");
51540
+ const { StuffDocumentsChain } = await import("./combine_docs_chain-DxTWH4t8.js");
51062
51541
  return StuffDocumentsChain.deserialize(data);
51063
51542
  }
51064
51543
  case "map_reduce_documents_chain": {
51065
- const { MapReduceDocumentsChain } = await import("./combine_docs_chain-DyJhshny.js");
51544
+ const { MapReduceDocumentsChain } = await import("./combine_docs_chain-DxTWH4t8.js");
51066
51545
  return MapReduceDocumentsChain.deserialize(data);
51067
51546
  }
51068
51547
  case "refine_documents_chain": {
51069
- const { RefineDocumentsChain } = await import("./combine_docs_chain-DyJhshny.js");
51548
+ const { RefineDocumentsChain } = await import("./combine_docs_chain-DxTWH4t8.js");
51070
51549
  return RefineDocumentsChain.deserialize(data);
51071
51550
  }
51072
51551
  case "vector_db_qa": {
51073
- const { VectorDBQAChain } = await import("./vector_db_qa-CMop95Y6.js");
51552
+ const { VectorDBQAChain } = await import("./vector_db_qa-Bz3hlL-C.js");
51074
51553
  return VectorDBQAChain.deserialize(data, values);
51075
51554
  }
51076
51555
  case "api_chain": {
51077
- const { APIChain } = await import("./api_chain-B3htIXeL.js");
51556
+ const { APIChain } = await import("./api_chain-CdqEyV93.js");
51078
51557
  return APIChain.deserialize(data);
51079
51558
  }
51080
51559
  default: