@zero-library/chat-agent 2.1.7 → 2.1.9
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 +17 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.esm.js +10 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { RenderControl, UserInfo } from '@zero-library/common';
|
|
2
2
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { Conversation } from '@ant-design/x';
|
|
4
|
+
import { Conversation, BubbleProps } from '@ant-design/x';
|
|
5
|
+
export * from '@ant-design/x';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
7
|
|
|
6
8
|
interface InputFile {
|
|
7
9
|
/**
|
|
@@ -316,6 +318,29 @@ interface ChatSenderHandle {
|
|
|
316
318
|
cursor?: 'start' | 'end';
|
|
317
319
|
}) => void;
|
|
318
320
|
}
|
|
321
|
+
interface FileUpload {
|
|
322
|
+
params?: ObjectType<any>;
|
|
323
|
+
config: FileUploadConfig[];
|
|
324
|
+
}
|
|
325
|
+
interface Props$3 {
|
|
326
|
+
placeholder?: string;
|
|
327
|
+
content?: string;
|
|
328
|
+
fileList?: InputFile[];
|
|
329
|
+
headerOpen?: boolean;
|
|
330
|
+
loading?: boolean;
|
|
331
|
+
onContentChange: (value: string) => void;
|
|
332
|
+
onFileListChange: (files: InputFile[]) => void;
|
|
333
|
+
onHeaderOpenChange: (open: boolean) => void;
|
|
334
|
+
onSend: () => void;
|
|
335
|
+
onCancel?: () => void;
|
|
336
|
+
onFocus?: () => void;
|
|
337
|
+
extraHeader?: React.ReactNode;
|
|
338
|
+
extraFooter?: React.ReactNode;
|
|
339
|
+
extraFooterBelow?: React.ReactNode;
|
|
340
|
+
sendBtnProps?: ButtonProps;
|
|
341
|
+
fileUpload?: FileUpload;
|
|
342
|
+
}
|
|
343
|
+
declare const _default$3: react.ForwardRefExoticComponent<Props$3 & react.RefAttributes<ChatSenderHandle>>;
|
|
319
344
|
|
|
320
345
|
interface ChatConfig {
|
|
321
346
|
receiverType?: number;
|
|
@@ -323,7 +348,7 @@ interface ChatConfig {
|
|
|
323
348
|
conversationId?: string;
|
|
324
349
|
conversationStrategy?: ConversationStrategy;
|
|
325
350
|
}
|
|
326
|
-
interface Props {
|
|
351
|
+
interface Props$2 {
|
|
327
352
|
theme?: ThemeConfig;
|
|
328
353
|
config?: ChatConfig;
|
|
329
354
|
params?: ChatParams;
|
|
@@ -342,6 +367,20 @@ interface ChatHandle {
|
|
|
342
367
|
setParams: (params?: ChatParams) => void;
|
|
343
368
|
senderFocus: ChatSenderHandle['focus'];
|
|
344
369
|
}
|
|
345
|
-
declare const _default: react.ForwardRefExoticComponent<Props & react.RefAttributes<ChatHandle>>;
|
|
370
|
+
declare const _default$2: react.ForwardRefExoticComponent<Props$2 & react.RefAttributes<ChatHandle>>;
|
|
371
|
+
|
|
372
|
+
interface Props$1 {
|
|
373
|
+
fileUploadConfig?: FileUploadConfig[];
|
|
374
|
+
extraParams?: ObjectType<string | undefined>;
|
|
375
|
+
fileList?: InputFile[];
|
|
376
|
+
onChange: (fileList: InputFile[]) => void;
|
|
377
|
+
}
|
|
378
|
+
declare const _default$1: react.ForwardRefExoticComponent<Props$1 & react.RefAttributes<unknown>>;
|
|
379
|
+
|
|
380
|
+
interface Props {
|
|
381
|
+
message: ConversationMessage;
|
|
382
|
+
placement: BubbleProps['placement'];
|
|
383
|
+
}
|
|
384
|
+
declare const _default: ({ message, placement }: Props) => react_jsx_runtime.JSX.Element;
|
|
346
385
|
|
|
347
|
-
export { type AgentInfo, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatLayout, type InputFile };
|
|
386
|
+
export { type AgentInfo, _default$1 as Attachments, type ChatConfig, _default$2 as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, _default$3 as ChatSender, type ConversationStrategy, type InputFile, _default as MessageRender, type ReferencesType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { RenderControl, UserInfo } from '@zero-library/common';
|
|
2
2
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { Conversation } from '@ant-design/x';
|
|
4
|
+
import { Conversation, BubbleProps } from '@ant-design/x';
|
|
5
|
+
export * from '@ant-design/x';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
7
|
|
|
6
8
|
interface InputFile {
|
|
7
9
|
/**
|
|
@@ -316,6 +318,29 @@ interface ChatSenderHandle {
|
|
|
316
318
|
cursor?: 'start' | 'end';
|
|
317
319
|
}) => void;
|
|
318
320
|
}
|
|
321
|
+
interface FileUpload {
|
|
322
|
+
params?: ObjectType<any>;
|
|
323
|
+
config: FileUploadConfig[];
|
|
324
|
+
}
|
|
325
|
+
interface Props$3 {
|
|
326
|
+
placeholder?: string;
|
|
327
|
+
content?: string;
|
|
328
|
+
fileList?: InputFile[];
|
|
329
|
+
headerOpen?: boolean;
|
|
330
|
+
loading?: boolean;
|
|
331
|
+
onContentChange: (value: string) => void;
|
|
332
|
+
onFileListChange: (files: InputFile[]) => void;
|
|
333
|
+
onHeaderOpenChange: (open: boolean) => void;
|
|
334
|
+
onSend: () => void;
|
|
335
|
+
onCancel?: () => void;
|
|
336
|
+
onFocus?: () => void;
|
|
337
|
+
extraHeader?: React.ReactNode;
|
|
338
|
+
extraFooter?: React.ReactNode;
|
|
339
|
+
extraFooterBelow?: React.ReactNode;
|
|
340
|
+
sendBtnProps?: ButtonProps;
|
|
341
|
+
fileUpload?: FileUpload;
|
|
342
|
+
}
|
|
343
|
+
declare const _default$3: react.ForwardRefExoticComponent<Props$3 & react.RefAttributes<ChatSenderHandle>>;
|
|
319
344
|
|
|
320
345
|
interface ChatConfig {
|
|
321
346
|
receiverType?: number;
|
|
@@ -323,7 +348,7 @@ interface ChatConfig {
|
|
|
323
348
|
conversationId?: string;
|
|
324
349
|
conversationStrategy?: ConversationStrategy;
|
|
325
350
|
}
|
|
326
|
-
interface Props {
|
|
351
|
+
interface Props$2 {
|
|
327
352
|
theme?: ThemeConfig;
|
|
328
353
|
config?: ChatConfig;
|
|
329
354
|
params?: ChatParams;
|
|
@@ -342,6 +367,20 @@ interface ChatHandle {
|
|
|
342
367
|
setParams: (params?: ChatParams) => void;
|
|
343
368
|
senderFocus: ChatSenderHandle['focus'];
|
|
344
369
|
}
|
|
345
|
-
declare const _default: react.ForwardRefExoticComponent<Props & react.RefAttributes<ChatHandle>>;
|
|
370
|
+
declare const _default$2: react.ForwardRefExoticComponent<Props$2 & react.RefAttributes<ChatHandle>>;
|
|
371
|
+
|
|
372
|
+
interface Props$1 {
|
|
373
|
+
fileUploadConfig?: FileUploadConfig[];
|
|
374
|
+
extraParams?: ObjectType<string | undefined>;
|
|
375
|
+
fileList?: InputFile[];
|
|
376
|
+
onChange: (fileList: InputFile[]) => void;
|
|
377
|
+
}
|
|
378
|
+
declare const _default$1: react.ForwardRefExoticComponent<Props$1 & react.RefAttributes<unknown>>;
|
|
379
|
+
|
|
380
|
+
interface Props {
|
|
381
|
+
message: ConversationMessage;
|
|
382
|
+
placement: BubbleProps['placement'];
|
|
383
|
+
}
|
|
384
|
+
declare const _default: ({ message, placement }: Props) => react_jsx_runtime.JSX.Element;
|
|
346
385
|
|
|
347
|
-
export { type AgentInfo, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatLayout, type InputFile };
|
|
386
|
+
export { type AgentInfo, _default$1 as Attachments, type ChatConfig, _default$2 as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, _default$3 as ChatSender, type ConversationStrategy, type InputFile, _default as MessageRender, type ReferencesType };
|
package/dist/index.esm.js
CHANGED
|
@@ -5,6 +5,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
5
5
|
import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
6
6
|
import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined, UserSwitchOutlined, CloseOutlined, PlusOutlined, CommentOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, DeleteOutlined, RedoOutlined, PlayCircleOutlined, CaretRightOutlined } from '@ant-design/icons';
|
|
7
7
|
import { Attachments, Sender, Suggestion, XProvider, Welcome, Prompts, Bubble, Conversations } from '@ant-design/x';
|
|
8
|
+
export * from '@ant-design/x';
|
|
8
9
|
import classNames7 from 'classnames';
|
|
9
10
|
import { useSnapshot, proxy } from 'valtio';
|
|
10
11
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
@@ -481,6 +482,7 @@ function createChatStore() {
|
|
|
481
482
|
}
|
|
482
483
|
config.hooks?.onAfterSwitchAgent?.(data);
|
|
483
484
|
} catch (error) {
|
|
485
|
+
console.error(error);
|
|
484
486
|
throw error;
|
|
485
487
|
} finally {
|
|
486
488
|
receiver.loading = false;
|
|
@@ -506,10 +508,13 @@ function createChatStore() {
|
|
|
506
508
|
const getCharacters = async (agentId) => {
|
|
507
509
|
try {
|
|
508
510
|
character.loading = true;
|
|
509
|
-
const
|
|
511
|
+
const { data } = await agentCharacterQuery(agentId);
|
|
510
512
|
if (receiver.active.id !== agentId) return;
|
|
511
|
-
character.list =
|
|
512
|
-
|
|
513
|
+
character.list = data;
|
|
514
|
+
const active = data.find((item) => item.selected);
|
|
515
|
+
if (active) {
|
|
516
|
+
character.active = active;
|
|
517
|
+
}
|
|
513
518
|
} finally {
|
|
514
519
|
character.loading = false;
|
|
515
520
|
}
|
|
@@ -696,7 +701,7 @@ function createChatStore() {
|
|
|
696
701
|
const switchAgentConversation = async (id, strategy) => {
|
|
697
702
|
const agentId = String(id);
|
|
698
703
|
await switchAgent(agentId);
|
|
699
|
-
const conversationId = await resolveConversationId(
|
|
704
|
+
const conversationId = await resolveConversationId(receiver.active.id, strategy);
|
|
700
705
|
if (conversationId) {
|
|
701
706
|
await switchConversation(conversationId);
|
|
702
707
|
}
|
|
@@ -1987,6 +1992,6 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
1987
1992
|
] }) }) }) });
|
|
1988
1993
|
});
|
|
1989
1994
|
|
|
1990
|
-
export { layouts_default as ChatCopilot };
|
|
1995
|
+
export { Attachments_default as Attachments, layouts_default as ChatCopilot, ChatSender_default as ChatSender, MessageRender_default as MessageRender };
|
|
1991
1996
|
//# sourceMappingURL=index.esm.js.map
|
|
1992
1997
|
//# sourceMappingURL=index.esm.js.map
|