@alicloud/appflow-chat 0.0.4-alpha.1 → 0.0.4-alpha.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/appflow-chat.cjs.js +236 -858
- package/dist/appflow-chat.esm.js +18560 -19658
- package/dist/types/index.d.ts +93 -74
- package/package.json +2 -3
- package/src/components/ChatSender.tsx +516 -0
- package/src/components/MessageBubble.tsx +2 -22
- package/src/index.ts +2 -6
- package/src/components/A2UIRenderer/A2UIRenderer.tsx +0 -181
- package/src/components/A2UIRenderer/index.ts +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,73 +1,5 @@
|
|
|
1
|
-
import { A2UIViewerProps } from '@a2ui/react';
|
|
2
|
-
import { ComponentRegistry } from '@a2ui/react';
|
|
3
1
|
import { default as default_2 } from 'react';
|
|
4
|
-
import { OnActionCallback } from '@a2ui/react';
|
|
5
2
|
import { Provider } from 'react';
|
|
6
|
-
import { ServerToClientMessage } from '@a2ui/react';
|
|
7
|
-
|
|
8
|
-
/** A2UI 协议消息(v0.8 格式,透传给 @a2ui/react 处理) */
|
|
9
|
-
export declare type A2UIMessage = ServerToClientMessage;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A2UIStaticViewer - A2UI 静态 JSON 渲染组件
|
|
13
|
-
*
|
|
14
|
-
* 用于直接从静态的组件定义和数据渲染 UI,无需流式消息。
|
|
15
|
-
* 适用于已有完整 A2UI 组件树的场景。
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* const components = [
|
|
20
|
-
* { id: 'root', component: { Card: { child: 'text' } } },
|
|
21
|
-
* { id: 'text', component: { Text: { text: { path: '/message' } } } },
|
|
22
|
-
* ];
|
|
23
|
-
*
|
|
24
|
-
* <A2UIStaticViewer
|
|
25
|
-
* root="root"
|
|
26
|
-
* components={components}
|
|
27
|
-
* data={{ message: 'Hello World!' }}
|
|
28
|
-
* onAction={(action) => console.log('Action:', action)}
|
|
29
|
-
* />
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare const A2UIStaticViewer: default_2.FC<A2UIStaticViewerProps>;
|
|
33
|
-
|
|
34
|
-
/** A2UIViewer 的 Props,用于静态 JSON 渲染场景 */
|
|
35
|
-
export declare type A2UIStaticViewerProps = A2UIViewerProps;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A2UISurface - A2UI 声明式 UI 渲染组件(流式消息场景)
|
|
39
|
-
*
|
|
40
|
-
* 接收 Agent 发送的 A2UI 协议消息数组,增量处理并渲染对应的 Surface。
|
|
41
|
-
* 内部封装了 A2UIProvider,可直接作为 BubbleContent 的 children 使用。
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* // 作为 BubbleContent 的 children 使用
|
|
46
|
-
* <BubbleContent content={content} status={status}>
|
|
47
|
-
* <A2UISurface
|
|
48
|
-
* messages={a2uiMessages}
|
|
49
|
-
* surfaceId="main"
|
|
50
|
-
* onAction={(msg) => console.log('用户操作:', msg)}
|
|
51
|
-
* />
|
|
52
|
-
* </BubbleContent>
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare const A2UISurface: default_2.FC<A2UISurfaceProps>;
|
|
56
|
-
|
|
57
|
-
export declare interface A2UISurfaceProps {
|
|
58
|
-
/** A2UI JSON 消息数组(来自 Agent 的响应) */
|
|
59
|
-
messages: A2UIMessage[];
|
|
60
|
-
/** 渲染的 Surface ID(默认 'main') */
|
|
61
|
-
surfaceId?: string;
|
|
62
|
-
/** 用户在 A2UI 组件上的交互回调 */
|
|
63
|
-
onAction?: OnActionCallback;
|
|
64
|
-
/** 自定义组件注册表(可选,默认使用内置组件) */
|
|
65
|
-
registry?: ComponentRegistry;
|
|
66
|
-
/** 自定义类名 */
|
|
67
|
-
className?: string;
|
|
68
|
-
/** 自定义样式 */
|
|
69
|
-
style?: default_2.CSSProperties;
|
|
70
|
-
}
|
|
71
3
|
|
|
72
4
|
/**
|
|
73
5
|
* AssociationPropertyMetadata 类型定义
|
|
@@ -119,6 +51,24 @@ export declare interface BubbleContentProps {
|
|
|
119
51
|
waitingMessage?: string;
|
|
120
52
|
}
|
|
121
53
|
|
|
54
|
+
/** 附件信息(上传完成后携带下载URL) */
|
|
55
|
+
export declare interface ChatAttachment {
|
|
56
|
+
/** 文件唯一标识 */
|
|
57
|
+
uid: string;
|
|
58
|
+
/** 文件名 */
|
|
59
|
+
name: string;
|
|
60
|
+
/** 上传状态 */
|
|
61
|
+
status: 'uploading' | 'done' | 'error';
|
|
62
|
+
/** 文件类型:image 或 file */
|
|
63
|
+
type: 'image' | 'file';
|
|
64
|
+
/** 上传后的下载URL */
|
|
65
|
+
url?: string;
|
|
66
|
+
/** 本地预览URL(图片) */
|
|
67
|
+
thumbUrl?: string;
|
|
68
|
+
/** 原始文件对象 */
|
|
69
|
+
originFile?: File;
|
|
70
|
+
}
|
|
71
|
+
|
|
122
72
|
export declare interface ChatConfig {
|
|
123
73
|
welcome: string;
|
|
124
74
|
questions: string[];
|
|
@@ -142,6 +92,79 @@ export declare interface ChatMessage {
|
|
|
142
92
|
webSearch?: boolean;
|
|
143
93
|
}
|
|
144
94
|
|
|
95
|
+
/**
|
|
96
|
+
* ChatSender - 聊天输入框组件
|
|
97
|
+
*
|
|
98
|
+
* 集成了文本输入、文件/图片上传、语音输入、联网搜索、模型选择等功能。
|
|
99
|
+
* 根据模型能力自动控制功能按钮的显隐。
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* <ChatSender
|
|
104
|
+
* loading={isLoading}
|
|
105
|
+
* models={config.models}
|
|
106
|
+
* capabilities={chatService.getModelCapabilities(modelId)}
|
|
107
|
+
* onSubmit={({ text, images, files, modelId, webSearch }) => {
|
|
108
|
+
* chatService.chat({ text, images, files, modelId, webSearch });
|
|
109
|
+
* }}
|
|
110
|
+
* onCancel={() => chatService.cancel()}
|
|
111
|
+
* onClear={() => chatService.clear()}
|
|
112
|
+
* onUpload={(file) => chatService.upload(file)}
|
|
113
|
+
* />
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const ChatSender: default_2.FC<ChatSenderProps>;
|
|
117
|
+
|
|
118
|
+
export declare interface ChatSenderProps {
|
|
119
|
+
/** 是否处于加载状态(AI正在回复) */
|
|
120
|
+
loading?: boolean;
|
|
121
|
+
/** 是否禁用 */
|
|
122
|
+
disabled?: boolean;
|
|
123
|
+
/** 输入框占位文本 */
|
|
124
|
+
placeholder?: string;
|
|
125
|
+
/** 提交方式:'enter' 回车发送 | 'shiftEnter' Shift+回车发送 */
|
|
126
|
+
submitType?: 'enter' | 'shiftEnter';
|
|
127
|
+
/** 可用模型列表 */
|
|
128
|
+
models?: ModelInfo[];
|
|
129
|
+
/** 当前选中的模型ID */
|
|
130
|
+
modelId?: string;
|
|
131
|
+
/** 默认选中的模型ID(非受控) */
|
|
132
|
+
defaultModelId?: string;
|
|
133
|
+
/** 模型切换回调 */
|
|
134
|
+
onModelChange?: (modelId: string) => void;
|
|
135
|
+
/**
|
|
136
|
+
* 模型能力配置,控制功能按钮的显隐
|
|
137
|
+
* 如果不传,所有功能按钮都显示
|
|
138
|
+
*/
|
|
139
|
+
capabilities?: ModelCapabilities;
|
|
140
|
+
/** 提交消息回调 */
|
|
141
|
+
onSubmit?: (data: ChatSenderSubmitData) => void;
|
|
142
|
+
/** 取消当前请求 */
|
|
143
|
+
onCancel?: () => void;
|
|
144
|
+
/** 清除会话回调 */
|
|
145
|
+
onClear?: () => void;
|
|
146
|
+
/** 文件上传方法,返回下载URL */
|
|
147
|
+
onUpload?: (file: File) => Promise<string>;
|
|
148
|
+
/** 自定义类名 */
|
|
149
|
+
className?: string;
|
|
150
|
+
/** 自定义样式 */
|
|
151
|
+
style?: default_2.CSSProperties;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** 提交时的消息数据 */
|
|
155
|
+
export declare interface ChatSenderSubmitData {
|
|
156
|
+
/** 文本内容 */
|
|
157
|
+
text: string;
|
|
158
|
+
/** 图片URL列表 */
|
|
159
|
+
images: string[];
|
|
160
|
+
/** 文件URL列表 */
|
|
161
|
+
files: string[];
|
|
162
|
+
/** 选中的模型ID */
|
|
163
|
+
modelId?: string;
|
|
164
|
+
/** 是否启用联网搜索 */
|
|
165
|
+
webSearch: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
145
168
|
export declare class ChatService {
|
|
146
169
|
private config;
|
|
147
170
|
private setupConfig;
|
|
@@ -598,18 +621,14 @@ export declare interface MessageBubbleProps {
|
|
|
598
621
|
onReferenceClick?: (item: DocReferenceItem) => void;
|
|
599
622
|
/** 点击网页搜索结果回调(不传则使用默认实现) */
|
|
600
623
|
onWebSearchClick?: (items: DocReferenceItem[]) => void;
|
|
601
|
-
/** 事件类型(用于特殊消息如 humanVerify、historyCard
|
|
602
|
-
eventType?: 'humanVerify' | 'historyCard'
|
|
624
|
+
/** 事件类型(用于特殊消息如 humanVerify、historyCard) */
|
|
625
|
+
eventType?: 'humanVerify' | 'historyCard';
|
|
603
626
|
/** HumanVerify 相关数据 */
|
|
604
627
|
humanVerifyData?: HumanVerifyData;
|
|
605
628
|
/** HistoryCard 相关数据(历史对话中的审核卡片) */
|
|
606
629
|
historyCardData?: HistoryCardData;
|
|
607
630
|
/** HumanVerify 提交回调 */
|
|
608
631
|
onHumanVerifySubmit?: (data: HumanVerifySubmitData) => void;
|
|
609
|
-
/** A2UI 消息数组(Agent 生成的声明式 UI 描述) */
|
|
610
|
-
a2uiMessages?: A2UIMessage[];
|
|
611
|
-
/** A2UI 用户交互回调 */
|
|
612
|
-
onA2UIAction?: (action: any) => void;
|
|
613
632
|
}
|
|
614
633
|
|
|
615
634
|
export declare interface ModelCapabilities {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/appflow-chat",
|
|
3
|
-
"version": "0.0.4-alpha.
|
|
3
|
+
"version": "0.0.4-alpha.2",
|
|
4
4
|
"description": "Appflow-Chat AI聊天机器人组件库,提供聊天服务和UI组件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/appflow-chat.cjs.js",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@fortawesome/react-fontawesome": "^0.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@ant-design/x": "^1.6.1",
|
|
43
44
|
"@eslint/js": "^9.13.0",
|
|
44
45
|
"@types/js-cookie": "^3.0.6",
|
|
45
46
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -58,8 +59,6 @@
|
|
|
58
59
|
"vite-plugin-dts": "^4.3.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
|
-
"@a2ui/react": "^0.8.0",
|
|
62
|
-
"@a2ui/web_core": "^0.8.0",
|
|
63
62
|
"antd": "^5.0.0",
|
|
64
63
|
"react": "^18.0.0",
|
|
65
64
|
"react-dom": "^18.0.0"
|