@blocklet/pages-kit 0.2.296 → 0.2.298
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/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +7 -2
- package/lib/cjs/builtin/async/ai-runtime/components/common/UserInfo.js +56 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +16 -12
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +13 -2
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +10 -18
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +40 -26
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +21 -17
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +10 -18
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/constants.js +6 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +11 -1
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/index.js +64 -11
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/runtime.js +5 -1
- package/lib/cjs/builtin/async/ai-runtime/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +7 -1
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +5 -2
- package/lib/esm/builtin/async/ai-runtime/components/common/UserInfo.js +47 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +16 -12
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +13 -2
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +10 -18
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +38 -27
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +21 -17
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +10 -18
- package/lib/esm/builtin/async/ai-runtime/components/runtime/constants.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +11 -1
- package/lib/esm/builtin/async/ai-runtime/components/runtime/index.js +44 -14
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/runtime.js +5 -1
- package/lib/esm/builtin/async/ai-runtime/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +7 -1
- package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/common/UserInfo.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.d.ts +4 -1
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/runtime/constants.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/runtime.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,42 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const types_1 = require("@blocklet/ai-runtime/types");
|
|
8
30
|
const material_1 = require("@mui/material");
|
|
9
31
|
const react_1 = require("react");
|
|
10
32
|
const react_helmet_1 = require("react-helmet");
|
|
11
33
|
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
12
34
|
const ux_1 = require("../../../../arcblock/ux");
|
|
35
|
+
const locale_1 = require("../../../../locale");
|
|
13
36
|
const header_1 = require("../../../../page/header");
|
|
14
|
-
const RuntimeProvider_1 =
|
|
37
|
+
const RuntimeProvider_1 = __importStar(require("../RuntimeProvider"));
|
|
38
|
+
const SocialShare_1 = __importDefault(require("../SocialShare"));
|
|
39
|
+
const constants_1 = require("./constants");
|
|
15
40
|
const runtime_1 = require("./state/runtime");
|
|
41
|
+
const logoSize = 44;
|
|
42
|
+
function AgentCreatedBy({ agent }) {
|
|
43
|
+
const { t } = (0, locale_1.useLocaleContext)();
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [t('by'), " ", (0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.DID, did: agent.createdBy, copyable: false, responsive: true })] }));
|
|
45
|
+
}
|
|
16
46
|
function Runtime() {
|
|
17
|
-
var _a
|
|
47
|
+
var _a;
|
|
18
48
|
const { agent, appearancePage, sessionState } = (0, runtime_1.useRuntimeState)();
|
|
49
|
+
const theme = (0, material_1.useTheme)();
|
|
50
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
|
|
51
|
+
const { locale } = (0, locale_1.useLocaleContext)();
|
|
19
52
|
(0, react_1.useEffect)(() => {
|
|
20
53
|
header_1.useHeaderState.setState((state) => {
|
|
21
54
|
var _a;
|
|
22
55
|
const logo = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.logo) === null || _a === void 0 ? void 0 : _a.url;
|
|
23
|
-
state.logo = logo && (0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, src: logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, size:
|
|
24
|
-
|
|
56
|
+
state.logo = logo && ((0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, src: logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, size: logoSize, sx: {
|
|
57
|
+
width: logoSize,
|
|
58
|
+
height: logoSize,
|
|
59
|
+
} }));
|
|
60
|
+
if (!isMobile) {
|
|
61
|
+
state.brand = ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
62
|
+
height: 18,
|
|
63
|
+
fontSize: 18,
|
|
64
|
+
}, children: (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name }));
|
|
65
|
+
state.description = agent.createdBy && ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
66
|
+
display: 'inline-flex',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
gap: 0.5,
|
|
69
|
+
mt: 0.5,
|
|
70
|
+
height: 12,
|
|
71
|
+
fontSize: 12,
|
|
72
|
+
}, children: (0, jsx_runtime_1.jsx)(AgentCreatedBy, { agent: agent }) }) }));
|
|
73
|
+
}
|
|
74
|
+
const shareContent = `${agent.name}
|
|
75
|
+
|
|
76
|
+
${agent === null || agent === void 0 ? void 0 : agent.description}
|
|
77
|
+
`;
|
|
78
|
+
state.addons = (...exists) => [(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }), ...exists].filter(Boolean);
|
|
25
79
|
});
|
|
26
80
|
return () => {
|
|
27
81
|
header_1.useHeaderState.setState((state) => {
|
|
28
82
|
state.logo = undefined;
|
|
29
83
|
state.brand = undefined;
|
|
84
|
+
state.description = undefined;
|
|
85
|
+
state.addons = (...exists) => [...exists];
|
|
30
86
|
});
|
|
31
87
|
};
|
|
32
|
-
}, [appearancePage]);
|
|
88
|
+
}, [appearancePage, locale, isMobile]);
|
|
33
89
|
(0, react_1.useEffect)(() => {
|
|
34
90
|
sessionState.load();
|
|
35
91
|
}, []);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
if (!componentId)
|
|
39
|
-
throw new Error('Missing output `appearance`');
|
|
40
|
-
return ((0, jsx_runtime_1.jsxs)(RuntimeProvider_1.default, { children: [appearancePage && ((0, jsx_runtime_1.jsxs)(react_helmet_1.Helmet, { children: [appearancePage.name && (0, jsx_runtime_1.jsx)("title", { children: appearancePage.name }), appearancePage.description && (0, jsx_runtime_1.jsx)("meta", { name: "description", content: appearancePage.description })] })), (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, properties: appearance.componentProps })] }));
|
|
92
|
+
const componentId = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentId) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PAGE_COMPONENT_ID;
|
|
93
|
+
return ((0, jsx_runtime_1.jsxs)(RuntimeProvider_1.default, { children: [appearancePage && ((0, jsx_runtime_1.jsxs)(react_helmet_1.Helmet, { children: [appearancePage.name && (0, jsx_runtime_1.jsx)("title", { children: appearancePage.name }), appearancePage.description && (0, jsx_runtime_1.jsx)("meta", { name: "description", content: appearancePage.description })] })), (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProps })] }));
|
|
41
94
|
}
|
|
42
95
|
exports.default = Runtime;
|
|
@@ -51,6 +51,10 @@ function useRuntimeState() {
|
|
|
51
51
|
const initialValue = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearancePage)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
52
52
|
return initialValue;
|
|
53
53
|
}, [agent]);
|
|
54
|
-
|
|
54
|
+
const childAgentId = (0, react_1.useMemo)(() => {
|
|
55
|
+
var _a, _b, _c, _d, _e, _f;
|
|
56
|
+
return ((_f = (_e = (_d = (_c = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue) === null || _c === void 0 ? void 0 : _c.agents) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : agent.id);
|
|
57
|
+
}, [agent]);
|
|
58
|
+
return { aid, working, agent, appearancePage, sessionState, childAgentId, execute };
|
|
55
59
|
}
|
|
56
60
|
exports.useRuntimeState = useRuntimeState;
|
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ChatBot = exports.AIRuntime = exports.PhotoGalleryItem = exports.ChatOutput = exports.
|
|
20
|
+
exports.ChatBot = exports.AIRuntime = exports.PhotoGalleryItem = exports.ChatOutput = exports.SimpleOutput = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.Runtime = void 0;
|
|
21
21
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
22
22
|
const material_1 = require("@mui/material");
|
|
23
23
|
const react_1 = require("react");
|
|
@@ -47,7 +47,7 @@ Object.defineProperty(exports, "PhotoGallery", { enumerable: true, get: function
|
|
|
47
47
|
var AutoForm_1 = require("./components/runtime/components/AutoForm");
|
|
48
48
|
Object.defineProperty(exports, "AutoForm", { enumerable: true, get: function () { return __importDefault(AutoForm_1).default; } });
|
|
49
49
|
var SimpleOutput_1 = require("./components/runtime/components/SimpleOutput");
|
|
50
|
-
Object.defineProperty(exports, "
|
|
50
|
+
Object.defineProperty(exports, "SimpleOutput", { enumerable: true, get: function () { return __importDefault(SimpleOutput_1).default; } });
|
|
51
51
|
var ChatOutput_1 = require("./components/runtime/components/ChatOutput");
|
|
52
52
|
Object.defineProperty(exports, "ChatOutput", { enumerable: true, get: function () { return __importDefault(ChatOutput_1).default; } });
|
|
53
53
|
var PhotoGalleryItem_1 = require("./components/runtime/components/PhotoGalleryItem");
|
|
@@ -18,6 +18,9 @@ exports.translations = {
|
|
|
18
18
|
dialog: {
|
|
19
19
|
title: 'AI Art Image',
|
|
20
20
|
prompt: 'Prompt',
|
|
21
|
+
metadata: 'Metadata',
|
|
22
|
+
author: 'Author',
|
|
23
|
+
time: 'Creation Time',
|
|
21
24
|
},
|
|
22
25
|
},
|
|
23
26
|
questionPlaceholder: 'Ask Anything...',
|
|
@@ -93,7 +96,7 @@ exports.translations = {
|
|
|
93
96
|
loadMore: 'Load More',
|
|
94
97
|
},
|
|
95
98
|
zh: {
|
|
96
|
-
by: '
|
|
99
|
+
by: '作者',
|
|
97
100
|
socialShare: {
|
|
98
101
|
title: '分享',
|
|
99
102
|
shareToX: '分享到 X',
|
|
@@ -108,6 +111,9 @@ exports.translations = {
|
|
|
108
111
|
dialog: {
|
|
109
112
|
title: 'AI 艺术图片',
|
|
110
113
|
prompt: '提示词',
|
|
114
|
+
metadata: '元数据',
|
|
115
|
+
author: '作者',
|
|
116
|
+
time: '创作时间',
|
|
111
117
|
},
|
|
112
118
|
},
|
|
113
119
|
questionPlaceholder: '问点什么...',
|
|
@@ -8,9 +8,12 @@ import { translations } from '../locales';
|
|
|
8
8
|
import GlobalLoading from './GlobalLoading';
|
|
9
9
|
import ThemeProvider from './ThemeProvider';
|
|
10
10
|
export default function RuntimeProvider({ children }) {
|
|
11
|
-
|
|
12
|
-
return (_jsx(LocaleProvider, { translations: translations, locale: locale, fallbackLocale: "en", children: _jsx(ThemeProvider, { children: _jsxs(ErrorBoundary, { FallbackComponent: ErrorRender, children: [_jsx(GlobalLoading, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), _jsx(React.Suspense, { fallback: _jsx(Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: _jsx(CircularProgress, { size: 24 }) }), children: children })] }) }) }));
|
|
11
|
+
return (_jsx(RuntimeLocaleProvider, { children: _jsx(ThemeProvider, { children: _jsxs(ErrorBoundary, { FallbackComponent: ErrorRender, children: [_jsx(GlobalLoading, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), _jsx(React.Suspense, { fallback: _jsx(Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: _jsx(CircularProgress, { size: 24 }) }), children: children })] }) }) }));
|
|
13
12
|
}
|
|
14
13
|
function ErrorRender({ error }) {
|
|
15
14
|
return (_jsx(Result, { status: error.status || 'error', description: error.message, sx: { bgcolor: 'transparent', mt: '20%' } }));
|
|
16
15
|
}
|
|
16
|
+
export function RuntimeLocaleProvider({ children }) {
|
|
17
|
+
const { locale } = useLocaleContext();
|
|
18
|
+
return (_jsx(LocaleProvider, { translations: translations, locale: locale, fallbackLocale: "en", children: children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import DID from '@arcblock/ux/lib/DID';
|
|
14
|
+
import { Box, Stack, Typography } from '@mui/material';
|
|
15
|
+
import dayjs from 'dayjs';
|
|
16
|
+
import { useMemo } from 'react';
|
|
17
|
+
import { Avatar } from '../../../../arcblock/ux';
|
|
18
|
+
export default function UserInfo(_a) {
|
|
19
|
+
var { avatar, showDID, did, name, time, children, reverse } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse"]);
|
|
20
|
+
return (_jsxs(Stack, Object.assign({ className: "user-info", alignItems: "center", direction: reverse ? 'row-reverse' : 'row', gap: 1.5 }, restProps, { children: [(avatar || did) && (_jsx(Box, { sx: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
maxHeight: 44,
|
|
24
|
+
}, children: _jsx(Avatar, { size: 40, did: did, variant: "circle", shape: "circle", src: avatar }) })), _jsxs(Box, { flex: 1, width: 0, children: [_jsxs(UserName, { sx: {
|
|
25
|
+
justifyContent: reverse ? 'flex-end' : 'flex-start',
|
|
26
|
+
}, children: [name || '', time && (_jsx(UserTime, { time: time, sx: {
|
|
27
|
+
fontSize: 12,
|
|
28
|
+
lineHeight: '24px',
|
|
29
|
+
color: 'text.secondary',
|
|
30
|
+
} }))] }), showDID && did && _jsx(Box, { component: DID, did: did, copyable: false, size: 14, responsive: true, sx: { mt: -0.25 } }), _jsx(Box, { flex: 1, children: children })] })] })));
|
|
31
|
+
}
|
|
32
|
+
export function UserName(_a) {
|
|
33
|
+
var { children, sx } = _a, restProps = __rest(_a, ["children", "sx"]);
|
|
34
|
+
return (_jsx(Typography, Object.assign({ component: "div", noWrap: true, sx: Object.assign({ fontSize: 14, lineHeight: '24px', fontWeight: 500, display: 'flex', alignItems: 'center', gap: 1 }, sx) }, restProps, { children: children })));
|
|
35
|
+
}
|
|
36
|
+
export function UserTime(_a) {
|
|
37
|
+
var { time } = _a, restProps = __rest(_a, ["time"]);
|
|
38
|
+
const formattedTime = useMemo(() => {
|
|
39
|
+
const date = dayjs(time);
|
|
40
|
+
if (!date.isValid())
|
|
41
|
+
return undefined;
|
|
42
|
+
return date.isSame(dayjs(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
|
|
43
|
+
}, [time]);
|
|
44
|
+
if (!formattedTime)
|
|
45
|
+
return null;
|
|
46
|
+
return (_jsx(Typography, Object.assign({}, restProps, { children: formattedTime }), "user-time"));
|
|
47
|
+
}
|
package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js
CHANGED
|
@@ -14,6 +14,7 @@ import ImagePreview from '@blocklet/ai-kit/components/image-preview';
|
|
|
14
14
|
import { cx } from '@emotion/css';
|
|
15
15
|
import { Box, Skeleton, Stack, Tooltip, Typography, styled, useMediaQuery, useTheme } from '@mui/material';
|
|
16
16
|
import dayjs from 'dayjs';
|
|
17
|
+
import isEmpty from 'lodash/isEmpty';
|
|
17
18
|
import React, { memo, useMemo, useState } from 'react';
|
|
18
19
|
import { Avatar } from '../../../../../../arcblock/ux';
|
|
19
20
|
import { useSessionContext } from '../../../../../../session';
|
|
@@ -26,13 +27,23 @@ const MessageItemView = memo((_a) => {
|
|
|
26
27
|
var _b;
|
|
27
28
|
var { message, hideAvatar } = _a, props = __rest(_a, ["message", "hideAvatar"]);
|
|
28
29
|
const showUserMessage = !!((_b = message.parameters) === null || _b === void 0 ? void 0 : _b.question);
|
|
29
|
-
return (_jsxs(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && _jsx(UserMessage, { message: message }), _jsx(AgentMessage, { message: message, hideAvatar: hideAvatar })] })));
|
|
30
|
+
return (_jsxs(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && !isEmpty(message.parameters) && _jsx(UserMessage, { message: message, hideAvatar: hideAvatar }), !isEmpty(message.result) && _jsx(AgentMessage, { message: message, hideAvatar: hideAvatar })] })));
|
|
30
31
|
});
|
|
31
32
|
export default MessageItemView;
|
|
32
33
|
const MessageItemContainer = styled(Stack) `
|
|
33
34
|
gap: ${({ theme }) => theme.spacing(2.5)};
|
|
34
35
|
overflow: hidden;
|
|
35
36
|
|
|
37
|
+
&.hide-avatar {
|
|
38
|
+
.message-question {
|
|
39
|
+
border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.message-response {
|
|
43
|
+
border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
.message-question {
|
|
37
48
|
position: relative;
|
|
38
49
|
border-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
@@ -42,10 +53,6 @@ const MessageItemContainer = styled(Stack) `
|
|
|
42
53
|
// without logo width
|
|
43
54
|
max-width: calc(100% - 40px);
|
|
44
55
|
background-color: rgba(239, 246, 255, 1);
|
|
45
|
-
|
|
46
|
-
&.hide-avatar {
|
|
47
|
-
border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
48
|
-
}
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
.message-response {
|
|
@@ -56,14 +63,11 @@ const MessageItemContainer = styled(Stack) `
|
|
|
56
63
|
margin-top: ${({ theme }) => theme.spacing(0.5)};
|
|
57
64
|
// without logo width
|
|
58
65
|
max-width: calc(100% - 40px);
|
|
66
|
+
display: inline-flex;
|
|
59
67
|
background-color: rgba(229, 231, 235, 1);
|
|
60
|
-
|
|
61
|
-
&.hide-avatar {
|
|
62
|
-
border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
63
|
-
}
|
|
64
68
|
}
|
|
65
69
|
`;
|
|
66
|
-
function UserMessage({ message }) {
|
|
70
|
+
function UserMessage({ message, hideAvatar }) {
|
|
67
71
|
var _a, _b, _c, _d;
|
|
68
72
|
const { session: authSession } = useSessionContext();
|
|
69
73
|
return (_jsxs(Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
|
|
@@ -71,11 +75,11 @@ function UserMessage({ message }) {
|
|
|
71
75
|
flexDirection: 'row-reverse',
|
|
72
76
|
textAlign: 'right',
|
|
73
77
|
justifyContent: 'flex-end',
|
|
74
|
-
}, children: [_jsx(Box, { children: _jsx(Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) }), _jsxs(Stack, { flex: 1, overflow: "hidden", sx: {
|
|
78
|
+
}, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) })), _jsxs(Stack, { flex: 1, overflow: "hidden", sx: {
|
|
75
79
|
display: 'flex',
|
|
76
80
|
flexDirection: 'column',
|
|
77
81
|
alignItems: 'flex-end',
|
|
78
|
-
}, children: [_jsxs(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, _jsx(MessageTime, { time: message.createdAt })] }), _jsx(Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
|
|
82
|
+
}, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, _jsx(MessageTime, { time: message.createdAt })] })), _jsx(Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
|
|
79
83
|
}
|
|
80
84
|
function AgentMessage({ message, hideAvatar }) {
|
|
81
85
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
2
3
|
import { useCurrentMessage } from '../../contexts/CurrentMessage';
|
|
3
4
|
import MessageItemView from './MessageItemView';
|
|
4
|
-
|
|
5
|
+
// default hideAvatar to true, only show message when polish agent layout
|
|
6
|
+
export default function ChatOutput({ hideAvatar = true, renderType, }) {
|
|
5
7
|
const { message } = useCurrentMessage();
|
|
6
|
-
|
|
8
|
+
const formattedMessage = useMemo(() => {
|
|
9
|
+
if (renderType) {
|
|
10
|
+
return Object.assign({}, message, {
|
|
11
|
+
result: renderType === 'parameters' ? {} : message.result,
|
|
12
|
+
parameters: renderType === 'result' ? {} : message.parameters,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return message;
|
|
16
|
+
}, [message, renderType]);
|
|
17
|
+
return _jsx(MessageItemView, { message: formattedMessage, hideAvatar: hideAvatar });
|
|
7
18
|
}
|
package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
|
|
3
2
|
import { Masonry } from '@mui/lab';
|
|
4
3
|
import { Box, Skeleton, Stack, ThemeProvider, Typography, createTheme, styled, useTheme } from '@mui/material';
|
|
5
4
|
import { Suspense, useMemo } from 'react';
|
|
@@ -12,12 +11,7 @@ import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
|
12
11
|
import { useRuntimeState } from '../../state/runtime';
|
|
13
12
|
import mapRight from '../../utils/map-right';
|
|
14
13
|
export default function PhotoGallery({ resultTitle, background, primaryColor, }) {
|
|
15
|
-
|
|
16
|
-
const { appearancePage, agent } = useRuntimeState();
|
|
17
|
-
const children = useMemo(() => {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
20
|
-
}, [agent]);
|
|
14
|
+
const { agent, appearancePage, childAgentId } = useRuntimeState();
|
|
21
15
|
const inheritedTheme = useTheme();
|
|
22
16
|
const theme = useMemo(() => {
|
|
23
17
|
let { primary } = inheritedTheme.palette;
|
|
@@ -36,7 +30,9 @@ export default function PhotoGallery({ resultTitle, background, primaryColor, })
|
|
|
36
30
|
},
|
|
37
31
|
});
|
|
38
32
|
}, [inheritedTheme, primaryColor]);
|
|
39
|
-
|
|
33
|
+
const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
|
|
34
|
+
const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
|
|
35
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Root, { className: "photo-wall-root", sx: { backgroundImage: `url(${background})` }, children: [_jsx(Stack, { className: "photo-wall-header", children: _jsxs(Provider, { children: [title && (_jsx(Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: title }) })), description && (_jsx(Typography, { fontSize: 20, textAlign: "center", children: _jsx(Balancer, { children: description }) }))] }) }), _jsx(Stack, { className: "photo-wall-input", children: _jsx(CurrentAgentProvider, { agentId: childAgentId, children: _jsx(AgentInputRender, {}) }) }), _jsxs(Stack, { className: "photo-wall-output", gap: 2, children: [resultTitle && (_jsx(Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: resultTitle }) })), _jsx(OutputView, {})] })] }) }));
|
|
40
36
|
}
|
|
41
37
|
const Root = styled(Stack)(({ theme }) => theme.unstable_sx({
|
|
42
38
|
gap: { xs: 3, sm: 4, md: 5 },
|
|
@@ -71,12 +67,10 @@ const Root = styled(Stack)(({ theme }) => theme.unstable_sx({
|
|
|
71
67
|
},
|
|
72
68
|
}));
|
|
73
69
|
function AgentInputRender() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
77
|
-
if (!(input === null || input === void 0 ? void 0 : input.componentId))
|
|
70
|
+
const { appearanceInput } = useCurrentAgent();
|
|
71
|
+
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
78
72
|
return null;
|
|
79
|
-
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId:
|
|
73
|
+
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
|
|
80
74
|
}
|
|
81
75
|
function NoOutputs() {
|
|
82
76
|
return (_jsx(Stack, { mt: 10, children: _jsx(Typography, { color: "text.disabled", children: "You haven't generated any pictures yet." }) }));
|
|
@@ -91,10 +85,8 @@ function OutputView() {
|
|
|
91
85
|
} })), mapRight((_d = sessionState.messages) !== null && _d !== void 0 ? _d : [], (message) => (_jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(OutputItemView, {}) }) }) }, message.taskId)))] }), _jsx(Box, { my: 4, children: !!((_e = sessionState.messages) === null || _e === void 0 ? void 0 : _e.length) && !sessionState.noMoreMessage && (_jsx(LoadingButton, { variant: "outlined", onClick: sessionState.loadMoreMessages, children: t('loadMore') })) })] }));
|
|
92
86
|
}
|
|
93
87
|
function OutputItemView() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
97
|
-
if (!(input === null || input === void 0 ? void 0 : input.componentId))
|
|
88
|
+
const { appearanceOutput } = useCurrentAgent();
|
|
89
|
+
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
98
90
|
return null;
|
|
99
|
-
return _jsx(CustomComponentRenderer, { componentId:
|
|
91
|
+
return (_jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
|
|
100
92
|
}
|
package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js
CHANGED
|
@@ -12,10 +12,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
|
|
14
14
|
import { Icon } from '@iconify/react';
|
|
15
|
-
import { Box, Button, Dialog, DialogContent, Stack, Typography, alpha
|
|
15
|
+
import { Box, Button, Dialog, DialogContent, DialogTitle, Stack, Typography, alpha } from '@mui/material';
|
|
16
16
|
import { useState } from 'react';
|
|
17
|
+
import { RelativeTime } from '../../../../../../arcblock/ux';
|
|
17
18
|
import { useLocaleContext } from '../../../../../../locale';
|
|
19
|
+
import { useSessionContext } from '../../../../../../session';
|
|
18
20
|
import { ActionButton } from '../../../ActionButton';
|
|
21
|
+
import UserInfo from '../../../common/UserInfo';
|
|
19
22
|
import { useCurrentMessage } from '../../contexts/CurrentMessage';
|
|
20
23
|
const getLineClamp = (line) => ({
|
|
21
24
|
display: '-webkit-box',
|
|
@@ -70,12 +73,17 @@ export default function PhotoGalleryItem() {
|
|
|
70
73
|
} }))] }, url));
|
|
71
74
|
});
|
|
72
75
|
}
|
|
76
|
+
function RenderSubTitle({ children }) {
|
|
77
|
+
return (_jsx(Typography, { variant: "caption", sx: { fontSize: 14 }, children: children }));
|
|
78
|
+
}
|
|
73
79
|
function PromptDialog(_a) {
|
|
80
|
+
var _b, _c, _d;
|
|
74
81
|
var { url } = _a, props = __rest(_a, ["url"]);
|
|
75
82
|
const { message } = useCurrentMessage();
|
|
76
83
|
const { parameters } = message;
|
|
77
|
-
const theme = useTheme();
|
|
78
84
|
const { t } = useLocaleContext();
|
|
85
|
+
const { session: authSession } = useSessionContext();
|
|
86
|
+
const borderRadius = 1;
|
|
79
87
|
return (_jsxs(Dialog, Object.assign({ fullWidth: true, maxWidth: false, scroll: "paper", slotProps: {
|
|
80
88
|
backdrop: {
|
|
81
89
|
sx: {
|
|
@@ -83,32 +91,35 @@ function PromptDialog(_a) {
|
|
|
83
91
|
backdropFilter: 'blur(12px)',
|
|
84
92
|
},
|
|
85
93
|
},
|
|
86
|
-
} }, props, { children: [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
} }, props, { children: [_jsxs(DialogTitle, { sx: {
|
|
95
|
+
display: 'flex',
|
|
96
|
+
justifyContent: 'space-between',
|
|
97
|
+
}, children: [_jsx(Typography, { component: "h5", sx: { fontSize: 24, fontWeight: 700, color: 'primary.main' }, children: t('photoWall.dialog.title') }), _jsx(Box, { children: _jsx(Button, { onClick: (e) => { var _a; return (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props, e, 'backdropClick'); }, variant: "contained", disableElevation: true, sx: {
|
|
98
|
+
bgcolor: (theme) => alpha(theme.palette.primary.light, 0.2),
|
|
99
|
+
minWidth: 32,
|
|
100
|
+
minHeight: 32,
|
|
101
|
+
p: 0,
|
|
102
|
+
fontSize: 22,
|
|
103
|
+
color: 'primary.main',
|
|
104
|
+
':hover': {
|
|
105
|
+
bgcolor: (theme) => alpha(theme.palette.primary.light, 0.3),
|
|
106
|
+
},
|
|
107
|
+
}, children: _jsx(Icon, { icon: "tabler:x" }) }) })] }), _jsx(DialogContent, { children: _jsxs(Stack, { gap: 2.5, sx: { flexDirection: { md: 'row' } }, children: [_jsx(Stack, { sx: { flex: 3, width: { xs: '100%', md: 0 }, gap: 1 }, children: _jsx(Box, { component: "img", src: url, alt: "", loading: "lazy", sx: {
|
|
108
|
+
display: 'block',
|
|
109
|
+
width: '100%',
|
|
110
|
+
borderRadius,
|
|
111
|
+
} }) }), _jsxs(Stack, { sx: { flex: 2, width: { xs: '100%', md: 0 }, gap: 1 }, children: [_jsx(RenderSubTitle, { children: t('photoWall.dialog.author') }), _jsx(UserInfo, { showDID: true, name: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.fullName, did: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did, avatar: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.avatar }), _jsx(Box, {}), _jsx(Box, { sx: { fontSize: 14, color: 'text.secondary' }, children: _jsx(RelativeTime, { value: message.createdAt }) }), _jsx(Box, {}), _jsx(RenderSubTitle, { children: t('photoWall.dialog.prompt') }), _jsx(Box, { sx: {
|
|
112
|
+
backgroundColor: 'background.paper',
|
|
113
|
+
borderRadius,
|
|
114
|
+
p: 1,
|
|
115
|
+
fontSize: 16,
|
|
116
|
+
border: 1,
|
|
117
|
+
borderColor: 'divider',
|
|
118
|
+
overflow: 'auto',
|
|
119
|
+
maxHeight: { xs: 'unset', md: '40vh' },
|
|
120
|
+
}, children: parameters === null || parameters === void 0 ? void 0 : parameters.question }), _jsx(Box, { children: _jsx(ActionButton, { autoReset: true, size: "small", variant: "contained", placement: "right", tip: t('copyToClipboard'), title: t('copy'), titleSucceed: t('copied'), icon: "tabler:copy", iconSucceed: "tabler:copy-check-filled", onClick: () => {
|
|
110
121
|
window.navigator.clipboard.writeText(parameters === null || parameters === void 0 ? void 0 : parameters.question);
|
|
111
122
|
}, sx: {
|
|
112
|
-
borderRadius
|
|
123
|
+
borderRadius,
|
|
113
124
|
} }) })] })] }) })] })));
|
|
114
125
|
}
|
|
@@ -4,7 +4,9 @@ import { Box, Stack, ThemeProvider, Typography, createTheme, useTheme } from '@m
|
|
|
4
4
|
import { Suspense, useEffect, useMemo } from 'react';
|
|
5
5
|
import Balancer, { Provider } from 'react-wrap-balancer';
|
|
6
6
|
import CustomComponentRenderer from '../../../../../../../components/CustomComponentRenderer';
|
|
7
|
+
import { useSessionContext } from '../../../../../../session';
|
|
7
8
|
import { MessageSuggestedQuestions } from '../../../common';
|
|
9
|
+
import UserInfo from '../../../common/UserInfo';
|
|
8
10
|
import ScrollView, { useScrollToBottomModule } from '../../../ScrollView';
|
|
9
11
|
import CurrentAgentProvider, { useCurrentAgent } from '../../contexts/CurrentAgent';
|
|
10
12
|
import CurrentMessageProvider, { useCurrentMessage } from '../../contexts/CurrentMessage';
|
|
@@ -31,26 +33,21 @@ export default function SimpleChat({ primaryColor }) {
|
|
|
31
33
|
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(ScrollView, { scroller: "window", initialScrollBehavior: "auto", children: _jsx(SimpleChatView, {}) }) }));
|
|
32
34
|
}
|
|
33
35
|
function SimpleChatView() {
|
|
34
|
-
|
|
35
|
-
const { agent, appearancePage, sessionState } = useRuntimeState();
|
|
36
|
+
const { agent, childAgentId, appearancePage, sessionState } = useRuntimeState();
|
|
36
37
|
const scrollToBottom = useScrollToBottomModule().useScrollToBottom();
|
|
37
38
|
useEffect(() => {
|
|
38
39
|
if (sessionState.running)
|
|
39
40
|
scrollToBottom();
|
|
40
41
|
}, [scrollToBottom, sessionState.running]);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [agent]);
|
|
45
|
-
return (_jsxs(Stack, { flexGrow: 1, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [_jsx(Stack, { gap: 2, mt: 8, mb: 4, children: _jsxs(Provider, { children: [(appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) && (_jsx(Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: appearancePage.name }) })), (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) && (_jsx(Typography, { textAlign: "center", children: _jsx(Balancer, { children: appearancePage.description }) }))] }) }), _jsx(Stack, { children: _jsx(OutputView, {}) }), _jsx(Box, { flexGrow: 1, minHeight: 200 }), _jsx(Stack, { sx: { position: 'sticky', bottom: 0, py: 1, bgcolor: 'background.paper', zIndex: 10 }, children: (_a = children === null || children === void 0 ? void 0 : children.agents) === null || _a === void 0 ? void 0 : _a.map((i) => (_jsx(CurrentAgentProvider, { agentId: i.id, children: _jsx(AgentInputRender, {}) }, i.id))) })] }));
|
|
42
|
+
const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
|
|
43
|
+
const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
|
|
44
|
+
return (_jsxs(Stack, { flexGrow: 1, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [_jsx(Stack, { gap: 2, mt: 8, mb: 4, children: _jsxs(Provider, { children: [title && (_jsx(Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: title }) })), description && (_jsx(Typography, { textAlign: "center", children: _jsx(Balancer, { children: description }) }))] }) }), _jsx(Stack, { children: _jsx(OutputView, {}) }), _jsx(Box, { flexGrow: 1, minHeight: 200 }), _jsx(Stack, { sx: { position: 'sticky', bottom: 0, py: 1, bgcolor: 'background.paper', zIndex: 10 }, children: _jsx(CurrentAgentProvider, { agentId: childAgentId, children: _jsx(AgentInputRender, {}) }) })] }));
|
|
46
45
|
}
|
|
47
46
|
function AgentInputRender() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
51
|
-
if (!(input === null || input === void 0 ? void 0 : input.componentId))
|
|
47
|
+
const { appearanceInput } = useCurrentAgent();
|
|
48
|
+
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
52
49
|
return null;
|
|
53
|
-
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId:
|
|
50
|
+
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
|
|
54
51
|
}
|
|
55
52
|
function OutputView() {
|
|
56
53
|
var _a, _b;
|
|
@@ -59,12 +56,19 @@ function OutputView() {
|
|
|
59
56
|
return (_jsxs(Stack, { gap: 2, children: [(_b = sessionState.messages) === null || _b === void 0 ? void 0 : _b.map((message) => (_jsx(Stack, { children: _jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(OutputItemView, {}) }) }) }) }))), lastMessage && (_jsx(CurrentAgentProvider, { agentId: lastMessage.assistantId, children: _jsx(CurrentMessageProvider, { message: lastMessage, children: _jsx(SuggestedQuestionsView, {}) }) }))] }));
|
|
60
57
|
}
|
|
61
58
|
function OutputItemView() {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
const {
|
|
64
|
-
const
|
|
65
|
-
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
const { appearancePage } = useRuntimeState();
|
|
61
|
+
const { appearanceOutput } = useCurrentAgent();
|
|
62
|
+
const { message } = useCurrentMessage();
|
|
63
|
+
const { session: authSession } = useSessionContext();
|
|
64
|
+
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
66
65
|
return null;
|
|
67
|
-
return
|
|
66
|
+
// return <CustomComponentRenderer componentId={input.componentId} properties={input.componentProps} props={{hideAvatar: false}} />;
|
|
67
|
+
return (_jsxs(Stack, { gap: 2, children: [_jsx(Box, { children: _jsx(UserInfo, { name: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.fullName, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, avatar: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps, props: {
|
|
68
|
+
renderType: 'parameters',
|
|
69
|
+
} }) }) }), _jsx(Box, { children: _jsx(UserInfo, { name: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, avatar: (_e = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.logo) === null || _e === void 0 ? void 0 : _e.url, time: message.createdAt, alignItems: "flex-start", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps, props: {
|
|
70
|
+
renderType: 'result',
|
|
71
|
+
} }) }) })] }));
|
|
68
72
|
}
|
|
69
73
|
function SuggestedQuestionsView() {
|
|
70
74
|
const { execute } = useRuntimeState();
|
package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Stack } from '@mui/material';
|
|
|
3
3
|
import { MessageMetadataRenderer } from '../../../common';
|
|
4
4
|
import MarkdownRenderer from '../../../MarkdownRenderer';
|
|
5
5
|
import { useCurrentMessage } from '../../contexts/CurrentMessage';
|
|
6
|
-
export default function
|
|
6
|
+
export default function SimpleOutput() {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const { message } = useCurrentMessage();
|
|
9
9
|
const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
|