@zero-library/chat-copilot 3.1.21 → 3.1.23
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 +140 -88
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +12 -82
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +143 -91
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, ShareAltOutlined,
|
|
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,
|
|
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, Upload, Popconfirm,
|
|
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
|
+
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';
|
|
7
7
|
import { useSnapshot, proxy } from 'valtio';
|
|
@@ -1168,9 +1168,10 @@ function createChatStore() {
|
|
|
1168
1168
|
/** 智能体加载状态 */
|
|
1169
1169
|
loading: false
|
|
1170
1170
|
});
|
|
1171
|
-
const setAgentModel = (
|
|
1172
|
-
|
|
1173
|
-
|
|
1171
|
+
const setAgentModel = (updater) => {
|
|
1172
|
+
const nextPatch = typeof updater === "function" ? updater(agent.model) : updater;
|
|
1173
|
+
agent.model = { ...agent.model, ...nextPatch };
|
|
1174
|
+
config.hooks?.onAfterSwitchModel?.(agent.model);
|
|
1174
1175
|
};
|
|
1175
1176
|
const getUserInput = async (agentId) => {
|
|
1176
1177
|
agent.loading = true;
|
|
@@ -1267,6 +1268,7 @@ function createChatStore() {
|
|
|
1267
1268
|
};
|
|
1268
1269
|
const initConversation = async (config2) => {
|
|
1269
1270
|
await getConversations(config2.agent.id);
|
|
1271
|
+
await getConversationFavorite();
|
|
1270
1272
|
if (config2?.conversationId) {
|
|
1271
1273
|
switchConversation(config2.conversationId);
|
|
1272
1274
|
} else {
|
|
@@ -1343,7 +1345,17 @@ function createChatStore() {
|
|
|
1343
1345
|
isFavorite: true
|
|
1344
1346
|
}
|
|
1345
1347
|
});
|
|
1346
|
-
|
|
1348
|
+
const resultItems = transforms(data || [], {
|
|
1349
|
+
key: "id",
|
|
1350
|
+
id: "id",
|
|
1351
|
+
label: "title",
|
|
1352
|
+
spec: "spec",
|
|
1353
|
+
isFavorite: "isFavorite",
|
|
1354
|
+
group: (c) => {
|
|
1355
|
+
return classifyTime(c.updatedAt);
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
favorite.list.items = resultItems;
|
|
1347
1359
|
} finally {
|
|
1348
1360
|
favorite.loading = false;
|
|
1349
1361
|
}
|
|
@@ -2232,10 +2244,11 @@ window._iconfont_svg_string_5021436 = '<svg><symbol id="icon-Ollama" viewBox="0
|
|
|
2232
2244
|
// src/components/IconFont/index.ts
|
|
2233
2245
|
var IconFont = createFromIconfontCN({});
|
|
2234
2246
|
var IconFont_default = IconFont;
|
|
2235
|
-
var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
2247
|
+
var ConversationFavoritesBtn_default = ({ icon, disabled, ...rest }) => {
|
|
2236
2248
|
const chatStore = useChatStore();
|
|
2237
2249
|
const conversationsState = useSnapshot(chatStore.conversations);
|
|
2238
2250
|
const conversationState = useSnapshot(chatStore.conversation);
|
|
2251
|
+
const activeMessages = conversationState.messages[conversationState.active.id]?.message;
|
|
2239
2252
|
const activeConversation = useMemo(() => {
|
|
2240
2253
|
return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
|
|
2241
2254
|
}, [conversationsState.list.items, conversationState.active.id]);
|
|
@@ -2250,17 +2263,18 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2250
2263
|
title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
|
|
2251
2264
|
type: "text",
|
|
2252
2265
|
size: "large",
|
|
2253
|
-
disabled: !conversationState.active.id,
|
|
2266
|
+
disabled: disabled || !conversationState.active.id || !activeMessages?.length,
|
|
2254
2267
|
icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsx(StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsx(StarOutlined, {})),
|
|
2255
2268
|
onClick: handleToggleFavorite,
|
|
2256
2269
|
...rest
|
|
2257
2270
|
}
|
|
2258
2271
|
);
|
|
2259
2272
|
};
|
|
2260
|
-
var ConversationShareBtn_default = ({ icon, ...rest }) => {
|
|
2273
|
+
var ConversationShareBtn_default = ({ icon, disabled, ...rest }) => {
|
|
2261
2274
|
const chatStore = useChatStore();
|
|
2262
2275
|
const conversationState = useSnapshot(chatStore.conversation);
|
|
2263
2276
|
const configState = useSnapshot(chatStore.config);
|
|
2277
|
+
const activeMessages = conversationState.messages[conversationState.active.id]?.message;
|
|
2264
2278
|
const handleShareConversation = async () => {
|
|
2265
2279
|
const { data } = await configState.services.request.shareConversation(conversationState.active.id);
|
|
2266
2280
|
if (data) {
|
|
@@ -2273,7 +2287,7 @@ var ConversationShareBtn_default = ({ icon, ...rest }) => {
|
|
|
2273
2287
|
title: "\u5206\u4EAB",
|
|
2274
2288
|
type: "text",
|
|
2275
2289
|
size: "large",
|
|
2276
|
-
disabled: !conversationState.active.id,
|
|
2290
|
+
disabled: disabled || !conversationState.active.id || !activeMessages?.length,
|
|
2277
2291
|
icon: icon?.() || /* @__PURE__ */ jsx(ShareAltOutlined, {}),
|
|
2278
2292
|
...rest,
|
|
2279
2293
|
onClick: handleShareConversation
|
|
@@ -2294,12 +2308,8 @@ var styles_module_default2 = {
|
|
|
2294
2308
|
chatHeaderBtnGroup: "styles_module_chatHeaderBtnGroup",
|
|
2295
2309
|
conversationListPanel: "styles_module_conversationListPanel",
|
|
2296
2310
|
createConversationButton: "styles_module_createConversationButton",
|
|
2297
|
-
conversationListContent: "styles_module_conversationListContent",
|
|
2298
2311
|
conversations: "styles_module_conversations",
|
|
2299
|
-
conversationTabs: "styles_module_conversationTabs",
|
|
2300
|
-
conversationTabPane: "styles_module_conversationTabPane",
|
|
2301
2312
|
conversationEmpty: "styles_module_conversationEmpty",
|
|
2302
|
-
conversationScrollArea: "styles_module_conversationScrollArea",
|
|
2303
2313
|
chatWelcomeWrap: "styles_module_chatWelcomeWrap",
|
|
2304
2314
|
chatWelcome: "styles_module_chatWelcome",
|
|
2305
2315
|
promptItem: "styles_module_promptItem",
|
|
@@ -2316,30 +2326,43 @@ var styles_module_default2 = {
|
|
|
2316
2326
|
senderReferenceHeaderTitle: "styles_module_senderReferenceHeaderTitle",
|
|
2317
2327
|
senderReferenceHeaderContent: "styles_module_senderReferenceHeaderContent"
|
|
2318
2328
|
};
|
|
2319
|
-
var
|
|
2329
|
+
var ConversationTabPane = ({ items, activeKey, emptyDescription, scrollableTarget, menu, onActiveChange }) => {
|
|
2330
|
+
return /* @__PURE__ */ jsx("div", { className: "height-full", children: items.length ? /* @__PURE__ */ jsx("div", { className: "height-full scroll-fade-in", id: scrollableTarget, children: /* @__PURE__ */ jsx(
|
|
2331
|
+
InfiniteScroll,
|
|
2332
|
+
{
|
|
2333
|
+
dataLength: items.length,
|
|
2334
|
+
hasMore: false,
|
|
2335
|
+
next: () => {
|
|
2336
|
+
console2.log("next");
|
|
2337
|
+
},
|
|
2338
|
+
loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
|
|
2339
|
+
style: { overflow: "hidden" },
|
|
2340
|
+
scrollableTarget,
|
|
2341
|
+
children: /* @__PURE__ */ jsx(
|
|
2342
|
+
Conversations,
|
|
2343
|
+
{
|
|
2344
|
+
className: styles_module_default2.conversations,
|
|
2345
|
+
items,
|
|
2346
|
+
activeKey,
|
|
2347
|
+
onActiveChange: async (id) => onActiveChange(id),
|
|
2348
|
+
groupable: true,
|
|
2349
|
+
menu
|
|
2350
|
+
}
|
|
2351
|
+
)
|
|
2352
|
+
}
|
|
2353
|
+
) }) : /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsx(Empty, { description: emptyDescription, image: Empty.PRESENTED_IMAGE_SIMPLE }) }) });
|
|
2354
|
+
};
|
|
2355
|
+
var ConversationList_default = ({ onClose }) => {
|
|
2320
2356
|
const chatStore = useChatStore();
|
|
2321
|
-
const agentState = useSnapshot(chatStore.agent);
|
|
2322
2357
|
const conversationsState = useSnapshot(chatStore.conversations);
|
|
2323
2358
|
const conversationState = useSnapshot(chatStore.conversation);
|
|
2324
2359
|
const favoriteState = useSnapshot(chatStore.favorite);
|
|
2325
2360
|
const [activeTabKey, setActiveTabKey] = useState("history");
|
|
2326
|
-
useEffect(() => {
|
|
2327
|
-
if (!agentState.agentInfo.id) return;
|
|
2328
|
-
chatStore.getConversationFavorite();
|
|
2329
|
-
}, [agentState.agentInfo.id, chatStore]);
|
|
2330
2361
|
const conversationList = useMemo(() => {
|
|
2331
2362
|
return conversationsState.list.items.filter((item) => item.label);
|
|
2332
2363
|
}, [conversationsState.list.items]);
|
|
2333
2364
|
const favoriteConversationList = useMemo(() => {
|
|
2334
|
-
return favoriteState.list.items.filter((item) => item.
|
|
2335
|
-
...item,
|
|
2336
|
-
key: item.id,
|
|
2337
|
-
id: item.id,
|
|
2338
|
-
label: item.title,
|
|
2339
|
-
spec: item.spec,
|
|
2340
|
-
isFavorite: true,
|
|
2341
|
-
group: classifyTime(item.updatedAt)
|
|
2342
|
-
}));
|
|
2365
|
+
return favoriteState.list.items.filter((item) => item.label);
|
|
2343
2366
|
}, [favoriteState.list.items]);
|
|
2344
2367
|
const historyMenuConfig = (conversation) => ({
|
|
2345
2368
|
items: [
|
|
@@ -2359,6 +2382,7 @@ var ConversationList_default = () => {
|
|
|
2359
2382
|
itemInfo.domEvent.stopPropagation();
|
|
2360
2383
|
if (itemInfo.key === "deleteChat") {
|
|
2361
2384
|
chatStore.delConversation(conversation.key);
|
|
2385
|
+
onClose?.();
|
|
2362
2386
|
} else if (itemInfo.key === "collect") {
|
|
2363
2387
|
chatStore.collectConversation(conversation.id, !conversation.isFavorite);
|
|
2364
2388
|
}
|
|
@@ -2380,7 +2404,7 @@ var ConversationList_default = () => {
|
|
|
2380
2404
|
children: /* @__PURE__ */ jsx(
|
|
2381
2405
|
Button,
|
|
2382
2406
|
{
|
|
2383
|
-
icon: /* @__PURE__ */ jsx(
|
|
2407
|
+
icon: /* @__PURE__ */ jsx(StarFilled, { className: "primary-text" }),
|
|
2384
2408
|
title: "\u53D6\u6D88\u6536\u85CF",
|
|
2385
2409
|
type: "text",
|
|
2386
2410
|
onClick: (e) => {
|
|
@@ -2392,72 +2416,51 @@ var ConversationList_default = () => {
|
|
|
2392
2416
|
),
|
|
2393
2417
|
items: []
|
|
2394
2418
|
});
|
|
2395
|
-
|
|
2419
|
+
const handleConversationChange = async (id) => {
|
|
2420
|
+
await chatStore.switchConversation(id);
|
|
2421
|
+
onClose?.();
|
|
2422
|
+
};
|
|
2423
|
+
return /* @__PURE__ */ jsx(
|
|
2396
2424
|
Tabs,
|
|
2397
2425
|
{
|
|
2398
2426
|
activeKey: activeTabKey,
|
|
2399
2427
|
centered: true,
|
|
2428
|
+
className: "full-tabs",
|
|
2400
2429
|
onChange: setActiveTabKey,
|
|
2401
2430
|
items: [
|
|
2402
2431
|
{
|
|
2403
2432
|
key: "history",
|
|
2404
2433
|
label: "\u5386\u53F2\u4F1A\u8BDD",
|
|
2405
|
-
children: /* @__PURE__ */ jsx(
|
|
2406
|
-
|
|
2434
|
+
children: /* @__PURE__ */ jsx(
|
|
2435
|
+
ConversationTabPane,
|
|
2407
2436
|
{
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
console2.log("next");
|
|
2412
|
-
},
|
|
2413
|
-
loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
|
|
2414
|
-
style: { overflow: "hidden" },
|
|
2437
|
+
items: conversationList,
|
|
2438
|
+
activeKey: conversationState.active.id,
|
|
2439
|
+
emptyDescription: "\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55",
|
|
2415
2440
|
scrollableTarget: "historyConversationScrollableDiv",
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
{
|
|
2419
|
-
className: styles_module_default2.conversations,
|
|
2420
|
-
items: conversationList,
|
|
2421
|
-
activeKey: conversationState.active.id,
|
|
2422
|
-
onActiveChange: async (id) => chatStore.switchConversation(id),
|
|
2423
|
-
groupable: true,
|
|
2424
|
-
menu: historyMenuConfig
|
|
2425
|
-
}
|
|
2426
|
-
)
|
|
2441
|
+
menu: historyMenuConfig,
|
|
2442
|
+
onActiveChange: handleConversationChange
|
|
2427
2443
|
}
|
|
2428
|
-
)
|
|
2444
|
+
)
|
|
2429
2445
|
},
|
|
2430
2446
|
{
|
|
2431
2447
|
key: "favorite",
|
|
2432
2448
|
label: "\u6536\u85CF\u4F1A\u8BDD",
|
|
2433
|
-
children: /* @__PURE__ */ jsx(
|
|
2434
|
-
|
|
2449
|
+
children: /* @__PURE__ */ jsx(
|
|
2450
|
+
ConversationTabPane,
|
|
2435
2451
|
{
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
console2.log("next");
|
|
2440
|
-
},
|
|
2441
|
-
loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
|
|
2442
|
-
style: { overflow: "hidden" },
|
|
2452
|
+
items: favoriteConversationList,
|
|
2453
|
+
activeKey: conversationState.active.id,
|
|
2454
|
+
emptyDescription: "\u6682\u65E0\u6536\u85CF\u4F1A\u8BDD",
|
|
2443
2455
|
scrollableTarget: "favoriteConversationScrollableDiv",
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
{
|
|
2447
|
-
className: styles_module_default2.conversations,
|
|
2448
|
-
items: favoriteConversationList,
|
|
2449
|
-
activeKey: conversationState.active.id,
|
|
2450
|
-
onActiveChange: async (id) => chatStore.switchConversation(id),
|
|
2451
|
-
groupable: true,
|
|
2452
|
-
menu: favoriteMenuConfig
|
|
2453
|
-
}
|
|
2454
|
-
)
|
|
2456
|
+
menu: favoriteMenuConfig,
|
|
2457
|
+
onActiveChange: handleConversationChange
|
|
2455
2458
|
}
|
|
2456
|
-
)
|
|
2459
|
+
)
|
|
2457
2460
|
}
|
|
2458
2461
|
]
|
|
2459
2462
|
}
|
|
2460
|
-
)
|
|
2463
|
+
);
|
|
2461
2464
|
};
|
|
2462
2465
|
|
|
2463
2466
|
// src/ui/common/FeatureComponents/style.module.less
|
|
@@ -2494,13 +2497,25 @@ var style_module_default = {
|
|
|
2494
2497
|
footer: "style_module_footer",
|
|
2495
2498
|
titleContainer: "style_module_titleContainer"};
|
|
2496
2499
|
var HistoryBtn_default = ({ icon, ...rest }) => {
|
|
2500
|
+
const chatStore = useChatStore();
|
|
2501
|
+
const agentState = useSnapshot(chatStore.agent);
|
|
2502
|
+
const [open, setOpen] = useState(false);
|
|
2503
|
+
const handleOpenChange = (open2) => {
|
|
2504
|
+
setOpen(open2);
|
|
2505
|
+
if (open2 && agentState.agentInfo.id) {
|
|
2506
|
+
chatStore.getConversations(agentState.agentInfo.id);
|
|
2507
|
+
chatStore.getConversationFavorite();
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2497
2510
|
return /* @__PURE__ */ jsx(
|
|
2498
2511
|
Popover,
|
|
2499
2512
|
{
|
|
2513
|
+
open,
|
|
2500
2514
|
getPopupContainer: (e) => e,
|
|
2515
|
+
onOpenChange: handleOpenChange,
|
|
2501
2516
|
placement: "bottom",
|
|
2502
2517
|
classNames: { container: style_module_default.popover },
|
|
2503
|
-
content: /* @__PURE__ */ jsx(ConversationList_default, {}),
|
|
2518
|
+
content: /* @__PURE__ */ jsx(ConversationList_default, { onClose: () => setOpen(false) }),
|
|
2504
2519
|
trigger: ["click"],
|
|
2505
2520
|
children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(CommentOutlined, {}), ...rest })
|
|
2506
2521
|
}
|
|
@@ -2591,9 +2606,9 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
2591
2606
|
] });
|
|
2592
2607
|
};
|
|
2593
2608
|
var ConversationListPanel = ({ header }) => {
|
|
2594
|
-
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
|
|
2609
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full", "zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
|
|
2595
2610
|
/* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
|
|
2596
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
2611
|
+
/* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
|
|
2597
2612
|
] });
|
|
2598
2613
|
};
|
|
2599
2614
|
var ConversationListPanel_default = ConversationListPanel;
|
|
@@ -5160,6 +5175,34 @@ ${resultContent.text}
|
|
|
5160
5175
|
] });
|
|
5161
5176
|
};
|
|
5162
5177
|
var default_render_default = DefaultToolRender;
|
|
5178
|
+
var MAX_NESTING_DEPTH = 3;
|
|
5179
|
+
var SubAgentRender = ({ item }) => {
|
|
5180
|
+
const subMessages = item.subMessages || [];
|
|
5181
|
+
const depth = subMessages[0]?.subAgentDepth || 1;
|
|
5182
|
+
if (!subMessages.length) {
|
|
5183
|
+
return /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default2.emptyText, children: "\u5B50\u667A\u80FD\u4F53\u6267\u884C\u4E2D..." });
|
|
5184
|
+
}
|
|
5185
|
+
if (depth > MAX_NESTING_DEPTH) {
|
|
5186
|
+
return /* @__PURE__ */ jsxs(Typography.Text, { type: "secondary", className: index_module_default2.emptyText, children: [
|
|
5187
|
+
"\u5B50\u667A\u80FD\u4F53\u6267\u884C\u5185\u5BB9\uFF08\u5D4C\u5957\u5C42\u7EA7 ",
|
|
5188
|
+
depth,
|
|
5189
|
+
"\uFF0C\u5DF2\u6298\u53E0\uFF09"
|
|
5190
|
+
] });
|
|
5191
|
+
}
|
|
5192
|
+
return /* @__PURE__ */ jsxs("div", { className: index_module_default2.subAgentContainer, children: [
|
|
5193
|
+
item.subAgentName && /* @__PURE__ */ jsx("div", { className: index_module_default2.subAgentHeader, children: /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default2.subAgentName, children: item.subAgentName }) }),
|
|
5194
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default2.subAgentMessages, children: subMessages.map((msg, index) => /* @__PURE__ */ jsx(
|
|
5195
|
+
MessageRender_default,
|
|
5196
|
+
{
|
|
5197
|
+
role: { user: "agent", role: 2, placement: "start" },
|
|
5198
|
+
message: msg,
|
|
5199
|
+
loading: !!msg.generating
|
|
5200
|
+
},
|
|
5201
|
+
`sub-agent-${msg.messageId || index}`
|
|
5202
|
+
)) })
|
|
5203
|
+
] });
|
|
5204
|
+
};
|
|
5205
|
+
var sub_agent_render_default = SubAgentRender;
|
|
5163
5206
|
var TodoWriteRender = ({ args, result }) => {
|
|
5164
5207
|
const { token } = theme.useToken();
|
|
5165
5208
|
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
@@ -5191,21 +5234,30 @@ var TodoWriteRender = ({ args, result }) => {
|
|
|
5191
5234
|
);
|
|
5192
5235
|
};
|
|
5193
5236
|
var todo_write_render_default = TodoWriteRender;
|
|
5237
|
+
|
|
5238
|
+
// src/components/CustomComponents/ToolRenders/index.tsx
|
|
5194
5239
|
var toolRenders = {
|
|
5195
5240
|
todo_write: {
|
|
5196
5241
|
component: todo_write_render_default,
|
|
5197
|
-
defaultExpanded:
|
|
5242
|
+
defaultExpanded: true,
|
|
5198
5243
|
alwaysShowContent: (args, result) => {
|
|
5199
5244
|
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
5200
|
-
return todos && todos.length > 0;
|
|
5245
|
+
return Array.isArray(todos) && todos.length > 0;
|
|
5201
5246
|
},
|
|
5202
5247
|
hideStatus: true,
|
|
5203
5248
|
disableExpandOnError: true
|
|
5204
5249
|
}
|
|
5205
5250
|
};
|
|
5206
|
-
var getToolRenderConfig = (
|
|
5207
|
-
if (
|
|
5208
|
-
return
|
|
5251
|
+
var getToolRenderConfig = (item) => {
|
|
5252
|
+
if (item?.hasSubAgent && item?.subMessages?.length) {
|
|
5253
|
+
return {
|
|
5254
|
+
component: sub_agent_render_default,
|
|
5255
|
+
defaultExpanded: true,
|
|
5256
|
+
alwaysShowContent: true
|
|
5257
|
+
};
|
|
5258
|
+
}
|
|
5259
|
+
if (item?.toolName && toolRenders[item.toolName]) {
|
|
5260
|
+
return toolRenders[item.toolName];
|
|
5209
5261
|
}
|
|
5210
5262
|
return {
|
|
5211
5263
|
component: default_render_default,
|
|
@@ -5944,18 +5996,18 @@ var ModelSelect_default = ({}) => {
|
|
|
5944
5996
|
icon: item.icon,
|
|
5945
5997
|
options: item.models.map((model) => ({
|
|
5946
5998
|
label: model.modelLabel,
|
|
5947
|
-
value: model.modelName
|
|
5999
|
+
value: `${item.providerName}:${model.modelName}`,
|
|
6000
|
+
modelName: model.modelName,
|
|
5948
6001
|
providerName: item.providerName,
|
|
5949
6002
|
icon: model.icon
|
|
5950
6003
|
}))
|
|
5951
6004
|
}));
|
|
5952
|
-
const selectedModelValue = modelOptions.find((item) => item.value === agentState.model.providerName)?.options.find((item) => item.
|
|
6005
|
+
const selectedModelValue = modelOptions.find((item) => item.value === agentState.model.providerName)?.options.find((item) => item.modelName === agentState.model.modelName)?.value;
|
|
5953
6006
|
useEffect(() => {
|
|
5954
6007
|
if (!selectedModelValue && models.length > 0 && models[0].models?.length > 0) {
|
|
5955
6008
|
const firstProvider = models[0];
|
|
5956
6009
|
const firstModel = firstProvider.models[0];
|
|
5957
6010
|
chatStore.setAgentModel({
|
|
5958
|
-
...agentState.model,
|
|
5959
6011
|
modelName: firstModel.modelName,
|
|
5960
6012
|
providerName: firstProvider.providerName
|
|
5961
6013
|
});
|
|
@@ -5964,15 +6016,13 @@ var ModelSelect_default = ({}) => {
|
|
|
5964
6016
|
const handleModelChange = (_, option) => {
|
|
5965
6017
|
if (Array.isArray(option) || !option || !("providerName" in option)) return;
|
|
5966
6018
|
chatStore.setAgentModel({
|
|
5967
|
-
|
|
5968
|
-
modelName: option.value,
|
|
6019
|
+
modelName: option.modelName,
|
|
5969
6020
|
providerName: option.providerName
|
|
5970
6021
|
});
|
|
5971
6022
|
};
|
|
5972
6023
|
const labelRender = (props) => {
|
|
5973
6024
|
const currentVal = props.value;
|
|
5974
|
-
const
|
|
5975
|
-
const model = option?.options.find((model2) => model2.value === currentVal);
|
|
6025
|
+
const model = modelOptions.flatMap((item) => item.options).find((model2) => model2.value === currentVal);
|
|
5976
6026
|
if (!model) {
|
|
5977
6027
|
return currentVal;
|
|
5978
6028
|
}
|
|
@@ -6014,7 +6064,9 @@ var ReasonBtn_default = ({}) => {
|
|
|
6014
6064
|
"div",
|
|
6015
6065
|
{
|
|
6016
6066
|
className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: agentState.model.reasoning }),
|
|
6017
|
-
onClick: () => chatStore.setAgentModel(
|
|
6067
|
+
onClick: () => chatStore.setAgentModel((prevModel) => ({
|
|
6068
|
+
reasoning: !prevModel.reasoning
|
|
6069
|
+
})),
|
|
6018
6070
|
children: [
|
|
6019
6071
|
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-reason" }),
|
|
6020
6072
|
/* @__PURE__ */ jsx("span", { children: "\u6DF1\u5EA6\u601D\u8003" })
|