rhua-chatgpt-web 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api_chain-z7-hferR.cjs → api_chain-CnsQbB3_.cjs} +1 -1
- package/dist/{api_chain-6WuaFa6d.js → api_chain-_gAY_Ff4.js} +2 -2
- package/dist/{combine_docs_chain-CO7HVb4R.js → combine_docs_chain-D_BlYVy7.js} +2 -2
- package/dist/{combine_docs_chain-CFAXRlyi.cjs → combine_docs_chain-db22oa2b.cjs} +1 -1
- package/dist/{few_shot-GynjP3JZ.cjs → few_shot-t1ZCsnho.cjs} +1 -1
- package/dist/{few_shot-D1fV7wmE.js → few_shot-w2yEuYBx.js} +1 -1
- package/dist/index-8lGdUJP1.js +4 -0
- package/dist/{index-BcePyLfy.cjs → index-B23id95w.cjs} +1 -1
- package/dist/{index-oel1bTo0.cjs → index-B8bnMwrg.cjs} +1 -1
- package/dist/index-B8s9AcSz.js +4 -0
- package/dist/{index-DaVkrct-.cjs → index-B9OFiGXi.cjs} +1 -1
- package/dist/{index-CFCSEDxn.cjs → index-BBibfWcS.cjs} +1 -1
- package/dist/{index-CYZSWzuu.js → index-BGPoHY0q.js} +2 -2
- package/dist/{index-B3AeHb0J.js → index-BPsQyOrm.js} +1 -1
- package/dist/{index-Dkq6Ss_h.js → index-Bp0LJnbm.js} +1 -1
- package/dist/{index-BdHsAk36.cjs → index-C2FK4vVw.cjs} +1 -1
- package/dist/{index-DsPuml45.cjs → index-C8-EKble.cjs} +9 -9
- package/dist/{index-BjVIOIdk.cjs → index-CGPQrqQT.cjs} +1 -1
- package/dist/{index-D0o12JtU.js → index-CHzh5IhP.js} +1 -1
- package/dist/{index-DKYlRoiR.js → index-CNmegDVK.js} +2 -2
- package/dist/{index-Cfz7TnCH.js → index-CznwOIid.js} +684 -256
- package/dist/{index-CMmMjajZ.cjs → index-D1gOChlC.cjs} +1 -1
- package/dist/{index-PRwtvON1.js → index-DD8V9-3e.js} +1 -1
- package/dist/{index-Dift2gpr.cjs → index-DpvFsML8.cjs} +1 -1
- package/dist/{index-jr5i21r1.cjs → index-YNkeef7K.cjs} +1 -1
- package/dist/{index-KDG7mz5O.cjs → index-fSVpxDtJ.cjs} +1 -1
- package/dist/{index-DL_ocleL.cjs → index-lhPd8bdF.cjs} +1 -1
- package/dist/{index-gI4Ks2P3.js → index-pEb3QKAv.js} +1 -1
- package/dist/index-tJTVI70e.js +4 -0
- package/dist/index-tT2o02DG.js +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-QDwz4eEz.cjs → index.es-Cw5cK6IY.cjs} +2 -2
- package/dist/{index.es-Fq7tEj25.js → index.es-D77mvuFI.js} +11 -11
- package/dist/index.esm.js +1 -1
- package/dist/{llm_chain-5NVYgTDC.js → llm_chain-C-9mmcVX.js} +1 -1
- package/dist/{llm_chain-HMEylFLR.cjs → llm_chain-ylM6i0Y_.cjs} +1 -1
- package/dist/{sequential_chain-BIwygM6l.cjs → sequential_chain-B0kEMck2.cjs} +1 -1
- package/dist/{sequential_chain-B3aNFa_8.js → sequential_chain-DP94xDnI.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{vector_db_qa-C_vzGRYC.cjs → vector_db_qa-Dj3wQPpW.cjs} +1 -1
- package/dist/{vector_db_qa-BlC0aeM2.js → vector_db_qa-jcfmC8oz.js} +3 -3
- package/package.json +1 -1
- package/dist/index-BiyXJ5nZ.js +0 -4
- package/dist/index-C4FSTC-Y.js +0 -4
- package/dist/index-De7_kMn7.js +0 -4
- package/dist/index-Gi2kGbCW.js +0 -4
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
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
5
|
import { Button, Input, Select, Checkbox, Tooltip, Toast, Typography, Collapsible, Dropdown, Tag, Avatar, Spin, Layout, 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,
|
|
6
|
+
import { IconChevronDown, IconClose, IconShareStroked, IconPlus, IconSearch, IconEdit2Stroked, IconDeleteStroked, IconCopyStroked, IconDownCircleStroked, IconBulb, IconChevronUp, IconFile, IconLink, IconTreeTriangleDown, IconImage, IconArrowRight, IconRefresh, IconLikeThumb, IconArrowLeft, IconBolt, IconEditStroked, IconComment, IconDelete, IconCloud, IconStop, IconSend, IconChevronLeft, IconArrowUp, 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";
|
|
@@ -41853,6 +41853,51 @@ const isEqual = (prevProps, currentProps) => {
|
|
|
41853
41853
|
};
|
|
41854
41854
|
const MarkdownBox = React__default.memo(({ content: content2, themeMode = "light" }) => {
|
|
41855
41855
|
const thinkingContent = parseThinkingContent(content2);
|
|
41856
|
+
const isDownloadLink = (href) => {
|
|
41857
|
+
if (!href) return false;
|
|
41858
|
+
const downloadExtensions = [
|
|
41859
|
+
".pdf",
|
|
41860
|
+
".doc",
|
|
41861
|
+
".docx",
|
|
41862
|
+
".xls",
|
|
41863
|
+
".xlsx",
|
|
41864
|
+
".ppt",
|
|
41865
|
+
".pptx",
|
|
41866
|
+
".zip",
|
|
41867
|
+
".rar",
|
|
41868
|
+
".7z",
|
|
41869
|
+
".tar",
|
|
41870
|
+
".gz",
|
|
41871
|
+
".txt",
|
|
41872
|
+
".csv",
|
|
41873
|
+
".json",
|
|
41874
|
+
".xml",
|
|
41875
|
+
".jpg",
|
|
41876
|
+
".jpeg",
|
|
41877
|
+
".png",
|
|
41878
|
+
".gif",
|
|
41879
|
+
".bmp",
|
|
41880
|
+
".svg",
|
|
41881
|
+
".webp",
|
|
41882
|
+
".mp4",
|
|
41883
|
+
".avi",
|
|
41884
|
+
".mov",
|
|
41885
|
+
".wmv",
|
|
41886
|
+
".flv",
|
|
41887
|
+
".mp3",
|
|
41888
|
+
".wav",
|
|
41889
|
+
".flac",
|
|
41890
|
+
".aac",
|
|
41891
|
+
".exe",
|
|
41892
|
+
".dmg",
|
|
41893
|
+
".deb",
|
|
41894
|
+
".rpm",
|
|
41895
|
+
".apk",
|
|
41896
|
+
".ipa"
|
|
41897
|
+
];
|
|
41898
|
+
const lowerHref = href.toLowerCase();
|
|
41899
|
+
return downloadExtensions.some((ext) => lowerHref.includes(ext));
|
|
41900
|
+
};
|
|
41856
41901
|
const extractLinkButtons = (text2) => {
|
|
41857
41902
|
const buttons2 = [];
|
|
41858
41903
|
const buttonPattern = /<button\s+data-link=["']([^"']+)["'][^>]*>([\s\S]*?)<\/button>/gi;
|
|
@@ -41879,7 +41924,46 @@ const MarkdownBox = React__default.memo(({ content: content2, themeMode = "light
|
|
|
41879
41924
|
children: MessageUtil.messageContentConvert(cleanedContent),
|
|
41880
41925
|
components: {
|
|
41881
41926
|
a: ({ href, children }) => {
|
|
41882
|
-
|
|
41927
|
+
if (!href) {
|
|
41928
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { children });
|
|
41929
|
+
}
|
|
41930
|
+
const isDownload = isDownloadLink(href);
|
|
41931
|
+
const buttonText = isDownload ? "点击下载" : "点击跳转";
|
|
41932
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
41933
|
+
Button,
|
|
41934
|
+
{
|
|
41935
|
+
className: "markdown-link-button",
|
|
41936
|
+
theme: "solid",
|
|
41937
|
+
type: "primary",
|
|
41938
|
+
icon: isDownload ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconLink, {}),
|
|
41939
|
+
onClick: () => {
|
|
41940
|
+
if (isDownload) {
|
|
41941
|
+
try {
|
|
41942
|
+
const link2 = document.createElement("a");
|
|
41943
|
+
link2.href = href;
|
|
41944
|
+
const urlParts = href.split("/");
|
|
41945
|
+
const fileName = urlParts[urlParts.length - 1].split("?")[0];
|
|
41946
|
+
link2.download = fileName || "";
|
|
41947
|
+
link2.target = "_blank";
|
|
41948
|
+
link2.rel = "noopener noreferrer";
|
|
41949
|
+
document.body.appendChild(link2);
|
|
41950
|
+
link2.click();
|
|
41951
|
+
document.body.removeChild(link2);
|
|
41952
|
+
} catch (error) {
|
|
41953
|
+
window.open(href, "_blank", "noopener,noreferrer");
|
|
41954
|
+
}
|
|
41955
|
+
} else {
|
|
41956
|
+
window.open(href, "_blank", "noopener,noreferrer");
|
|
41957
|
+
}
|
|
41958
|
+
},
|
|
41959
|
+
style: {
|
|
41960
|
+
margin: "0px 8px 4px 8px",
|
|
41961
|
+
display: "inline-flex",
|
|
41962
|
+
alignItems: "center"
|
|
41963
|
+
},
|
|
41964
|
+
children: buttonText
|
|
41965
|
+
}
|
|
41966
|
+
);
|
|
41883
41967
|
},
|
|
41884
41968
|
code: ({ node: node2, className, children, ...props }) => {
|
|
41885
41969
|
const match = /language-(\w+)/.exec(className || "");
|
|
@@ -42118,11 +42202,20 @@ const BotMessageBox = React__default.memo(
|
|
|
42118
42202
|
agentApiKey,
|
|
42119
42203
|
openingPrompts,
|
|
42120
42204
|
showOpeningPrompts = true,
|
|
42121
|
-
agentDescription
|
|
42205
|
+
agentDescription,
|
|
42206
|
+
likeMessage,
|
|
42207
|
+
dislikeMessage,
|
|
42208
|
+
regenerateMessage
|
|
42122
42209
|
}) => {
|
|
42123
42210
|
const [showThink, setShowThink] = React__default.useState(true);
|
|
42124
42211
|
const [expandedReferences, setExpandedReferences] = React__default.useState(/* @__PURE__ */ new Set());
|
|
42212
|
+
const [isLiked, setIsLiked] = React__default.useState(message.isLiked || false);
|
|
42213
|
+
const [isDisliked, setIsDisliked] = React__default.useState(message.isDisliked || false);
|
|
42125
42214
|
const prevReferencesRef = useRef(message.references);
|
|
42215
|
+
useEffect(() => {
|
|
42216
|
+
setIsLiked(message.isLiked || false);
|
|
42217
|
+
setIsDisliked(message.isDisliked || false);
|
|
42218
|
+
}, [message.isLiked, message.isDisliked]);
|
|
42126
42219
|
useEffect(() => {
|
|
42127
42220
|
const prevRefs = prevReferencesRef.current;
|
|
42128
42221
|
const currentRefs = message.references;
|
|
@@ -42161,251 +42254,383 @@ const BotMessageBox = React__default.memo(
|
|
|
42161
42254
|
const hasThinkContent = thinkContent !== "";
|
|
42162
42255
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "comment-single-box bot", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "comment-single-wrapper", children: [
|
|
42163
42256
|
(!message.isNewChat || !isMobile) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "comment-single-avatar", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: robotIcon, alt: "机器人头像" }) }),
|
|
42164
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
42165
|
-
|
|
42166
|
-
|
|
42167
|
-
|
|
42168
|
-
|
|
42169
|
-
|
|
42170
|
-
|
|
42171
|
-
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
|
|
42178
|
-
|
|
42179
|
-
|
|
42180
|
-
|
|
42181
|
-
onClick: () => setShowThink(!showThink),
|
|
42182
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
42183
|
-
"思考过程 ",
|
|
42184
|
-
showThink ? "▲" : "▼"
|
|
42185
|
-
] })
|
|
42186
|
-
}
|
|
42187
|
-
),
|
|
42188
|
-
showThink && hasThinkContent && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42189
|
-
"div",
|
|
42190
|
-
{
|
|
42191
|
-
style: {
|
|
42192
|
-
opacity: 0.8,
|
|
42193
|
-
borderLeft: "1px solid rgb(126, 126, 126)",
|
|
42194
|
-
paddingLeft: "12px",
|
|
42195
|
-
marginLeft: "4px",
|
|
42196
|
-
marginBottom: "16px"
|
|
42197
|
-
},
|
|
42198
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownBox, { content: thinkContent, themeMode })
|
|
42199
|
-
}
|
|
42200
|
-
),
|
|
42201
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownBox, { content: chatContent, themeMode }),
|
|
42202
|
-
message.isNewChat && showOpeningPrompts && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42203
|
-
"div",
|
|
42204
|
-
{
|
|
42205
|
-
style: {
|
|
42206
|
-
marginTop: "16px",
|
|
42207
|
-
display: "flex",
|
|
42208
|
-
gap: "8px",
|
|
42209
|
-
flexWrap: "wrap"
|
|
42210
|
-
},
|
|
42211
|
-
children: (openingPrompts && openingPrompts.length > 0 ? openingPrompts : suggested_questions).map((messageText, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42212
|
-
"span",
|
|
42213
|
-
{
|
|
42214
|
-
className: "opening-prompt-btn",
|
|
42215
|
-
onClick: () => chatSubmit(messageText),
|
|
42216
|
-
children: messageText
|
|
42257
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "comment-single-content", children: [
|
|
42258
|
+
!message.completed && message.content == "" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "comment-single-text", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "comment-single-text markdown-body", children: [
|
|
42259
|
+
hasThinkContent && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42260
|
+
"div",
|
|
42261
|
+
{
|
|
42262
|
+
style: {
|
|
42263
|
+
cursor: "pointer",
|
|
42264
|
+
color: "#333333",
|
|
42265
|
+
marginBottom: "8px",
|
|
42266
|
+
display: "flex",
|
|
42267
|
+
alignItems: "center",
|
|
42268
|
+
gap: "8px",
|
|
42269
|
+
fontSize: "14px",
|
|
42270
|
+
fontWeight: 600,
|
|
42271
|
+
userSelect: "none",
|
|
42272
|
+
WebkitUserSelect: "none",
|
|
42273
|
+
msUserSelect: "none"
|
|
42217
42274
|
},
|
|
42218
|
-
|
|
42219
|
-
|
|
42220
|
-
|
|
42221
|
-
|
|
42222
|
-
|
|
42223
|
-
|
|
42224
|
-
|
|
42225
|
-
|
|
42226
|
-
|
|
42227
|
-
|
|
42228
|
-
|
|
42229
|
-
|
|
42230
|
-
|
|
42231
|
-
|
|
42232
|
-
"
|
|
42233
|
-
|
|
42234
|
-
|
|
42235
|
-
|
|
42236
|
-
|
|
42237
|
-
|
|
42238
|
-
|
|
42239
|
-
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
|
|
42243
|
-
|
|
42244
|
-
"
|
|
42275
|
+
onClick: () => setShowThink(!showThink),
|
|
42276
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
42277
|
+
"思考过程 ",
|
|
42278
|
+
showThink ? "▲" : "▼"
|
|
42279
|
+
] })
|
|
42280
|
+
}
|
|
42281
|
+
),
|
|
42282
|
+
showThink && hasThinkContent && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42283
|
+
"div",
|
|
42284
|
+
{
|
|
42285
|
+
style: {
|
|
42286
|
+
opacity: 0.8,
|
|
42287
|
+
borderLeft: "1px solid rgb(126, 126, 126)",
|
|
42288
|
+
paddingLeft: "12px",
|
|
42289
|
+
marginLeft: "4px",
|
|
42290
|
+
marginBottom: "16px"
|
|
42291
|
+
},
|
|
42292
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownBox, { content: thinkContent, themeMode })
|
|
42293
|
+
}
|
|
42294
|
+
),
|
|
42295
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownBox, { content: chatContent, themeMode }),
|
|
42296
|
+
message.isNewChat && showOpeningPrompts && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42297
|
+
"div",
|
|
42298
|
+
{
|
|
42299
|
+
style: {
|
|
42300
|
+
marginTop: "16px",
|
|
42301
|
+
display: "flex",
|
|
42302
|
+
gap: "8px",
|
|
42303
|
+
flexWrap: "wrap"
|
|
42304
|
+
},
|
|
42305
|
+
children: (openingPrompts && openingPrompts.length > 0 ? openingPrompts : suggested_questions).map((messageText, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42306
|
+
"span",
|
|
42245
42307
|
{
|
|
42246
|
-
|
|
42247
|
-
|
|
42248
|
-
|
|
42249
|
-
|
|
42250
|
-
|
|
42251
|
-
|
|
42252
|
-
|
|
42253
|
-
|
|
42254
|
-
|
|
42255
|
-
|
|
42256
|
-
|
|
42257
|
-
|
|
42258
|
-
|
|
42259
|
-
|
|
42260
|
-
|
|
42261
|
-
|
|
42262
|
-
|
|
42263
|
-
|
|
42264
|
-
|
|
42265
|
-
|
|
42266
|
-
|
|
42267
|
-
|
|
42268
|
-
|
|
42269
|
-
|
|
42270
|
-
|
|
42271
|
-
|
|
42272
|
-
|
|
42273
|
-
|
|
42274
|
-
|
|
42275
|
-
|
|
42276
|
-
|
|
42277
|
-
|
|
42278
|
-
|
|
42279
|
-
|
|
42280
|
-
|
|
42281
|
-
|
|
42282
|
-
|
|
42283
|
-
|
|
42284
|
-
|
|
42285
|
-
|
|
42286
|
-
|
|
42287
|
-
|
|
42288
|
-
|
|
42289
|
-
|
|
42290
|
-
|
|
42308
|
+
className: "opening-prompt-btn",
|
|
42309
|
+
onClick: () => chatSubmit(messageText),
|
|
42310
|
+
children: messageText
|
|
42311
|
+
},
|
|
42312
|
+
index2
|
|
42313
|
+
))
|
|
42314
|
+
}
|
|
42315
|
+
),
|
|
42316
|
+
message.references && message.references.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42317
|
+
"div",
|
|
42318
|
+
{
|
|
42319
|
+
style: {
|
|
42320
|
+
marginTop: "16px",
|
|
42321
|
+
paddingTop: "16px",
|
|
42322
|
+
borderTop: `1px solid ${themeMode === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)"}`
|
|
42323
|
+
},
|
|
42324
|
+
children: [
|
|
42325
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42326
|
+
"div",
|
|
42327
|
+
{
|
|
42328
|
+
style: {
|
|
42329
|
+
fontSize: "14px",
|
|
42330
|
+
fontWeight: 600,
|
|
42331
|
+
marginBottom: "12px",
|
|
42332
|
+
color: themeMode === "dark" ? "#fff" : "#333"
|
|
42333
|
+
},
|
|
42334
|
+
children: "引用"
|
|
42335
|
+
}
|
|
42336
|
+
),
|
|
42337
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42338
|
+
"div",
|
|
42339
|
+
{
|
|
42340
|
+
style: {
|
|
42341
|
+
display: "flex",
|
|
42342
|
+
flexDirection: "column",
|
|
42343
|
+
gap: "12px"
|
|
42344
|
+
},
|
|
42345
|
+
children: message.references.map((ref, index2) => {
|
|
42346
|
+
const isExpanded = expandedReferences.has(index2);
|
|
42347
|
+
const toggleExpand = () => {
|
|
42348
|
+
const newSet = new Set(expandedReferences);
|
|
42349
|
+
if (isExpanded) {
|
|
42350
|
+
newSet.delete(index2);
|
|
42351
|
+
} else {
|
|
42352
|
+
newSet.add(index2);
|
|
42353
|
+
}
|
|
42354
|
+
setExpandedReferences(newSet);
|
|
42355
|
+
};
|
|
42356
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42357
|
+
"div",
|
|
42358
|
+
{
|
|
42359
|
+
style: {
|
|
42360
|
+
backgroundColor: themeMode === "dark" ? "rgba(255, 255, 255, 0.05)" : "rgba(0, 0, 0, 0.02)",
|
|
42361
|
+
borderRadius: "6px",
|
|
42362
|
+
overflow: "hidden",
|
|
42363
|
+
border: `1px solid ${themeMode === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.08)"}`
|
|
42364
|
+
},
|
|
42365
|
+
children: [
|
|
42366
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42367
|
+
"div",
|
|
42368
|
+
{
|
|
42369
|
+
style: {
|
|
42370
|
+
display: "flex",
|
|
42371
|
+
alignItems: "center",
|
|
42372
|
+
gap: "8px",
|
|
42373
|
+
padding: "12px",
|
|
42374
|
+
cursor: ref.content ? "pointer" : "default"
|
|
42375
|
+
},
|
|
42376
|
+
onClick: toggleExpand,
|
|
42377
|
+
children: [
|
|
42378
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42379
|
+
IconFile,
|
|
42380
|
+
{
|
|
42381
|
+
style: {
|
|
42382
|
+
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.7)" : "rgba(0, 0, 0, 0.6)",
|
|
42383
|
+
fontSize: "16px",
|
|
42384
|
+
flexShrink: 0
|
|
42385
|
+
}
|
|
42291
42386
|
}
|
|
42292
|
-
|
|
42293
|
-
|
|
42294
|
-
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
|
|
42298
|
-
|
|
42299
|
-
|
|
42300
|
-
|
|
42301
|
-
|
|
42302
|
-
|
|
42303
|
-
children: ref.name
|
|
42304
|
-
}
|
|
42305
|
-
),
|
|
42306
|
-
ref.content && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { flexShrink: 0 }, children: isExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42307
|
-
IconChevronUp,
|
|
42308
|
-
{
|
|
42309
|
-
style: {
|
|
42310
|
-
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.6)" : "rgba(0, 0, 0, 0.5)",
|
|
42311
|
-
fontSize: "16px"
|
|
42387
|
+
),
|
|
42388
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42389
|
+
"span",
|
|
42390
|
+
{
|
|
42391
|
+
style: {
|
|
42392
|
+
fontSize: "14px",
|
|
42393
|
+
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.9)" : "rgba(0, 0, 0, 0.8)",
|
|
42394
|
+
flex: 1,
|
|
42395
|
+
fontWeight: 500
|
|
42396
|
+
},
|
|
42397
|
+
children: ref.name
|
|
42312
42398
|
}
|
|
42313
|
-
|
|
42314
|
-
|
|
42315
|
-
|
|
42316
|
-
|
|
42317
|
-
|
|
42318
|
-
|
|
42319
|
-
|
|
42399
|
+
),
|
|
42400
|
+
ref.content && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { flexShrink: 0 }, children: isExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42401
|
+
IconChevronUp,
|
|
42402
|
+
{
|
|
42403
|
+
style: {
|
|
42404
|
+
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.6)" : "rgba(0, 0, 0, 0.5)",
|
|
42405
|
+
fontSize: "16px"
|
|
42406
|
+
}
|
|
42320
42407
|
}
|
|
42321
|
-
|
|
42322
|
-
|
|
42323
|
-
|
|
42324
|
-
|
|
42325
|
-
|
|
42326
|
-
|
|
42327
|
-
"div",
|
|
42328
|
-
{
|
|
42329
|
-
style: {
|
|
42330
|
-
padding: "0 12px 12px 12px",
|
|
42331
|
-
borderTop: `1px solid ${themeMode === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.08)"}`
|
|
42332
|
-
},
|
|
42333
|
-
children: [
|
|
42334
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42335
|
-
"div",
|
|
42336
|
-
{
|
|
42337
|
-
style: {
|
|
42338
|
-
fontSize: "13px",
|
|
42339
|
-
lineHeight: "1.6",
|
|
42340
|
-
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.8)" : "rgba(0, 0, 0, 0.7)",
|
|
42341
|
-
whiteSpace: "pre-wrap",
|
|
42342
|
-
wordBreak: "break-word",
|
|
42343
|
-
paddingTop: "12px",
|
|
42344
|
-
marginBottom: ref.dataset_id && ref.id ? "12px" : "0"
|
|
42345
|
-
},
|
|
42346
|
-
children: ref.content
|
|
42347
|
-
}
|
|
42348
|
-
),
|
|
42349
|
-
ref.dataset_id && ref.id && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42350
|
-
"div",
|
|
42351
|
-
{
|
|
42352
|
-
style: {
|
|
42353
|
-
display: "flex",
|
|
42354
|
-
justifyContent: "flex-end"
|
|
42355
|
-
},
|
|
42356
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42357
|
-
"div",
|
|
42358
|
-
{
|
|
42359
|
-
style: {
|
|
42360
|
-
display: "flex",
|
|
42361
|
-
alignItems: "center",
|
|
42362
|
-
gap: "4px",
|
|
42363
|
-
fontSize: "13px",
|
|
42364
|
-
color: themeMode === "dark" ? "rgba(100, 181, 246, 1)" : "rgba(25, 118, 210, 1)",
|
|
42365
|
-
cursor: "pointer",
|
|
42366
|
-
fontWeight: 500
|
|
42367
|
-
},
|
|
42368
|
-
onClick: (e) => {
|
|
42369
|
-
e.stopPropagation();
|
|
42370
|
-
const baseUrl = CommonUtil.getDifyApiBaseUrl();
|
|
42371
|
-
const knowledgeBaseUrl = `${baseUrl.replace(/\/api$/, "")}/datasets/${ref.dataset_id}/documents/${ref.id}`;
|
|
42372
|
-
window.open(knowledgeBaseUrl, "_blank");
|
|
42373
|
-
},
|
|
42374
|
-
onMouseEnter: (e) => {
|
|
42375
|
-
e.currentTarget.style.opacity = "0.8";
|
|
42376
|
-
},
|
|
42377
|
-
onMouseLeave: (e) => {
|
|
42378
|
-
e.currentTarget.style.opacity = "1";
|
|
42379
|
-
},
|
|
42380
|
-
children: [
|
|
42381
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "跳转至知识库" }),
|
|
42382
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42383
|
-
IconArrowRight,
|
|
42384
|
-
{
|
|
42385
|
-
style: {
|
|
42386
|
-
fontSize: "14px"
|
|
42387
|
-
}
|
|
42388
|
-
}
|
|
42389
|
-
)
|
|
42390
|
-
]
|
|
42408
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42409
|
+
IconChevronDown,
|
|
42410
|
+
{
|
|
42411
|
+
style: {
|
|
42412
|
+
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.6)" : "rgba(0, 0, 0, 0.5)",
|
|
42413
|
+
fontSize: "16px"
|
|
42391
42414
|
}
|
|
42392
|
-
|
|
42393
|
-
}
|
|
42394
|
-
|
|
42395
|
-
|
|
42396
|
-
|
|
42397
|
-
|
|
42398
|
-
|
|
42399
|
-
|
|
42400
|
-
|
|
42401
|
-
|
|
42402
|
-
|
|
42415
|
+
}
|
|
42416
|
+
) })
|
|
42417
|
+
]
|
|
42418
|
+
}
|
|
42419
|
+
),
|
|
42420
|
+
isExpanded && ref.content && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42421
|
+
"div",
|
|
42422
|
+
{
|
|
42423
|
+
style: {
|
|
42424
|
+
padding: "0 12px 12px 12px",
|
|
42425
|
+
borderTop: `1px solid ${themeMode === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.08)"}`
|
|
42426
|
+
},
|
|
42427
|
+
children: [
|
|
42428
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42429
|
+
"div",
|
|
42430
|
+
{
|
|
42431
|
+
style: {
|
|
42432
|
+
fontSize: "13px",
|
|
42433
|
+
lineHeight: "1.6",
|
|
42434
|
+
color: themeMode === "dark" ? "rgba(255, 255, 255, 0.8)" : "rgba(0, 0, 0, 0.7)",
|
|
42435
|
+
whiteSpace: "pre-wrap",
|
|
42436
|
+
wordBreak: "break-word",
|
|
42437
|
+
paddingTop: "12px",
|
|
42438
|
+
marginBottom: ref.dataset_id && ref.id ? "12px" : "0"
|
|
42439
|
+
},
|
|
42440
|
+
children: ref.content
|
|
42441
|
+
}
|
|
42442
|
+
),
|
|
42443
|
+
ref.dataset_id && ref.id && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42444
|
+
"div",
|
|
42445
|
+
{
|
|
42446
|
+
style: {
|
|
42447
|
+
display: "flex",
|
|
42448
|
+
justifyContent: "flex-end"
|
|
42449
|
+
},
|
|
42450
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
42451
|
+
"div",
|
|
42452
|
+
{
|
|
42453
|
+
style: {
|
|
42454
|
+
display: "flex",
|
|
42455
|
+
alignItems: "center",
|
|
42456
|
+
gap: "4px",
|
|
42457
|
+
fontSize: "13px",
|
|
42458
|
+
color: themeMode === "dark" ? "rgba(100, 181, 246, 1)" : "rgba(25, 118, 210, 1)",
|
|
42459
|
+
cursor: "pointer",
|
|
42460
|
+
fontWeight: 500
|
|
42461
|
+
},
|
|
42462
|
+
onClick: (e) => {
|
|
42463
|
+
e.stopPropagation();
|
|
42464
|
+
const baseUrl = CommonUtil.getDifyApiBaseUrl();
|
|
42465
|
+
const knowledgeBaseUrl = `${baseUrl.replace(/\/api$/, "")}/datasets/${ref.dataset_id}/documents/${ref.id}`;
|
|
42466
|
+
window.open(knowledgeBaseUrl, "_blank");
|
|
42467
|
+
},
|
|
42468
|
+
onMouseEnter: (e) => {
|
|
42469
|
+
e.currentTarget.style.opacity = "0.8";
|
|
42470
|
+
},
|
|
42471
|
+
onMouseLeave: (e) => {
|
|
42472
|
+
e.currentTarget.style.opacity = "1";
|
|
42473
|
+
},
|
|
42474
|
+
children: [
|
|
42475
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "跳转至知识库" }),
|
|
42476
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42477
|
+
IconArrowRight,
|
|
42478
|
+
{
|
|
42479
|
+
style: {
|
|
42480
|
+
fontSize: "14px"
|
|
42481
|
+
}
|
|
42482
|
+
}
|
|
42483
|
+
)
|
|
42484
|
+
]
|
|
42485
|
+
}
|
|
42486
|
+
)
|
|
42487
|
+
}
|
|
42488
|
+
)
|
|
42489
|
+
]
|
|
42490
|
+
}
|
|
42491
|
+
)
|
|
42492
|
+
]
|
|
42493
|
+
},
|
|
42494
|
+
index2
|
|
42495
|
+
);
|
|
42496
|
+
})
|
|
42497
|
+
}
|
|
42498
|
+
)
|
|
42499
|
+
]
|
|
42500
|
+
}
|
|
42501
|
+
)
|
|
42502
|
+
] }),
|
|
42503
|
+
message.completed && !message.isNewChat && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "comment-single-action-buttons", children: [
|
|
42504
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { content: "复制", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42505
|
+
Button,
|
|
42506
|
+
{
|
|
42507
|
+
theme: "borderless",
|
|
42508
|
+
type: "tertiary",
|
|
42509
|
+
size: "small",
|
|
42510
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCopyStroked, {}),
|
|
42511
|
+
onClick: (e) => {
|
|
42512
|
+
e.stopPropagation();
|
|
42513
|
+
copyCommentChatItem(message.id);
|
|
42514
|
+
},
|
|
42515
|
+
style: {
|
|
42516
|
+
width: "28px",
|
|
42517
|
+
height: "28px",
|
|
42518
|
+
minWidth: "28px",
|
|
42519
|
+
padding: "0",
|
|
42520
|
+
borderRadius: "8px",
|
|
42521
|
+
background: "#ffffff",
|
|
42522
|
+
border: "1px solid rgba(180, 197, 226, 0.6)",
|
|
42523
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)"
|
|
42524
|
+
},
|
|
42525
|
+
className: "comment-single-action-button"
|
|
42526
|
+
}
|
|
42527
|
+
) }),
|
|
42528
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { content: "重写", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42529
|
+
Button,
|
|
42530
|
+
{
|
|
42531
|
+
theme: "borderless",
|
|
42532
|
+
type: "tertiary",
|
|
42533
|
+
size: "small",
|
|
42534
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconRefresh, {}),
|
|
42535
|
+
onClick: async (e) => {
|
|
42536
|
+
e.stopPropagation();
|
|
42537
|
+
if (regenerateMessage) {
|
|
42538
|
+
try {
|
|
42539
|
+
await regenerateMessage(message.id);
|
|
42540
|
+
} catch (error) {
|
|
42541
|
+
console.error("重写失败:", error);
|
|
42542
|
+
}
|
|
42403
42543
|
}
|
|
42404
|
-
|
|
42405
|
-
|
|
42406
|
-
|
|
42407
|
-
|
|
42408
|
-
|
|
42544
|
+
},
|
|
42545
|
+
style: {
|
|
42546
|
+
width: "28px",
|
|
42547
|
+
height: "28px",
|
|
42548
|
+
minWidth: "28px",
|
|
42549
|
+
padding: "0",
|
|
42550
|
+
borderRadius: "8px",
|
|
42551
|
+
background: "#ffffff",
|
|
42552
|
+
border: "1px solid rgba(180, 197, 226, 0.6)",
|
|
42553
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)"
|
|
42554
|
+
},
|
|
42555
|
+
className: "comment-single-action-button"
|
|
42556
|
+
}
|
|
42557
|
+
) }),
|
|
42558
|
+
!isDisliked && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { content: "点赞", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42559
|
+
Button,
|
|
42560
|
+
{
|
|
42561
|
+
theme: "borderless",
|
|
42562
|
+
type: "tertiary",
|
|
42563
|
+
size: "small",
|
|
42564
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconLikeThumb, {}),
|
|
42565
|
+
onClick: async (e) => {
|
|
42566
|
+
e.stopPropagation();
|
|
42567
|
+
const newLikedState = !isLiked;
|
|
42568
|
+
setIsLiked(newLikedState);
|
|
42569
|
+
if (newLikedState && isDisliked) {
|
|
42570
|
+
setIsDisliked(false);
|
|
42571
|
+
}
|
|
42572
|
+
if (likeMessage) {
|
|
42573
|
+
try {
|
|
42574
|
+
await likeMessage(message.id);
|
|
42575
|
+
} catch (error) {
|
|
42576
|
+
setIsLiked(!newLikedState);
|
|
42577
|
+
console.error("点赞失败:", error);
|
|
42578
|
+
}
|
|
42579
|
+
}
|
|
42580
|
+
},
|
|
42581
|
+
style: {
|
|
42582
|
+
color: isLiked ? "#ffc107" : "rgba(0, 0, 0, 0.6)",
|
|
42583
|
+
width: "28px",
|
|
42584
|
+
height: "28px",
|
|
42585
|
+
minWidth: "28px",
|
|
42586
|
+
padding: "0",
|
|
42587
|
+
borderRadius: "8px",
|
|
42588
|
+
background: "#ffffff",
|
|
42589
|
+
border: "1px solid rgba(180, 197, 226, 0.6)",
|
|
42590
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)"
|
|
42591
|
+
},
|
|
42592
|
+
className: "comment-single-action-button"
|
|
42593
|
+
}
|
|
42594
|
+
) }),
|
|
42595
|
+
!isLiked && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { content: "点踩", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42596
|
+
Button,
|
|
42597
|
+
{
|
|
42598
|
+
theme: "borderless",
|
|
42599
|
+
type: "tertiary",
|
|
42600
|
+
size: "small",
|
|
42601
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(IconLikeThumb, { style: { transform: "rotate(180deg)" } }),
|
|
42602
|
+
onClick: async (e) => {
|
|
42603
|
+
e.stopPropagation();
|
|
42604
|
+
const newDislikedState = !isDisliked;
|
|
42605
|
+
setIsDisliked(newDislikedState);
|
|
42606
|
+
if (newDislikedState && isLiked) {
|
|
42607
|
+
setIsLiked(false);
|
|
42608
|
+
}
|
|
42609
|
+
if (dislikeMessage) {
|
|
42610
|
+
try {
|
|
42611
|
+
await dislikeMessage(message.id);
|
|
42612
|
+
} catch (error) {
|
|
42613
|
+
setIsDisliked(!newDislikedState);
|
|
42614
|
+
console.error("点踩失败:", error);
|
|
42615
|
+
}
|
|
42616
|
+
}
|
|
42617
|
+
},
|
|
42618
|
+
style: {
|
|
42619
|
+
color: isDisliked ? "#f56565" : "rgba(0, 0, 0, 0.6)",
|
|
42620
|
+
width: "28px",
|
|
42621
|
+
height: "28px",
|
|
42622
|
+
minWidth: "28px",
|
|
42623
|
+
padding: "0",
|
|
42624
|
+
borderRadius: "8px",
|
|
42625
|
+
background: "#ffffff",
|
|
42626
|
+
border: "1px solid rgba(180, 197, 226, 0.6)",
|
|
42627
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)"
|
|
42628
|
+
},
|
|
42629
|
+
className: "comment-single-action-button"
|
|
42630
|
+
}
|
|
42631
|
+
) })
|
|
42632
|
+
] })
|
|
42633
|
+
] }),
|
|
42409
42634
|
!message.isNewChat && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `csh-${message.id}`, className: "comment-single-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42410
42635
|
Dropdown,
|
|
42411
42636
|
{
|
|
@@ -44685,11 +44910,20 @@ function CommentIndex({
|
|
|
44685
44910
|
};
|
|
44686
44911
|
});
|
|
44687
44912
|
}
|
|
44913
|
+
let serverMessageId = currentMessage.serverMessageId;
|
|
44914
|
+
if (parsed.message_id && !serverMessageId) {
|
|
44915
|
+
serverMessageId = parsed.message_id;
|
|
44916
|
+
}
|
|
44688
44917
|
newChatList[findIndex] = {
|
|
44689
44918
|
...currentMessage,
|
|
44690
44919
|
completed: true,
|
|
44691
|
-
references: references.length > 0 ? references : currentMessage.references
|
|
44920
|
+
references: references.length > 0 ? references : currentMessage.references,
|
|
44921
|
+
serverMessageId: serverMessageId || currentMessage.serverMessageId
|
|
44692
44922
|
};
|
|
44923
|
+
if (serverMessageId && serverMessageId !== currentMessage.serverMessageId && currentCommentSessionId) {
|
|
44924
|
+
LocalForageService.setItem(`chat_list_${currentCommentSessionId}`, newChatList).catch((error) => {
|
|
44925
|
+
});
|
|
44926
|
+
}
|
|
44693
44927
|
return newChatList;
|
|
44694
44928
|
});
|
|
44695
44929
|
setTimeout(() => {
|
|
@@ -44718,6 +44952,24 @@ function CommentIndex({
|
|
|
44718
44952
|
}).catch((error) => {
|
|
44719
44953
|
});
|
|
44720
44954
|
}
|
|
44955
|
+
if (parsed.message_id && currentCommentSessionId) {
|
|
44956
|
+
setCommentChatList((chatList) => {
|
|
44957
|
+
const findIndex = chatList.findIndex(
|
|
44958
|
+
(message) => message.id === botMessage.id
|
|
44959
|
+
);
|
|
44960
|
+
if (findIndex < 0) return chatList;
|
|
44961
|
+
const currentMessage = chatList[findIndex];
|
|
44962
|
+
if (currentMessage.serverMessageId) return chatList;
|
|
44963
|
+
const newChatList = [...chatList];
|
|
44964
|
+
newChatList[findIndex] = {
|
|
44965
|
+
...currentMessage,
|
|
44966
|
+
serverMessageId: parsed.message_id
|
|
44967
|
+
};
|
|
44968
|
+
LocalForageService.setItem(`chat_list_${currentCommentSessionId}`, newChatList).catch((error) => {
|
|
44969
|
+
});
|
|
44970
|
+
return newChatList;
|
|
44971
|
+
});
|
|
44972
|
+
}
|
|
44721
44973
|
if (parsed.answer) {
|
|
44722
44974
|
setCommentChatList((chatList) => {
|
|
44723
44975
|
const findIndex = chatList.findIndex(
|
|
@@ -45632,6 +45884,172 @@ function CommentIndex({
|
|
|
45632
45884
|
return chatList;
|
|
45633
45885
|
});
|
|
45634
45886
|
}, []);
|
|
45887
|
+
const likeMessage = useCallback(async (messageId) => {
|
|
45888
|
+
const message = commentChatList.find((msg) => msg.id === messageId);
|
|
45889
|
+
if (!message || message.type !== "bot") {
|
|
45890
|
+
Toast.warning({
|
|
45891
|
+
content: "无法找到该消息",
|
|
45892
|
+
showClose: false,
|
|
45893
|
+
duration: 2
|
|
45894
|
+
});
|
|
45895
|
+
return;
|
|
45896
|
+
}
|
|
45897
|
+
const serverMessageId = message.serverMessageId || messageId;
|
|
45898
|
+
const newLikedState = !message.isLiked;
|
|
45899
|
+
const requestBody = {
|
|
45900
|
+
rating: newLikedState ? "like" : null
|
|
45901
|
+
};
|
|
45902
|
+
try {
|
|
45903
|
+
let preApi = location.hostname === "localhost" ? "http://111.6.44.42:30001" : location.origin;
|
|
45904
|
+
const response = await fetch(`${preApi}/prod-api/v1/messages/${serverMessageId}/feedbacks`, {
|
|
45905
|
+
method: "POST",
|
|
45906
|
+
headers: {
|
|
45907
|
+
"Content-Type": "application/json"
|
|
45908
|
+
},
|
|
45909
|
+
body: JSON.stringify(requestBody)
|
|
45910
|
+
});
|
|
45911
|
+
if (!response.ok) {
|
|
45912
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45913
|
+
}
|
|
45914
|
+
setCommentChatList((chatList) => {
|
|
45915
|
+
const newChatList = chatList.map((msg) => {
|
|
45916
|
+
if (msg.id === messageId) {
|
|
45917
|
+
return {
|
|
45918
|
+
...msg,
|
|
45919
|
+
isLiked: newLikedState,
|
|
45920
|
+
// 如果点赞,取消点踩
|
|
45921
|
+
isDisliked: newLikedState ? false : msg.isDisliked
|
|
45922
|
+
};
|
|
45923
|
+
}
|
|
45924
|
+
return msg;
|
|
45925
|
+
});
|
|
45926
|
+
if (currentCommentSessionId) {
|
|
45927
|
+
LocalForageService.setItem(`chat_list_${currentCommentSessionId}`, newChatList);
|
|
45928
|
+
}
|
|
45929
|
+
return newChatList;
|
|
45930
|
+
});
|
|
45931
|
+
Toast.success({
|
|
45932
|
+
content: newLikedState ? "点赞成功" : "已取消点赞",
|
|
45933
|
+
showClose: false,
|
|
45934
|
+
duration: 2
|
|
45935
|
+
});
|
|
45936
|
+
} catch (error) {
|
|
45937
|
+
console.error("点赞失败:", error);
|
|
45938
|
+
Toast.error({
|
|
45939
|
+
content: "点赞失败,请稍后重试",
|
|
45940
|
+
showClose: false,
|
|
45941
|
+
duration: 2
|
|
45942
|
+
});
|
|
45943
|
+
throw error;
|
|
45944
|
+
}
|
|
45945
|
+
}, [commentChatList, currentCommentSessionId, currentCommentSession, agentList, selectedAgentId, sessionSetting]);
|
|
45946
|
+
const dislikeMessage = useCallback(async (messageId) => {
|
|
45947
|
+
const message = commentChatList.find((msg) => msg.id === messageId);
|
|
45948
|
+
if (!message || message.type !== "bot") {
|
|
45949
|
+
Toast.warning({
|
|
45950
|
+
content: "无法找到该消息",
|
|
45951
|
+
showClose: false,
|
|
45952
|
+
duration: 2
|
|
45953
|
+
});
|
|
45954
|
+
return;
|
|
45955
|
+
}
|
|
45956
|
+
const serverMessageId = message.serverMessageId || messageId;
|
|
45957
|
+
const newDislikedState = !message.isDisliked;
|
|
45958
|
+
const requestBody = {
|
|
45959
|
+
rating: newDislikedState ? "dislike" : null
|
|
45960
|
+
};
|
|
45961
|
+
try {
|
|
45962
|
+
let preApi = location.hostname === "localhost" ? "http://111.6.44.42:30001" : location.origin;
|
|
45963
|
+
const response = await fetch(`${preApi}/prod-api/v1/messages/${serverMessageId}/feedbacks`, {
|
|
45964
|
+
method: "POST",
|
|
45965
|
+
headers: {
|
|
45966
|
+
"Content-Type": "application/json"
|
|
45967
|
+
},
|
|
45968
|
+
body: JSON.stringify(requestBody)
|
|
45969
|
+
});
|
|
45970
|
+
if (!response.ok) {
|
|
45971
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45972
|
+
}
|
|
45973
|
+
setCommentChatList((chatList) => {
|
|
45974
|
+
const newChatList = chatList.map((msg) => {
|
|
45975
|
+
if (msg.id === messageId) {
|
|
45976
|
+
return {
|
|
45977
|
+
...msg,
|
|
45978
|
+
isDisliked: newDislikedState,
|
|
45979
|
+
// 如果点踩,取消点赞
|
|
45980
|
+
isLiked: newDislikedState ? false : msg.isLiked
|
|
45981
|
+
};
|
|
45982
|
+
}
|
|
45983
|
+
return msg;
|
|
45984
|
+
});
|
|
45985
|
+
if (currentCommentSessionId) {
|
|
45986
|
+
LocalForageService.setItem(`chat_list_${currentCommentSessionId}`, newChatList);
|
|
45987
|
+
}
|
|
45988
|
+
return newChatList;
|
|
45989
|
+
});
|
|
45990
|
+
Toast.success({
|
|
45991
|
+
content: newDislikedState ? "点踩成功" : "已取消点踩",
|
|
45992
|
+
showClose: false,
|
|
45993
|
+
duration: 2
|
|
45994
|
+
});
|
|
45995
|
+
} catch (error) {
|
|
45996
|
+
console.error("点踩失败:", error);
|
|
45997
|
+
Toast.error({
|
|
45998
|
+
content: "点踩失败,请稍后重试",
|
|
45999
|
+
showClose: false,
|
|
46000
|
+
duration: 2
|
|
46001
|
+
});
|
|
46002
|
+
throw error;
|
|
46003
|
+
}
|
|
46004
|
+
}, [commentChatList, currentCommentSessionId, currentCommentSession, agentList, selectedAgentId, sessionSetting]);
|
|
46005
|
+
const regenerateMessage = useCallback(async (messageId) => {
|
|
46006
|
+
if (!currentCommentSessionId) {
|
|
46007
|
+
Toast.warning({
|
|
46008
|
+
content: "请先创建对话",
|
|
46009
|
+
showClose: false,
|
|
46010
|
+
duration: 2
|
|
46011
|
+
});
|
|
46012
|
+
return;
|
|
46013
|
+
}
|
|
46014
|
+
const messageIndex = commentChatList.findIndex((msg) => msg.id === messageId);
|
|
46015
|
+
if (messageIndex < 0) {
|
|
46016
|
+
Toast.warning({
|
|
46017
|
+
content: "无法找到该消息",
|
|
46018
|
+
showClose: false,
|
|
46019
|
+
duration: 2
|
|
46020
|
+
});
|
|
46021
|
+
return;
|
|
46022
|
+
}
|
|
46023
|
+
const botMessage = commentChatList[messageIndex];
|
|
46024
|
+
if (botMessage.type !== "bot") {
|
|
46025
|
+
Toast.warning({
|
|
46026
|
+
content: "只能重写AI回复的消息",
|
|
46027
|
+
showClose: false,
|
|
46028
|
+
duration: 2
|
|
46029
|
+
});
|
|
46030
|
+
return;
|
|
46031
|
+
}
|
|
46032
|
+
const userMessage = commentChatList[messageIndex - 1];
|
|
46033
|
+
if (!userMessage || userMessage.type !== "user") {
|
|
46034
|
+
Toast.warning({
|
|
46035
|
+
content: "无法找到对应的用户消息",
|
|
46036
|
+
showClose: false,
|
|
46037
|
+
duration: 2
|
|
46038
|
+
});
|
|
46039
|
+
return;
|
|
46040
|
+
}
|
|
46041
|
+
setCommentChatList((chatList) => {
|
|
46042
|
+
const newChatList = [...chatList];
|
|
46043
|
+
newChatList.splice(messageIndex - 1, 2);
|
|
46044
|
+
if (currentCommentSessionId) {
|
|
46045
|
+
LocalForageService.setItem(`chat_list_${currentCommentSessionId}`, newChatList);
|
|
46046
|
+
}
|
|
46047
|
+
return newChatList;
|
|
46048
|
+
});
|
|
46049
|
+
setTimeout(() => {
|
|
46050
|
+
chatSubmit(userMessage.content);
|
|
46051
|
+
}, 100);
|
|
46052
|
+
}, [commentChatList, currentCommentSessionId, chatSubmit]);
|
|
45635
46053
|
const [updateChatVisible, setUpdateChatVisible] = useState(false);
|
|
45636
46054
|
const [chatToUpdate, setChatToUpdate] = useState();
|
|
45637
46055
|
const chatFormRef = createRef();
|
|
@@ -46108,6 +46526,9 @@ function CommentIndex({
|
|
|
46108
46526
|
chatSubmit,
|
|
46109
46527
|
themeMode,
|
|
46110
46528
|
agentApiKey: (_a3 = agentList.find((agent) => agent.id === selectedAgentId)) == null ? void 0 : _a3.apiKeys,
|
|
46529
|
+
likeMessage,
|
|
46530
|
+
dislikeMessage,
|
|
46531
|
+
regenerateMessage,
|
|
46111
46532
|
openingPrompts: (() => {
|
|
46112
46533
|
var _a5, _b3;
|
|
46113
46534
|
const sessionPrompts = currentCommentSession == null ? void 0 : currentCommentSession.openingPrompts;
|
|
@@ -46407,7 +46828,7 @@ const BlockEdit = ({
|
|
|
46407
46828
|
const initVueEditor = async () => {
|
|
46408
46829
|
if (editorRef.current) {
|
|
46409
46830
|
try {
|
|
46410
|
-
const BlockNoteEditorModule = await import("./index.es-
|
|
46831
|
+
const BlockNoteEditorModule = await import("./index.es-D77mvuFI.js");
|
|
46411
46832
|
const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
|
|
46412
46833
|
const theme = {
|
|
46413
46834
|
colors: {
|
|
@@ -47363,7 +47784,7 @@ const AiBlockEdit = ({
|
|
|
47363
47784
|
const initVueEditor = async () => {
|
|
47364
47785
|
if (editorRef.current) {
|
|
47365
47786
|
try {
|
|
47366
|
-
const BlockNoteEditorModule = await import("./index.es-
|
|
47787
|
+
const BlockNoteEditorModule = await import("./index.es-D77mvuFI.js");
|
|
47367
47788
|
const BlockNoteEditor = BlockNoteEditorModule.BlockNoteEditor;
|
|
47368
47789
|
const theme = {
|
|
47369
47790
|
colors: {
|
|
@@ -47945,10 +48366,17 @@ const AiBlockEdit = ({
|
|
|
47945
48366
|
getHistoryFromIndexedDB();
|
|
47946
48367
|
};
|
|
47947
48368
|
const handleRegenerate = () => {
|
|
47948
|
-
|
|
47949
|
-
|
|
47950
|
-
|
|
48369
|
+
if (!onRegenerate) {
|
|
48370
|
+
return;
|
|
48371
|
+
}
|
|
48372
|
+
let item = historyList.find(
|
|
48373
|
+
(item2) => item2.conversationId == currentConversationId
|
|
48374
|
+
);
|
|
48375
|
+
if (!item) {
|
|
48376
|
+
Toast.error("未找到历史记录");
|
|
48377
|
+
return;
|
|
47951
48378
|
}
|
|
48379
|
+
onRegenerate(item);
|
|
47952
48380
|
};
|
|
47953
48381
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
47954
48382
|
"div",
|
|
@@ -48405,7 +48833,7 @@ class BasePromptTemplate extends Runnable {
|
|
|
48405
48833
|
return PromptTemplate2.deserialize({ ...data, _type: "prompt" });
|
|
48406
48834
|
}
|
|
48407
48835
|
case "few_shot": {
|
|
48408
|
-
const { FewShotPromptTemplate } = await import("./few_shot-
|
|
48836
|
+
const { FewShotPromptTemplate } = await import("./few_shot-w2yEuYBx.js");
|
|
48409
48837
|
return FewShotPromptTemplate.deserialize(data);
|
|
48410
48838
|
}
|
|
48411
48839
|
default:
|
|
@@ -49977,35 +50405,35 @@ class BaseChain extends BaseLangChain {
|
|
|
49977
50405
|
static async deserialize(data, values = {}) {
|
|
49978
50406
|
switch (data._type) {
|
|
49979
50407
|
case "llm_chain": {
|
|
49980
|
-
const { LLMChain } = await import("./llm_chain-
|
|
50408
|
+
const { LLMChain } = await import("./llm_chain-C-9mmcVX.js");
|
|
49981
50409
|
return LLMChain.deserialize(data);
|
|
49982
50410
|
}
|
|
49983
50411
|
case "sequential_chain": {
|
|
49984
|
-
const { SequentialChain } = await import("./sequential_chain-
|
|
50412
|
+
const { SequentialChain } = await import("./sequential_chain-DP94xDnI.js");
|
|
49985
50413
|
return SequentialChain.deserialize(data);
|
|
49986
50414
|
}
|
|
49987
50415
|
case "simple_sequential_chain": {
|
|
49988
|
-
const { SimpleSequentialChain } = await import("./sequential_chain-
|
|
50416
|
+
const { SimpleSequentialChain } = await import("./sequential_chain-DP94xDnI.js");
|
|
49989
50417
|
return SimpleSequentialChain.deserialize(data);
|
|
49990
50418
|
}
|
|
49991
50419
|
case "stuff_documents_chain": {
|
|
49992
|
-
const { StuffDocumentsChain } = await import("./combine_docs_chain-
|
|
50420
|
+
const { StuffDocumentsChain } = await import("./combine_docs_chain-D_BlYVy7.js");
|
|
49993
50421
|
return StuffDocumentsChain.deserialize(data);
|
|
49994
50422
|
}
|
|
49995
50423
|
case "map_reduce_documents_chain": {
|
|
49996
|
-
const { MapReduceDocumentsChain } = await import("./combine_docs_chain-
|
|
50424
|
+
const { MapReduceDocumentsChain } = await import("./combine_docs_chain-D_BlYVy7.js");
|
|
49997
50425
|
return MapReduceDocumentsChain.deserialize(data);
|
|
49998
50426
|
}
|
|
49999
50427
|
case "refine_documents_chain": {
|
|
50000
|
-
const { RefineDocumentsChain } = await import("./combine_docs_chain-
|
|
50428
|
+
const { RefineDocumentsChain } = await import("./combine_docs_chain-D_BlYVy7.js");
|
|
50001
50429
|
return RefineDocumentsChain.deserialize(data);
|
|
50002
50430
|
}
|
|
50003
50431
|
case "vector_db_qa": {
|
|
50004
|
-
const { VectorDBQAChain } = await import("./vector_db_qa-
|
|
50432
|
+
const { VectorDBQAChain } = await import("./vector_db_qa-jcfmC8oz.js");
|
|
50005
50433
|
return VectorDBQAChain.deserialize(data, values);
|
|
50006
50434
|
}
|
|
50007
50435
|
case "api_chain": {
|
|
50008
|
-
const { APIChain } = await import("./api_chain-
|
|
50436
|
+
const { APIChain } = await import("./api_chain-_gAY_Ff4.js");
|
|
50009
50437
|
return APIChain.deserialize(data);
|
|
50010
50438
|
}
|
|
50011
50439
|
default:
|