@alicloud/appflow-chat 0.0.1-beta.1 → 0.0.1-beta.3
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/README-ZH.md
CHANGED
|
@@ -7,11 +7,7 @@ AI 聊天机器人组件库,提供聊天服务和 UI 组件。
|
|
|
7
7
|
### 基础安装
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
11
|
-
tnpm install @ali/appflow-chat
|
|
12
|
-
|
|
13
|
-
# NPM 官方
|
|
14
|
-
npm install appflow-chat
|
|
10
|
+
npm install @alicloud/appflow-chat
|
|
15
11
|
```
|
|
16
12
|
|
|
17
13
|
### 安装 Peer Dependencies
|
|
@@ -33,7 +29,7 @@ npm install react react-dom antd
|
|
|
33
29
|
### 1. 初始化服务
|
|
34
30
|
|
|
35
31
|
```typescript
|
|
36
|
-
import { chatService } from '@
|
|
32
|
+
import { chatService } from '@alicloud/appflow-chat';
|
|
37
33
|
|
|
38
34
|
// 初始化
|
|
39
35
|
const config = await chatService.setup({
|
|
@@ -65,7 +61,7 @@ chatService.chat({ text: '你好' })
|
|
|
65
61
|
### 3. 使用 UI 组件
|
|
66
62
|
|
|
67
63
|
```tsx
|
|
68
|
-
import { MessageBubble, RichMessageBubble } from '@
|
|
64
|
+
import { MessageBubble, RichMessageBubble } from '@alicloud/appflow-chat';
|
|
69
65
|
|
|
70
66
|
// 简单消息气泡
|
|
71
67
|
<MessageBubble
|
|
@@ -85,7 +81,7 @@ import { MessageBubble, RichMessageBubble } from '@ali/appflow-chat';
|
|
|
85
81
|
### 4. 使用 MarkdownView 组件
|
|
86
82
|
|
|
87
83
|
```tsx
|
|
88
|
-
import { MarkdownView } from '@
|
|
84
|
+
import { MarkdownView } from '@alicloud/appflow-chat';
|
|
89
85
|
|
|
90
86
|
// 渲染 Markdown 内容
|
|
91
87
|
<MarkdownView
|
|
@@ -97,7 +93,7 @@ import { MarkdownView } from '@ali/appflow-chat';
|
|
|
97
93
|
### 5. 使用 Core 组件(高级定制)
|
|
98
94
|
|
|
99
95
|
```tsx
|
|
100
|
-
import { BubbleContent, SourceContent } from '@
|
|
96
|
+
import { BubbleContent, SourceContent } from '@alicloud/appflow-chat';
|
|
101
97
|
|
|
102
98
|
// 自定义消息气泡
|
|
103
99
|
<div className="my-bubble">
|
package/README.md
CHANGED
|
@@ -9,11 +9,7 @@ AI chatbot component library providing chat services and UI components.
|
|
|
9
9
|
### Basic Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
13
|
-
tnpm install @ali/appflow-chat
|
|
14
|
-
|
|
15
|
-
# NPM Official
|
|
16
|
-
npm install appflow-chat
|
|
12
|
+
npm install @alicloud/appflow-chat
|
|
17
13
|
```
|
|
18
14
|
|
|
19
15
|
### Install Peer Dependencies
|
|
@@ -35,7 +31,7 @@ npm install react react-dom antd
|
|
|
35
31
|
### 1. Initialize Service
|
|
36
32
|
|
|
37
33
|
```typescript
|
|
38
|
-
import { chatService } from '@
|
|
34
|
+
import { chatService } from '@alicloud/appflow-chat';
|
|
39
35
|
|
|
40
36
|
// Initialize
|
|
41
37
|
const config = await chatService.setup({
|
|
@@ -67,7 +63,7 @@ chatService.chat({ text: 'Hello' })
|
|
|
67
63
|
### 3. Use UI Components
|
|
68
64
|
|
|
69
65
|
```tsx
|
|
70
|
-
import { MessageBubble, RichMessageBubble } from '@
|
|
66
|
+
import { MessageBubble, RichMessageBubble } from '@alicloud/appflow-chat';
|
|
71
67
|
|
|
72
68
|
// Simple message bubble
|
|
73
69
|
<MessageBubble
|
|
@@ -87,7 +83,7 @@ import { MessageBubble, RichMessageBubble } from '@ali/appflow-chat';
|
|
|
87
83
|
### 4. Use MarkdownView Component
|
|
88
84
|
|
|
89
85
|
```tsx
|
|
90
|
-
import { MarkdownView } from '@
|
|
86
|
+
import { MarkdownView } from '@alicloud/appflow-chat';
|
|
91
87
|
|
|
92
88
|
// Render Markdown content
|
|
93
89
|
<MarkdownView
|
|
@@ -99,7 +95,7 @@ import { MarkdownView } from '@ali/appflow-chat';
|
|
|
99
95
|
### 5. Use Core Components (Advanced Customization)
|
|
100
96
|
|
|
101
97
|
```tsx
|
|
102
|
-
import { BubbleContent, SourceContent } from '@
|
|
98
|
+
import { BubbleContent, SourceContent } from '@alicloud/appflow-chat';
|
|
103
99
|
|
|
104
100
|
// Custom message bubble
|
|
105
101
|
<div className="my-bubble">
|
package/dist/appflow-chat.cjs.js
CHANGED
|
@@ -1802,7 +1802,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1802
1802
|
display: flex;
|
|
1803
1803
|
flex-wrap: wrap;
|
|
1804
1804
|
gap: 8px;
|
|
1805
|
-
`,iN=({content:e,role:t="bot",status:r="Success",references:n=[],className:a,style:i,onReferenceClick:s,onWebSearchClick:u,eventType:o,humanVerifyData:l,historyCardData:c,onHumanVerifySubmit:f})=>{const[p,m]=Ne.Modal.useModal(),[b,y]=ue.useState(!1),[v,T]=ue.useState([]);ue.useEffect(()=>{e!=null&&e.includes("```echarts")&&gi().catch(console.error)},[e]);const w=ue.useCallback(F=>{const $=F.Title||F.title,j=F.Text||F.text,D=F.Images||F.images;p.confirm({bodyStyle:{maxHeight:"80vh",overflow:"auto"},icon:null,title:"参考资料",destroyOnClose:!0,maskClosable:!0,closable:!0,width:800,content:R.jsxs(Ne.Space,{direction:"vertical",style:{width:"100%"},children:[R.jsxs("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:[$&&R.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:$}),j&&R.jsx("div",{children:j})]}),D&&D.length>0&&R.jsx("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:R.jsx(aN,{children:D.map((X,G)=>R.jsx(Ne.Image,{src:X,height:50},G))})})]}),footer:null})},[p]),A=ue.useCallback(F=>{T(F),y(!0)},[]),P=ue.useCallback(()=>{y(!1)},[]),B=s||w,O=u||A;return R.jsxs(R.Fragment,{children:[R.jsx(tN,{$role:t,className:`appflow-sdk-message-bubble ${a||""}`,style:i,children:R.jsxs(rN,{$role:t,children:[R.jsxs(U2,{content:e,status:r,role:t,children:[o==="humanVerify"&&l&&R.jsx(J2,{verifyId:l.verifyId,sessionWebhook:l.sessionWebhook,approved:l.approved,customParamsSchema:l.customParams,customParamsKey:l.customParamsKey,onSubmit:f}),o==="historyCard"&&c&&R.jsx(Z2,{approvalStatus:c.approvalStatus,formValues:c.formValues,formSchema:c.formSchema}),n.length>0&&r==="Success"&&R.jsx(nN,{children:R.jsx(Cl,{items:n,status:r,onItemClick:B,onWebSearchClick:O})})]}),m]})}),!u&&R.jsx(Il,{items:v,open:b,onClose:P})]})},sN=ae.div`
|
|
1805
|
+
`,iN=({content:e,role:t="bot",status:r="Success",references:n=[],className:a,style:i,onReferenceClick:s,onWebSearchClick:u,eventType:o,humanVerifyData:l,historyCardData:c,onHumanVerifySubmit:f})=>{const[p,m]=Ne.Modal.useModal(),[b,y]=ue.useState(!1),[v,T]=ue.useState([]);ue.useEffect(()=>{e!=null&&e.includes("```echarts")&&gi().catch(console.error)},[e]);const w=ue.useCallback(F=>{const $=F.Title||F.title,j=F.Text||F.text,D=F.Images||F.images;p.confirm({bodyStyle:{maxHeight:"80vh",overflow:"auto"},icon:null,title:"参考资料",destroyOnClose:!0,maskClosable:!0,closable:!0,width:800,content:R.jsxs(Ne.Space,{direction:"vertical",style:{width:"100%"},children:[R.jsxs("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:[$&&R.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:$}),j&&R.jsx("div",{children:j})]}),D&&D.length>0&&R.jsx("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:R.jsx(aN,{children:D.map((X,G)=>R.jsx(Ne.Image,{src:X,height:50},G))})})]}),footer:null})},[p]),A=ue.useCallback(F=>{T(F),y(!0)},[]),P=ue.useCallback(()=>{y(!1)},[]),B=s||w,O=u||A;return R.jsxs(R.Fragment,{children:[R.jsx(tN,{$role:t,className:`appflow-sdk-message-bubble ${a||""}`,style:i,children:R.jsxs(rN,{$role:t,children:[R.jsxs(U2,{content:e,status:r,role:t,children:[o==="humanVerify"&&l&&R.jsx(J2,{verifyId:l.verifyId,sessionWebhook:l.sessionWebhook,approved:l.approved,customParamsSchema:l.customParams,customParamsKey:l.customParamsKey,onSubmit:f}),o==="historyCard"&&c&&R.jsx(Z2,{approvalStatus:c.approvalStatus,formValues:c.formValues,formSchema:c.formSchema}),n&&n.length>0&&r==="Success"&&R.jsx(nN,{children:R.jsx(Cl,{items:n,status:r,onItemClick:B,onWebSearchClick:O})})]}),m]})}),!u&&R.jsx(Il,{items:v,open:b,onClose:P})]})},sN=ae.div`
|
|
1806
1806
|
padding: 12px 16px;
|
|
1807
1807
|
border-radius: 12px;
|
|
1808
1808
|
background: rgba(205, 208, 220, 0.15);
|
|
@@ -1900,4 +1900,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1900
1900
|
display: flex;
|
|
1901
1901
|
flex-wrap: wrap;
|
|
1902
1902
|
gap: 8px;
|
|
1903
|
-
`,lN=({content:e,messageType:t="markdown",status:r="Success",references:n=[],className:a,style:i,onReferenceClick:s,onWebSearchClick:u})=>{const[o,l]=Ne.Modal.useModal(),[c,f]=ue.useState(!1),[p,m]=ue.useState([]);ue.useEffect(()=>{(e!=null&&e.includes("echart")||e!=null&&e.includes("echarts"))&&gi().catch(console.error)},[e]);const b=ue.useCallback(A=>{const P=A.Title||A.title,B=A.Text||A.text,O=A.Images||A.images;o.confirm({bodyStyle:{maxHeight:"80vh",overflow:"auto"},icon:null,title:"参考资料",destroyOnClose:!0,maskClosable:!0,closable:!0,width:800,content:R.jsxs(Ne.Space,{direction:"vertical",style:{width:"100%"},children:[R.jsxs("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:[P&&R.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:P}),B&&R.jsx("div",{children:B})]}),O&&O.length>0&&R.jsx("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:R.jsx(oN,{children:O.map((F,$)=>R.jsx(Ne.Image,{src:F,height:50},$))})})]}),footer:null})},[o]),y=ue.useCallback(A=>{m(A),f(!0)},[]),v=ue.useCallback(()=>{f(!1)},[]),T=s||b,w=u||y;return R.jsxs(R.Fragment,{children:[R.jsxs(sN,{className:`appflow-sdk-rich-message-bubble ${a||""}`,style:i,children:[R.jsx(j2,{content:e,messageType:t,status:r,role:"bot",children:n.length>0&&r==="Success"&&R.jsx(uN,{children:R.jsx(Cl,{items:n,status:r,onItemClick:T,onWebSearchClick:w})})}),l]}),!u&&R.jsx(Il,{items:p,open:c,onClose:v})]})};exports.BubbleContent=U2;exports.ChatService=Rh;exports.CustomParamsRenderer=_l;exports.DocReferences=Cl;exports.HistoryCard=Z2;exports.HumanVerify=J2;exports.MarkdownRenderer=IC;exports.MarkdownView=Kt;exports.MessageBubble=iN;exports.RichBubbleContent=j2;exports.RichBubbleProvider=z2;exports.RichMessageBubble=lN;exports.SourceContent=X2;exports.WebSearchContent=K2;exports.WebSearchPanel=Il;exports.chatService=$3;exports.convertSchemaToUpperCase=fo;exports.loadEchartsScript=gi;exports.useCustomParamsRenderer=K_;exports.useRichBubbleContext=H2;exports.validateCustomParams=ea;
|
|
1903
|
+
`,lN=({content:e,messageType:t="markdown",status:r="Success",references:n=[],className:a,style:i,onReferenceClick:s,onWebSearchClick:u})=>{const[o,l]=Ne.Modal.useModal(),[c,f]=ue.useState(!1),[p,m]=ue.useState([]);ue.useEffect(()=>{(e!=null&&e.includes("echart")||e!=null&&e.includes("echarts"))&&gi().catch(console.error)},[e]);const b=ue.useCallback(A=>{const P=A.Title||A.title,B=A.Text||A.text,O=A.Images||A.images;o.confirm({bodyStyle:{maxHeight:"80vh",overflow:"auto"},icon:null,title:"参考资料",destroyOnClose:!0,maskClosable:!0,closable:!0,width:800,content:R.jsxs(Ne.Space,{direction:"vertical",style:{width:"100%"},children:[R.jsxs("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:[P&&R.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:P}),B&&R.jsx("div",{children:B})]}),O&&O.length>0&&R.jsx("div",{style:{borderRadius:"4px",backgroundColor:"#f0f2f5",padding:"8px"},children:R.jsx(oN,{children:O.map((F,$)=>R.jsx(Ne.Image,{src:F,height:50},$))})})]}),footer:null})},[o]),y=ue.useCallback(A=>{m(A),f(!0)},[]),v=ue.useCallback(()=>{f(!1)},[]),T=s||b,w=u||y;return R.jsxs(R.Fragment,{children:[R.jsxs(sN,{className:`appflow-sdk-rich-message-bubble ${a||""}`,style:i,children:[R.jsx(j2,{content:e,messageType:t,status:r,role:"bot",children:n&&n.length>0&&r==="Success"&&R.jsx(uN,{children:R.jsx(Cl,{items:n,status:r,onItemClick:T,onWebSearchClick:w})})}),l]}),!u&&R.jsx(Il,{items:p,open:c,onClose:v})]})};exports.BubbleContent=U2;exports.ChatService=Rh;exports.CustomParamsRenderer=_l;exports.DocReferences=Cl;exports.HistoryCard=Z2;exports.HumanVerify=J2;exports.MarkdownRenderer=IC;exports.MarkdownView=Kt;exports.MessageBubble=iN;exports.RichBubbleContent=j2;exports.RichBubbleProvider=z2;exports.RichMessageBubble=lN;exports.SourceContent=X2;exports.WebSearchContent=K2;exports.WebSearchPanel=Il;exports.chatService=$3;exports.convertSchemaToUpperCase=fo;exports.loadEchartsScript=gi;exports.useCustomParamsRenderer=K_;exports.useRichBubbleContext=H2;exports.validateCustomParams=ea;
|
package/dist/appflow-chat.esm.js
CHANGED
|
@@ -36740,7 +36740,7 @@ const w_ = ae.div`
|
|
|
36740
36740
|
formSchema: c.formSchema
|
|
36741
36741
|
}
|
|
36742
36742
|
),
|
|
36743
|
-
n.length > 0 && r === "Success" && /* @__PURE__ */ B(SN, { children: /* @__PURE__ */ B(
|
|
36743
|
+
n && n.length > 0 && r === "Success" && /* @__PURE__ */ B(SN, { children: /* @__PURE__ */ B(
|
|
36744
36744
|
r4,
|
|
36745
36745
|
{
|
|
36746
36746
|
items: n,
|
|
@@ -36915,7 +36915,7 @@ const w_ = ae.div`
|
|
|
36915
36915
|
messageType: t,
|
|
36916
36916
|
status: r,
|
|
36917
36917
|
role: "bot",
|
|
36918
|
-
children: n.length > 0 && r === "Success" && /* @__PURE__ */ B(IN, { children: /* @__PURE__ */ B(
|
|
36918
|
+
children: n && n.length > 0 && r === "Success" && /* @__PURE__ */ B(IN, { children: /* @__PURE__ */ B(
|
|
36919
36919
|
r4,
|
|
36920
36920
|
{
|
|
36921
36921
|
items: n,
|
package/package.json
CHANGED
|
@@ -370,7 +370,7 @@ export const MessageBubble: React.FC<MessageBubbleProps> = ({
|
|
|
370
370
|
)}
|
|
371
371
|
|
|
372
372
|
{/* 参考资料 */}
|
|
373
|
-
{references.length > 0 && status === 'Success' && (
|
|
373
|
+
{references && references.length > 0 && status === 'Success' && (
|
|
374
374
|
<ReferencesContainer>
|
|
375
375
|
<DocReferences
|
|
376
376
|
items={references}
|
|
@@ -397,4 +397,4 @@ export const MessageBubble: React.FC<MessageBubbleProps> = ({
|
|
|
397
397
|
);
|
|
398
398
|
};
|
|
399
399
|
|
|
400
|
-
export default MessageBubble;
|
|
400
|
+
export default MessageBubble;
|
|
@@ -254,7 +254,7 @@ export const RichMessageBubble: React.FC<RichMessageBubbleProps> = ({
|
|
|
254
254
|
role="bot"
|
|
255
255
|
>
|
|
256
256
|
{/* 参考资料 */}
|
|
257
|
-
{references.length > 0 && status === 'Success' && (
|
|
257
|
+
{references && references.length > 0 && status === 'Success' && (
|
|
258
258
|
<ReferencesContainer>
|
|
259
259
|
<DocReferences
|
|
260
260
|
items={references}
|
|
@@ -280,4 +280,4 @@ export const RichMessageBubble: React.FC<RichMessageBubbleProps> = ({
|
|
|
280
280
|
);
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
-
export default RichMessageBubble;
|
|
283
|
+
export default RichMessageBubble;
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Appflow Chat - NPM 包入口文件
|
|
3
3
|
*
|
|
4
4
|
* 使用方式:
|
|
5
|
-
* import { chatService, MarkdownRenderer, BubbleContent } from '@
|
|
5
|
+
* import { chatService, MarkdownRenderer, BubbleContent } from '@alicloud/appflow-chat';
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// ==================== 服务导出 ====================
|