@agentscope-ai/chat 1.1.45-beta.1766049774988 → 1.1.45-beta.1766388936317
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/components/ChatAnywhere/Input/index.tsx +38 -17
- package/components/ChatAnywhere/hooks/types.ts +1 -0
- package/components/GenerativeUI/Sandbox.tsx +7 -0
- package/components/GenerativeUI/index.tsx +1 -0
- package/components/Sender/style/index.ts +2 -0
- package/components/index.ts +3 -1
- package/lib/ChatAnywhere/Input/index.js +38 -19
- package/lib/ChatAnywhere/hooks/types.d.ts +1 -0
- package/lib/GenerativeUI/Sandbox.d.ts +1 -0
- package/lib/GenerativeUI/Sandbox.js +6 -0
- package/lib/GenerativeUI/index.d.ts +1 -0
- package/lib/GenerativeUI/index.js +1 -0
- package/lib/Sender/style/index.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import { UploadFile } from 'antd';
|
|
2
|
+
import { Flex, Popover, UploadFile } from 'antd';
|
|
3
3
|
import { useProviderContext, ChatInput, uuid, Sender, Attachments } from '@agentscope-ai/chat';
|
|
4
4
|
import cls from 'classnames';
|
|
5
5
|
import { useChatAnywhere } from '../hooks/ChatAnywhereProvider';
|
|
@@ -8,6 +8,7 @@ import { Button, GetProp, Space, Upload } from 'antd';
|
|
|
8
8
|
import Style from './style';
|
|
9
9
|
import { IconButton } from '@agentscope-ai/design';
|
|
10
10
|
import { AIGC } from '@agentscope-ai/chat';
|
|
11
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
11
12
|
|
|
12
13
|
type AttachedFiles = GetProp<typeof Attachments, 'items'>;
|
|
13
14
|
|
|
@@ -31,7 +32,7 @@ export default forwardRef(function (_, ref) {
|
|
|
31
32
|
useEffect(() => {
|
|
32
33
|
attachedFilesRef.current = attachedFiles;
|
|
33
34
|
}, [attachedFiles]);
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
const uiConfig = useChatAnywhere(v => v.uiConfig);
|
|
36
37
|
const { getPrefixCls } = useProviderContext();
|
|
37
38
|
const prefixCls = getPrefixCls('chat-anywhere-sender');
|
|
@@ -85,8 +86,11 @@ export default forwardRef(function (_, ref) {
|
|
|
85
86
|
})
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
const
|
|
89
|
-
|
|
89
|
+
const uploadPrefixNodes = useMemo(() => {
|
|
90
|
+
if (onInput.variant === 'aigc' || !onUpload?.length) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const nodes = onUpload.map((item, index) => {
|
|
90
94
|
return <Upload
|
|
91
95
|
{...item}
|
|
92
96
|
fileList={attachedFiles[index]}
|
|
@@ -102,12 +106,29 @@ export default forwardRef(function (_, ref) {
|
|
|
102
106
|
}}
|
|
103
107
|
showUploadList={false}
|
|
104
108
|
>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
{
|
|
110
|
+
item.trigger || <IconButton
|
|
111
|
+
icon={item.icon}
|
|
112
|
+
bordered={false}
|
|
113
|
+
/>
|
|
114
|
+
}
|
|
109
115
|
</Upload>
|
|
110
|
-
})
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (nodes.length === 1) return nodes;
|
|
119
|
+
return <Popover content={<Flex vertical>
|
|
120
|
+
{nodes}
|
|
121
|
+
</Flex>} trigger="click">
|
|
122
|
+
<IconButton
|
|
123
|
+
icon={<PlusOutlined />}
|
|
124
|
+
bordered={false}
|
|
125
|
+
/>
|
|
126
|
+
</Popover>
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
}, [onInput.variant, onUpload, attachedFiles]);
|
|
130
|
+
|
|
131
|
+
|
|
111
132
|
|
|
112
133
|
|
|
113
134
|
// aigc 模式下的 header
|
|
@@ -162,7 +183,7 @@ export default forwardRef(function (_, ref) {
|
|
|
162
183
|
if (trimmed.startsWith('.')) {
|
|
163
184
|
return fileName.toLowerCase().endsWith(trimmed.toLowerCase());
|
|
164
185
|
}
|
|
165
|
-
|
|
186
|
+
|
|
166
187
|
// Wildcard: image/*, */*
|
|
167
188
|
if (trimmed.includes('*')) {
|
|
168
189
|
if (trimmed === '*/*') return true;
|
|
@@ -170,7 +191,7 @@ export default forwardRef(function (_, ref) {
|
|
|
170
191
|
const [fileMain] = fileType.split('/');
|
|
171
192
|
return acceptMain === fileMain;
|
|
172
193
|
}
|
|
173
|
-
|
|
194
|
+
|
|
174
195
|
// Exact: image/jpeg
|
|
175
196
|
return fileType === trimmed;
|
|
176
197
|
});
|
|
@@ -225,7 +246,7 @@ export default forwardRef(function (_, ref) {
|
|
|
225
246
|
const getExtension = () => {
|
|
226
247
|
const nameMatch = fileName.match(/\.([^.]+)$/);
|
|
227
248
|
if (nameMatch) return nameMatch[1].toLowerCase();
|
|
228
|
-
|
|
249
|
+
|
|
229
250
|
const typeMatch = fileType.match(/\/([^/+]+)/);
|
|
230
251
|
return typeMatch ? typeMatch[1].toLowerCase() : 'bin';
|
|
231
252
|
};
|
|
@@ -257,7 +278,7 @@ export default forwardRef(function (_, ref) {
|
|
|
257
278
|
setAttachedFiles(prev => {
|
|
258
279
|
const updated = [...prev];
|
|
259
280
|
const currentList = updated[uploadIndex] || [];
|
|
260
|
-
|
|
281
|
+
|
|
261
282
|
// If not multiple, replace existing files
|
|
262
283
|
if (!uploadConfig.multiple) {
|
|
263
284
|
updated[uploadIndex] = [uploadFile];
|
|
@@ -296,11 +317,11 @@ export default forwardRef(function (_, ref) {
|
|
|
296
317
|
updateFile({ percent: event.percent });
|
|
297
318
|
},
|
|
298
319
|
} as any, {
|
|
299
|
-
defaultRequest: () => {}
|
|
320
|
+
defaultRequest: () => { }
|
|
300
321
|
});
|
|
301
322
|
}
|
|
302
323
|
};
|
|
303
|
-
|
|
324
|
+
|
|
304
325
|
// 检查是否有必需的上传项没有文件
|
|
305
326
|
const requiredFileMissing = useMemo(() => {
|
|
306
327
|
return onUpload?.some((item, index) => {
|
|
@@ -311,7 +332,7 @@ export default forwardRef(function (_, ref) {
|
|
|
311
332
|
return false;
|
|
312
333
|
}) ?? false;
|
|
313
334
|
}, [onUpload, attachedFiles]);
|
|
314
|
-
|
|
335
|
+
|
|
315
336
|
const sendDisabled = requiredFileMissing;
|
|
316
337
|
|
|
317
338
|
return <>
|
|
@@ -340,7 +361,7 @@ export default forwardRef(function (_, ref) {
|
|
|
340
361
|
scalable={onInput?.zoomable}
|
|
341
362
|
header={senderHeader}
|
|
342
363
|
prefix={<>
|
|
343
|
-
{
|
|
364
|
+
{uploadPrefixNodes}
|
|
344
365
|
{onInput?.morePrefixActions}
|
|
345
366
|
</>}
|
|
346
367
|
onSubmit={async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Sandbox } from './Sandbox';
|
package/components/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
18
18
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
|
+
import { Flex, Popover } from 'antd';
|
|
21
22
|
import { useProviderContext, ChatInput, Sender, Attachments } from "../..";
|
|
22
23
|
import cls from 'classnames';
|
|
23
24
|
import { useChatAnywhere } from "../hooks/ChatAnywhereProvider";
|
|
@@ -26,6 +27,7 @@ import { Upload } from 'antd';
|
|
|
26
27
|
import Style from "./style";
|
|
27
28
|
import { IconButton } from '@agentscope-ai/design';
|
|
28
29
|
import { AIGC } from "../..";
|
|
30
|
+
import { PlusOutlined } from "@agentscope-ai/icons-override-antd";
|
|
29
31
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
32
|
import { createElement as _createElement } from "react";
|
|
31
33
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -123,24 +125,41 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
123
125
|
return _ref.apply(this, arguments);
|
|
124
126
|
};
|
|
125
127
|
}();
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
128
|
+
var uploadPrefixNodes = useMemo(function () {
|
|
129
|
+
if (onInput.variant === 'aigc' || !(onUpload !== null && onUpload !== void 0 && onUpload.length)) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
var nodes = onUpload.map(function (item, index) {
|
|
133
|
+
return /*#__PURE__*/_createElement(Upload, _objectSpread(_objectSpread({}, item), {}, {
|
|
134
|
+
fileList: attachedFiles[index],
|
|
135
|
+
key: index,
|
|
136
|
+
onChange: function onChange(info) {
|
|
137
|
+
if (item.beforeUpload && info.file.status) {
|
|
138
|
+
handleFileChange(index, info.fileList);
|
|
139
|
+
}
|
|
140
|
+
if (!item.beforeUpload) {
|
|
141
|
+
handleFileChange(index, info.fileList);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
showUploadList: false
|
|
145
|
+
}), item.trigger || /*#__PURE__*/_jsx(IconButton, {
|
|
146
|
+
icon: item.icon,
|
|
147
|
+
bordered: false
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
if (nodes.length === 1) return nodes;
|
|
151
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
152
|
+
content: /*#__PURE__*/_jsx(Flex, {
|
|
153
|
+
vertical: true,
|
|
154
|
+
children: nodes
|
|
155
|
+
}),
|
|
156
|
+
trigger: "click",
|
|
157
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
158
|
+
icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
|
|
159
|
+
bordered: false
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
}, [onInput.variant, onUpload, attachedFiles]);
|
|
144
163
|
|
|
145
164
|
// aigc 模式下的 header
|
|
146
165
|
var aigcSenderHeader = /*#__PURE__*/_jsx(AIGC.SenderHeader, {
|
|
@@ -377,7 +396,7 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
377
396
|
scalable: onInput === null || onInput === void 0 ? void 0 : onInput.zoomable,
|
|
378
397
|
header: senderHeader,
|
|
379
398
|
prefix: /*#__PURE__*/_jsxs(_Fragment, {
|
|
380
|
-
children: [
|
|
399
|
+
children: [uploadPrefixNodes, onInput === null || onInput === void 0 ? void 0 : onInput.morePrefixActions]
|
|
381
400
|
}),
|
|
382
401
|
onSubmit: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
383
402
|
var next;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Iframe(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Sandbox } from './Sandbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Sandbox } from "./Sandbox";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createGlobalStyle } from 'antd-style';
|
|
4
|
-
var IndexStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-sender {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),\n 0px 12px 40px 0px rgba(51, 51, 71, 0.08),\n 0px 0px 1px 0px rgba(44, 44, 54, 0.02);\n background-color: ", ";\n border-radius: ", "px;\n border-color: ", ";\n border-width: 0;\n border-style: solid;\n overflow: hidden;\n\n &:after {\n content: '';\n position: absolute;\n inset: 0;\n pointer-events: none;\n transition: border-color ", ";\n border-radius: inherit;\n border-style: inherit;\n border-color: inherit;\n border-width: ", "px;\n }\n\n &:focus-within {\n box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),\n 0px 12px 40px 0px rgba(51, 51, 71, 0.08),\n 0px 0px 1px 0px rgba(44, 44, 54, 0.02);\n border-color: ", ";\n\n &:after {\n border-width: ", "px;\n }\n }\n\n &-disabled {\n .", "-sender-content,\n .", "-sender-header {\n background-color: ", ";\n }\n }\n\n &-blur {\n .", "-sender-input {\n height: 22px !important;\n min-height: 22px !important;\n }\n }\n\n &.", "-sender-rtl {\n direction: rtl;\n }\n\n &-content {\n width: 100%;\n padding: 8px;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n &-content-bottom {\n margin-top: 4px;\n display: flex;\n }\n\n &-prefix {\n flex: 1;\n }\n\n &-input {\n margin: 4px 0;\n padding: 0 8px;\n border-radius: 0;\n align-self: center;\n font-size: 14px;\n line-height: 22px;\n }\n\n &-actions-list {\n flex: none;\n display: flex;\n margin: 0 0 0 auto;\n\n &-presets {\n gap: ", "px;\n }\n\n &-length {\n font-size: 12px;\n line-height: 1;\n display: flex;\n align-items: center;\n padding: 0 12px;\n color: ", ";\n }\n }\n\n &-recording {\n height: 30px;\n padding: 0 8px;\n &-icon {\n display: block;\n width: 100%;\n height: 30px;\n }\n }\n\n &-actions-btn {\n &-disabled {\n background: ", ";\n }\n\n &-loading-button {\n padding: 0;\n border: 0;\n }\n\n &-loading-icon {\n height: ", "px;\n width: ", "px;\n vertical-align: top;\n }\n\n &-recording-icon {\n height: 1.2em;\n width: 1.2em;\n vertical-align: top;\n }\n\n \n }\n}\n\n.", "-sender {\n &-header {\n &-motion {\n transition: height .3s, border .3s;\n overflow: hidden;\n &-enter-start,\n &-leave-active {\n border-bottom-color: transparent;\n }\n\n &-hidden {\n display: none;\n }\n }\n }\n}\n"])), function (p) {
|
|
4
|
+
var IndexStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-sender {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),\n 0px 12px 40px 0px rgba(51, 51, 71, 0.08),\n 0px 0px 1px 0px rgba(44, 44, 54, 0.02);\n background-color: ", ";\n border-radius: ", "px;\n border-color: ", ";\n border-width: 0;\n border-style: solid;\n overflow: hidden;\n\n &:after {\n content: '';\n position: absolute;\n inset: 0;\n pointer-events: none;\n transition: border-color ", ";\n border-radius: inherit;\n border-style: inherit;\n border-color: inherit;\n border-width: ", "px;\n }\n\n &:focus-within {\n box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),\n 0px 12px 40px 0px rgba(51, 51, 71, 0.08),\n 0px 0px 1px 0px rgba(44, 44, 54, 0.02);\n border-color: ", ";\n\n &:after {\n border-width: ", "px;\n }\n }\n\n &-disabled {\n .", "-sender-content,\n .", "-sender-header {\n background-color: ", ";\n }\n }\n\n &-blur {\n .", "-sender-input {\n height: 22px !important;\n min-height: 22px !important;\n }\n }\n\n &.", "-sender-rtl {\n direction: rtl;\n }\n\n &-content {\n width: 100%;\n padding: 8px;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n &-content-bottom {\n margin-top: 4px;\n display: flex;\n }\n\n &-prefix {\n width: 0;\n flex: 1;\n overflow: auto;\n }\n\n &-input {\n margin: 4px 0;\n padding: 0 8px;\n border-radius: 0;\n align-self: center;\n font-size: 14px;\n line-height: 22px;\n }\n\n &-actions-list {\n flex: none;\n display: flex;\n margin: 0 0 0 auto;\n\n &-presets {\n gap: ", "px;\n }\n\n &-length {\n font-size: 12px;\n line-height: 1;\n display: flex;\n align-items: center;\n padding: 0 12px;\n color: ", ";\n }\n }\n\n &-recording {\n height: 30px;\n padding: 0 8px;\n &-icon {\n display: block;\n width: 100%;\n height: 30px;\n }\n }\n\n &-actions-btn {\n &-disabled {\n background: ", ";\n }\n\n &-loading-button {\n padding: 0;\n border: 0;\n }\n\n &-loading-icon {\n height: ", "px;\n width: ", "px;\n vertical-align: top;\n }\n\n &-recording-icon {\n height: 1.2em;\n width: 1.2em;\n vertical-align: top;\n }\n\n \n }\n}\n\n.", "-sender {\n &-header {\n &-motion {\n transition: height .3s, border .3s;\n overflow: hidden;\n &-enter-start,\n &-leave-active {\n border-bottom-color: transparent;\n }\n\n &-hidden {\n display: none;\n }\n }\n }\n}\n"])), function (p) {
|
|
5
5
|
return p.theme.prefixCls;
|
|
6
6
|
}, function (p) {
|
|
7
7
|
return p.theme.colorBgBase;
|
package/lib/index.d.ts
CHANGED
|
@@ -26,3 +26,4 @@ export { default as sleep } from './Util/sleep';
|
|
|
26
26
|
export { default as Welcome, type IWelcomeProps } from './Welcome';
|
|
27
27
|
export { default as Markdown, type MarkdownProps as IMarkdownProps, type MarkdownProps, } from './Markdown';
|
|
28
28
|
export { default as AIGC } from './AIGC';
|
|
29
|
+
export { Sandbox as GenerativeUISandbox } from './GenerativeUI';
|
package/lib/index.js
CHANGED
|
@@ -24,4 +24,5 @@ export { default as StatusCard } from "./StatusCard";
|
|
|
24
24
|
export { default as sleep } from "./Util/sleep";
|
|
25
25
|
export { default as Welcome } from "./Welcome";
|
|
26
26
|
export { default as Markdown } from "./Markdown";
|
|
27
|
-
export { default as AIGC } from "./AIGC";
|
|
27
|
+
export { default as AIGC } from "./AIGC";
|
|
28
|
+
export { Sandbox as GenerativeUISandbox } from "./GenerativeUI";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/chat",
|
|
3
|
-
"version": "1.1.45-beta.
|
|
3
|
+
"version": "1.1.45-beta.1766388936317",
|
|
4
4
|
"description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": [
|