@zero-library/chat-copilot 3.1.28 → 3.1.29

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.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, deepCopy, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
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, deepCopy, 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';
@@ -1163,18 +1163,6 @@ function createChatStore() {
1163
1163
  /** 智能体加载状态 */
1164
1164
  loading: false
1165
1165
  });
1166
- const setAgentModel = (updater) => {
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);
1177
- };
1178
1166
  const getUserInput = async (agentId) => {
1179
1167
  agent.loading = true;
1180
1168
  try {
@@ -1196,19 +1184,19 @@ function createChatStore() {
1196
1184
  try {
1197
1185
  const { data } = await config.services.request.fetchAgentInfo(id || "");
1198
1186
  agent.agentInfo = data;
1199
- config.hooks?.onAfterSwitchAgent?.(agent.agentInfo);
1200
1187
  } finally {
1201
1188
  config.loading = false;
1202
1189
  }
1203
1190
  };
1204
1191
  const setAgent = async (agentInfo) => {
1205
- if (!agent.agentInfo.id && !agentInfo.updatedAt || agent.agentInfo.id !== agentInfo.id) {
1192
+ if (!agent.agentInfo.id && !agentInfo.updatedAt || agent.agentInfo.id && agent.agentInfo.id !== agentInfo.id) {
1206
1193
  await getAgentInfo(agentInfo.id);
1207
1194
  }
1208
1195
  agent.agentInfo = { ...agent.agentInfo, ...agentInfo };
1209
1196
  if (config.layout.userInput) {
1210
1197
  await getUserInput(agent.agentInfo.id);
1211
1198
  }
1199
+ config.hooks?.onAfterSwitchAgent?.(agent.agentInfo);
1212
1200
  };
1213
1201
  const conversations = proxy({
1214
1202
  /** 会话列表数据 */
@@ -2041,7 +2029,11 @@ function createChatStore() {
2041
2029
  files,
2042
2030
  spec: {
2043
2031
  ...conversation.active.spec,
2044
- model: agent.agentInfo.spec?.model
2032
+ model: {
2033
+ providerName: agent.agentInfo.spec?.model?.providerName || "",
2034
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
2035
+ reasoning: agent.agentInfo.spec?.model?.reasoning ?? false
2036
+ }
2045
2037
  },
2046
2038
  stream: true,
2047
2039
  responseMode: 2
@@ -2110,8 +2102,6 @@ function createChatStore() {
2110
2102
  setServices,
2111
2103
  /** 智能体状态 */
2112
2104
  agent,
2113
- /** 设置智能体模型 */
2114
- setAgentModel,
2115
2105
  /** 设置文件预览 */
2116
2106
  setPreview,
2117
2107
  /** 设置参数 */
@@ -5992,16 +5982,16 @@ var ModelSelect_default = ({}) => {
5992
5982
  const currentModel = agentState.agentInfo.spec?.model;
5993
5983
  const updateAgentModel = useCallback(
5994
5984
  (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
5985
+ const nextAgentInfo = {
5986
+ ...agentState.agentInfo,
5987
+ spec: {
5988
+ ...agentState.agentInfo.spec,
5989
+ model: {
5990
+ ...agentState.agentInfo.spec?.model,
5991
+ ...model
5992
+ }
5993
+ }
6003
5994
  };
6004
- nextAgentInfo.spec = nextSpec;
6005
5995
  chatStore.setAgent(nextAgentInfo);
6006
5996
  },
6007
5997
  [agentState.agentInfo, chatStore]
@@ -6064,34 +6054,27 @@ var ModelSelect_default = ({}) => {
6064
6054
  }
6065
6055
  );
6066
6056
  };
6067
- var ReasonBtn_default = ({}) => {
6057
+ var ReasonBtn_default = () => {
6068
6058
  const chatStore = useChatStore();
6069
6059
  const agentState = useSnapshot(chatStore.agent);
6070
6060
  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 || {}
6061
+ const toggleReasoning = () => {
6062
+ const nextAgentInfo = {
6063
+ ...agentState.agentInfo,
6064
+ spec: {
6065
+ ...agentState.agentInfo.spec,
6066
+ model: {
6067
+ ...agentState.agentInfo.spec?.model,
6068
+ reasoning: !currentModel?.reasoning
6069
+ }
6070
+ }
6079
6071
  };
6080
- nextSpec.model.reasoning = reasoning;
6081
- nextAgentInfo.spec = nextSpec;
6082
6072
  chatStore.setAgent(nextAgentInfo);
6083
6073
  };
6084
- return /* @__PURE__ */ jsxs(
6085
- "div",
6086
- {
6087
- className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: currentModel?.reasoning }),
6088
- onClick: () => updateAgentModel(!currentModel?.reasoning),
6089
- children: [
6090
- /* @__PURE__ */ jsx(IconFont_default, { type: "icon-reason" }),
6091
- /* @__PURE__ */ jsx("span", { children: "\u6DF1\u5EA6\u601D\u8003" })
6092
- ]
6093
- }
6094
- );
6074
+ return /* @__PURE__ */ jsxs("div", { className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: currentModel?.reasoning }), onClick: toggleReasoning, children: [
6075
+ /* @__PURE__ */ jsx(IconFont_default, { type: "icon-reason" }),
6076
+ /* @__PURE__ */ jsx("span", { children: "\u6DF1\u5EA6\u601D\u8003" })
6077
+ ] });
6095
6078
  };
6096
6079
  var { Text: Text7 } = Typography;
6097
6080
  var SkillBtn_default = ({}) => {