@zero-library/chat-copilot 3.1.27 → 3.1.28
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/index.cjs.js +48 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +49 -37
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, ShareAltOutlined, DeleteOutlined, RedoOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
|
|
2
2
|
import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
|
|
3
|
-
import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, useWebSocket, isObject, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, transforms,
|
|
3
|
+
import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, useWebSocket, isObject, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, deepCopy, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
|
|
4
4
|
import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, Tabs, List, Upload, Popconfirm, Card, Table, Progress as Progress$1 } from 'antd';
|
|
5
5
|
import * as React10 from 'react';
|
|
6
6
|
import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback, useLayoutEffect } from 'react';
|
|
@@ -1160,18 +1160,20 @@ function createChatStore() {
|
|
|
1160
1160
|
const agent = proxy({
|
|
1161
1161
|
/** 当前智能体 */
|
|
1162
1162
|
agentInfo: {},
|
|
1163
|
-
model: {
|
|
1164
|
-
modelName: "",
|
|
1165
|
-
providerName: "",
|
|
1166
|
-
reasoning: true
|
|
1167
|
-
},
|
|
1168
1163
|
/** 智能体加载状态 */
|
|
1169
1164
|
loading: false
|
|
1170
1165
|
});
|
|
1171
1166
|
const setAgentModel = (updater) => {
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
|
|
1167
|
+
const prevModel = agent.agentInfo.spec?.model || {
|
|
1168
|
+
modelName: "",
|
|
1169
|
+
providerName: "",
|
|
1170
|
+
reasoning: true
|
|
1171
|
+
};
|
|
1172
|
+
const nextPatch = typeof updater === "function" ? updater(prevModel) : updater;
|
|
1173
|
+
const nextSpec = deepCopy(agent.agentInfo.spec || {});
|
|
1174
|
+
nextSpec.model = { ...prevModel, ...nextPatch };
|
|
1175
|
+
agent.agentInfo.spec = nextSpec;
|
|
1176
|
+
config.hooks?.onAfterSwitchModel?.(agent.agentInfo.spec.model);
|
|
1175
1177
|
};
|
|
1176
1178
|
const getUserInput = async (agentId) => {
|
|
1177
1179
|
agent.loading = true;
|
|
@@ -1200,16 +1202,11 @@ function createChatStore() {
|
|
|
1200
1202
|
}
|
|
1201
1203
|
};
|
|
1202
1204
|
const setAgent = async (agentInfo) => {
|
|
1203
|
-
if (!agent.agentInfo.id || agent.agentInfo.id !== agentInfo.id) {
|
|
1205
|
+
if (!agent.agentInfo.id && !agentInfo.updatedAt || agent.agentInfo.id !== agentInfo.id) {
|
|
1204
1206
|
await getAgentInfo(agentInfo.id);
|
|
1205
1207
|
}
|
|
1206
1208
|
agent.agentInfo = { ...agent.agentInfo, ...agentInfo };
|
|
1207
|
-
if (
|
|
1208
|
-
setAgentModel({
|
|
1209
|
-
modelName: agent.agentInfo.spec?.model?.modelName || "",
|
|
1210
|
-
providerName: agent.agentInfo.spec?.model?.providerName || ""
|
|
1211
|
-
});
|
|
1212
|
-
} else if (config.layout.userInput) {
|
|
1209
|
+
if (config.layout.userInput) {
|
|
1213
1210
|
await getUserInput(agent.agentInfo.id);
|
|
1214
1211
|
}
|
|
1215
1212
|
};
|
|
@@ -2044,7 +2041,7 @@ function createChatStore() {
|
|
|
2044
2041
|
files,
|
|
2045
2042
|
spec: {
|
|
2046
2043
|
...conversation.active.spec,
|
|
2047
|
-
model: agent.model
|
|
2044
|
+
model: agent.agentInfo.spec?.model
|
|
2048
2045
|
},
|
|
2049
2046
|
stream: true,
|
|
2050
2047
|
responseMode: 2
|
|
@@ -5992,6 +5989,23 @@ var ModelSelect_default = ({}) => {
|
|
|
5992
5989
|
const chatStore = useChatStore();
|
|
5993
5990
|
const agentState = useSnapshot(chatStore.agent);
|
|
5994
5991
|
const [models, setModels] = useState([]);
|
|
5992
|
+
const currentModel = agentState.agentInfo.spec?.model;
|
|
5993
|
+
const updateAgentModel = useCallback(
|
|
5994
|
+
(model) => {
|
|
5995
|
+
const nextAgentInfo = deepCopy(agentState.agentInfo || {});
|
|
5996
|
+
const nextSpec = deepCopy(agentState.agentInfo.spec || {});
|
|
5997
|
+
nextSpec.model = {
|
|
5998
|
+
modelName: "",
|
|
5999
|
+
providerName: "",
|
|
6000
|
+
reasoning: true,
|
|
6001
|
+
...nextSpec.model || {},
|
|
6002
|
+
...model
|
|
6003
|
+
};
|
|
6004
|
+
nextAgentInfo.spec = nextSpec;
|
|
6005
|
+
chatStore.setAgent(nextAgentInfo);
|
|
6006
|
+
},
|
|
6007
|
+
[agentState.agentInfo, chatStore]
|
|
6008
|
+
);
|
|
5995
6009
|
const modelOptions = models.map((item) => ({
|
|
5996
6010
|
label: item.providerLabel || item.providerName,
|
|
5997
6011
|
title: item.providerLabel || item.providerName,
|
|
@@ -6005,24 +6019,10 @@ var ModelSelect_default = ({}) => {
|
|
|
6005
6019
|
icon: model.icon
|
|
6006
6020
|
}))
|
|
6007
6021
|
}));
|
|
6008
|
-
const
|
|
6009
|
-
const selectedProvider = hasSelectedModelConfig ? modelOptions.find((item) => item.value === agentState.model.providerName) : void 0;
|
|
6010
|
-
const selectedModel = selectedProvider?.options.find((item) => item.modelName === agentState.model.modelName);
|
|
6011
|
-
const selectedModelValue = selectedModel?.value;
|
|
6012
|
-
useEffect(() => {
|
|
6013
|
-
const shouldUseDefaultModel = !hasSelectedModelConfig || !selectedModel;
|
|
6014
|
-
if (shouldUseDefaultModel && models.length > 0 && models[0].models?.length > 0) {
|
|
6015
|
-
const firstProvider = models[0];
|
|
6016
|
-
const firstModel = firstProvider.models[0];
|
|
6017
|
-
chatStore.setAgentModel({
|
|
6018
|
-
modelName: firstModel.modelName,
|
|
6019
|
-
providerName: firstProvider.providerName
|
|
6020
|
-
});
|
|
6021
|
-
}
|
|
6022
|
-
}, [hasSelectedModelConfig, selectedModel, models, chatStore]);
|
|
6022
|
+
const selectedModelValue = currentModel?.providerName && currentModel?.modelName ? `${currentModel.providerName}:${currentModel.modelName}` : void 0;
|
|
6023
6023
|
const handleModelChange = (_, option) => {
|
|
6024
6024
|
if (Array.isArray(option) || !option || !("providerName" in option)) return;
|
|
6025
|
-
|
|
6025
|
+
updateAgentModel({
|
|
6026
6026
|
modelName: option.modelName,
|
|
6027
6027
|
providerName: option.providerName
|
|
6028
6028
|
});
|
|
@@ -6067,13 +6067,25 @@ var ModelSelect_default = ({}) => {
|
|
|
6067
6067
|
var ReasonBtn_default = ({}) => {
|
|
6068
6068
|
const chatStore = useChatStore();
|
|
6069
6069
|
const agentState = useSnapshot(chatStore.agent);
|
|
6070
|
+
const currentModel = agentState.agentInfo.spec?.model;
|
|
6071
|
+
const updateAgentModel = (reasoning) => {
|
|
6072
|
+
const nextAgentInfo = deepCopy(agentState.agentInfo || {});
|
|
6073
|
+
const nextSpec = deepCopy(agentState.agentInfo.spec || {});
|
|
6074
|
+
nextSpec.model = {
|
|
6075
|
+
modelName: "",
|
|
6076
|
+
providerName: "",
|
|
6077
|
+
reasoning: true,
|
|
6078
|
+
...nextSpec.model || {}
|
|
6079
|
+
};
|
|
6080
|
+
nextSpec.model.reasoning = reasoning;
|
|
6081
|
+
nextAgentInfo.spec = nextSpec;
|
|
6082
|
+
chatStore.setAgent(nextAgentInfo);
|
|
6083
|
+
};
|
|
6070
6084
|
return /* @__PURE__ */ jsxs(
|
|
6071
6085
|
"div",
|
|
6072
6086
|
{
|
|
6073
|
-
className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]:
|
|
6074
|
-
onClick: () =>
|
|
6075
|
-
reasoning: !prevModel.reasoning
|
|
6076
|
-
})),
|
|
6087
|
+
className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: currentModel?.reasoning }),
|
|
6088
|
+
onClick: () => updateAgentModel(!currentModel?.reasoning),
|
|
6077
6089
|
children: [
|
|
6078
6090
|
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-reason" }),
|
|
6079
6091
|
/* @__PURE__ */ jsx("span", { children: "\u6DF1\u5EA6\u601D\u8003" })
|