@blocklet/pages-kit 0.2.291 → 0.2.293
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/api/assistant.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +14 -1
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +5 -3
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +1 -9
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +5 -1
- package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +16 -9
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +14 -3
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +65 -29
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +6 -5
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/RadioField.js +39 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +5 -1
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/AutoForm/index.js +153 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageErrorView.js +19 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +179 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +13 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +129 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +117 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +109 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +17 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +87 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +27 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/contexts/CurrentMessage.js +19 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/index.js +42 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/assistant.js +61 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/runtime.js +56 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/session.js +213 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/utils/map-right.js +10 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +42 -20
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +12 -5
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +5 -6
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +3 -6
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +4 -0
- package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +16 -7
- package/lib/cjs/builtin/async/ai-runtime/hooks/auth.js +31 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +29 -19
- package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +6 -4
- package/lib/cjs/builtin/async/ai-runtime/index.js +38 -30
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +28 -0
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +15 -18
- package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +4 -4
- package/lib/cjs/components/CustomComponentRenderer/index.js +0 -1
- package/lib/cjs/components/CustomComponentRenderer/state.js +64 -57
- package/lib/cjs/components/index.js +1 -0
- package/lib/esm/builtin/async/ai-runtime/api/assistant.js +2 -1
- package/lib/esm/builtin/async/ai-runtime/api/message.js +14 -1
- package/lib/esm/builtin/async/ai-runtime/api/request.js +5 -3
- package/lib/esm/builtin/async/ai-runtime/api/session.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +2 -10
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +4 -4
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +5 -1
- package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +16 -9
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +14 -3
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +65 -31
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +6 -5
- package/lib/esm/builtin/async/ai-runtime/components/parameters/RadioField.js +37 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +5 -1
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/AutoForm/index.js +146 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageErrorView.js +13 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +149 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +7 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +100 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +114 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +80 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +11 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +58 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/contexts/CurrentMessage.js +14 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/index.js +36 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/assistant.js +56 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/runtime.js +52 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/session.js +209 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime/utils/map-right.js +7 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +21 -22
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +13 -6
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +5 -6
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +3 -6
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +4 -0
- package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +9 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/auth.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/header.js +30 -20
- package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +6 -4
- package/lib/esm/builtin/async/ai-runtime/index.js +15 -29
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +28 -0
- package/lib/esm/builtin/async/ai-runtime/state/session.js +17 -20
- package/lib/esm/builtin/async/ai-runtime/state/subscription.js +2 -2
- package/lib/esm/components/CustomComponentRenderer/index.js +0 -1
- package/lib/esm/components/CustomComponentRenderer/state.js +63 -57
- package/lib/esm/components/index.js +1 -0
- package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +4 -2
- package/lib/types/builtin/async/ai-runtime/api/message.d.ts +9 -2
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +4 -1
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +3 -2
- package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +3 -2
- package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +5 -2
- package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +4 -5
- package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +11 -4
- package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -3
- package/lib/types/builtin/async/ai-runtime/components/parameters/RadioField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/AutoForm/index.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageErrorView.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.d.ts +12 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.d.ts +12 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/contexts/CurrentMessage.d.ts +10 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/assistant.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/runtime.d.ts +14 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/session.d.ts +29 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime/utils/map-right.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/hooks/auth.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +15 -8
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +22 -0
- package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +1 -1
- package/lib/types/components/CustomComponentRenderer/index.d.ts +0 -1
- package/lib/types/components/CustomComponentRenderer/state.d.ts +2 -3
- package/lib/types/components/index.d.ts +1 -0
- package/lib/types/types/core.d.ts +1 -0
- package/package.json +9 -7
|
@@ -1,4 +1,27 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -26,7 +49,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
49
|
exports.EntryListView = void 0;
|
|
27
50
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
51
|
const material_1 = require("@mui/material");
|
|
29
|
-
const omit_1 = __importDefault(require("lodash/omit"));
|
|
30
52
|
const react_1 = require("react");
|
|
31
53
|
const session_1 = require("../../../../session");
|
|
32
54
|
const session_2 = require("../../api/session");
|
|
@@ -35,16 +57,22 @@ const loading_1 = require("../../state/loading");
|
|
|
35
57
|
const session_3 = require("../../state/session");
|
|
36
58
|
const MessageSuggestedQuestions_1 = require("../common/MessageSuggestedQuestions");
|
|
37
59
|
const ParameterForm_1 = __importDefault(require("../form/ParameterForm"));
|
|
38
|
-
const
|
|
60
|
+
const MessageErrorView_1 = __importDefault(require("../message/MessageErrorView"));
|
|
61
|
+
const MessageItemView_1 = __importStar(require("../message/MessageItemView"));
|
|
39
62
|
const PoweredBy_1 = __importDefault(require("../PoweredBy"));
|
|
40
63
|
function InitialForm({ page }) {
|
|
41
|
-
var _a;
|
|
64
|
+
var _a, _b;
|
|
42
65
|
const { assistantId } = page;
|
|
43
66
|
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
44
67
|
const [assistant] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
|
|
45
|
-
const { parameters } = assistant;
|
|
46
68
|
const [error, setError] = (0, react_1.useState)();
|
|
47
|
-
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (error && authSession.user && ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
72
|
+
onSubmit(error.parameters);
|
|
73
|
+
setError(undefined);
|
|
74
|
+
}
|
|
75
|
+
}, [authSession.user]);
|
|
48
76
|
const opener = (0, react_1.useMemo)(() => {
|
|
49
77
|
var _a;
|
|
50
78
|
const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
|
|
@@ -52,6 +80,7 @@ function InitialForm({ page }) {
|
|
|
52
80
|
return {
|
|
53
81
|
taskId: '',
|
|
54
82
|
sessionId: '',
|
|
83
|
+
assistantId: '',
|
|
55
84
|
createdAt: new Date().toISOString(),
|
|
56
85
|
updatedAt: new Date().toISOString(),
|
|
57
86
|
result: { content: openerMessage },
|
|
@@ -60,14 +89,7 @@ function InitialForm({ page }) {
|
|
|
60
89
|
return undefined;
|
|
61
90
|
}, [assistant.release]);
|
|
62
91
|
const [creating, setCreating] = (0, react_1.useState)(false);
|
|
63
|
-
const onSubmit = (
|
|
64
|
-
if (!authSession.user) {
|
|
65
|
-
yield new Promise((resolve) => {
|
|
66
|
-
authSession.login(() => {
|
|
67
|
-
resolve();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
92
|
+
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
71
93
|
if (creating)
|
|
72
94
|
return;
|
|
73
95
|
setCreating(true);
|
|
@@ -75,20 +97,20 @@ function InitialForm({ page }) {
|
|
|
75
97
|
yield loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
|
|
76
98
|
const { created: session } = yield (0, session_2.createSession)({
|
|
77
99
|
assistantId,
|
|
78
|
-
name: parameters.question,
|
|
79
|
-
parameters
|
|
80
|
-
entry,
|
|
100
|
+
name: typeof (parameters === null || parameters === void 0 ? void 0 : parameters.question) === 'string' ? parameters.question : undefined,
|
|
101
|
+
parameters,
|
|
81
102
|
});
|
|
82
103
|
(0, session_3.createSessionState)({ sessionId: session.id, session }).getState().execute({
|
|
83
104
|
assistantId,
|
|
84
105
|
parameters,
|
|
85
106
|
});
|
|
86
|
-
setError(undefined);
|
|
87
107
|
page.navigate({ page: 'session', assistantId, sessionId: session.id });
|
|
88
108
|
}));
|
|
109
|
+
setError(undefined);
|
|
89
110
|
}
|
|
90
111
|
catch (error) {
|
|
91
|
-
setError(error);
|
|
112
|
+
setError({ error, parameters });
|
|
113
|
+
throw error;
|
|
92
114
|
}
|
|
93
115
|
finally {
|
|
94
116
|
setCreating(false);
|
|
@@ -96,11 +118,11 @@ function InitialForm({ page }) {
|
|
|
96
118
|
});
|
|
97
119
|
if (authSession.loading)
|
|
98
120
|
return null;
|
|
99
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [
|
|
121
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 5, mb: 5, px: 2 }, children: [opener && ((0, jsx_runtime_1.jsx)(material_1.Box, { mb: 2, children: (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { page: page, message: opener }) })), ((_a = assistant.entries) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(entry.parameters), sx: { pl: 6.5, pr: 2.5 } })), error && ((0, jsx_runtime_1.jsx)(MessageItemView_1.MessageItemWrapper, { assistant: assistant, agentMessage: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: error.error, page: page }), sx: { mt: 2 } }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-runtime-form-container", sx: {
|
|
100
122
|
position: 'sticky',
|
|
101
123
|
bottom: 0,
|
|
102
124
|
background: (theme) => `linear-gradient(180deg, ${(0, material_1.alpha)(theme.palette.background.default, 0.1)}, ${(0, material_1.alpha)(theme.palette.background.default, 1)} 16px)`,
|
|
103
|
-
}, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, {
|
|
125
|
+
}, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, { disabled: ((_b = error === null || error === void 0 ? void 0 : error.error) === null || _b === void 0 ? void 0 : _b.status) === 401, page: page, assistant: assistant, onSubmit: onSubmit }), (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { my: 1, px: 2 } })] })] }));
|
|
104
126
|
}
|
|
105
127
|
exports.default = InitialForm;
|
|
106
128
|
function EntryListView(_a) {
|
|
@@ -11,6 +11,8 @@ const assistant_1 = require("../../state/assistant");
|
|
|
11
11
|
const session_1 = require("../../state/session");
|
|
12
12
|
const common_1 = require("../common");
|
|
13
13
|
const ParameterForm_1 = __importDefault(require("../form/ParameterForm"));
|
|
14
|
+
const MessageErrorView_1 = __importDefault(require("../message/MessageErrorView"));
|
|
15
|
+
const MessageItemView_1 = require("../message/MessageItemView");
|
|
14
16
|
const MessageListView_1 = __importDefault(require("../message/MessageListView"));
|
|
15
17
|
const PoweredBy_1 = __importDefault(require("../PoweredBy"));
|
|
16
18
|
const ScrollView_1 = require("../ScrollView");
|
|
@@ -36,17 +38,22 @@ function RuntimeChatSession({ page }) {
|
|
|
36
38
|
setError(undefined);
|
|
37
39
|
})
|
|
38
40
|
.catch((error) => {
|
|
39
|
-
setError(error);
|
|
41
|
+
setError({ error, parameters });
|
|
40
42
|
});
|
|
41
43
|
};
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
45
|
+
mb: {
|
|
46
|
+
xs: 1,
|
|
47
|
+
md: 2,
|
|
48
|
+
},
|
|
49
|
+
}, children: [(0, jsx_runtime_1.jsx)(MessageListView_1.default, { className: "ai-chat-message-list", my: 5, px: 2, page: page }), (0, jsx_runtime_1.jsx)(material_1.Box, { ml: 6.5, mr: 2.5, mt: -4, px: 2, children: (suggestedQuestions === null || suggestedQuestions === void 0 ? void 0 : suggestedQuestions.length) ? ((0, jsx_runtime_1.jsx)(common_1.MessageSuggestedQuestions, { dataSource: suggestedQuestions, onClick: (item) => {
|
|
50
|
+
onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), { question: item.question }));
|
|
51
|
+
} })) : !((_e = state.messages) === null || _e === void 0 ? void 0 : _e.length) && ((_f = assistant.entries) === null || _f === void 0 ? void 0 : _f.length) ? ((0, jsx_runtime_1.jsx)(InitialForm_1.EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), entry.parameters)) })) : null }), error && ((0, jsx_runtime_1.jsx)(MessageItemView_1.MessageItemWrapper, { assistant: assistant, agentMessage: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: error.error, page: page }), sx: { mt: 2, px: 2 } }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-runtime-form-container", sx: {
|
|
45
52
|
pt: 2,
|
|
46
53
|
position: 'sticky',
|
|
47
54
|
bottom: 0,
|
|
48
55
|
// 从上透明到白色 0.72 的径向渐变
|
|
49
56
|
background: (theme) => `linear-gradient(180deg, ${(0, material_1.alpha)(theme.palette.background.default, 0.1)}, ${(0, material_1.alpha)(theme.palette.background.default, 1)} 16px)`,
|
|
50
|
-
}, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, {
|
|
57
|
+
}, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, { page: page, defaultValues: lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters, assistant: assistant, onSubmit: onSubmit, isSubmitting: state.running }), (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { my: 0.5, px: 2 } })] })] }));
|
|
51
58
|
}
|
|
52
59
|
exports.default = RuntimeChatSession;
|
|
@@ -67,12 +67,16 @@ function RuntimeFormForms(_a) {
|
|
|
67
67
|
const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
|
|
68
68
|
const [error, setError] = (0, react_2.useState)();
|
|
69
69
|
const [expand, setExpand] = (0, react_2.useState)(false);
|
|
70
|
-
const { session } = (0, session_1.useSessionContext)();
|
|
70
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
71
71
|
const [submitting, setSubmitting] = (0, react_2.useState)(false);
|
|
72
72
|
(0, react_2.useEffect)(() => {
|
|
73
73
|
form.reset(defaultForm);
|
|
74
74
|
}, [defaultForm]);
|
|
75
75
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (!authSession.user) {
|
|
77
|
+
// TODO:
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
76
80
|
try {
|
|
77
81
|
setSubmitting(true);
|
|
78
82
|
let { sessionId } = page;
|
|
@@ -104,11 +108,6 @@ function RuntimeFormForms(_a) {
|
|
|
104
108
|
const handleSubmit = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
105
109
|
var _e;
|
|
106
110
|
e.preventDefault();
|
|
107
|
-
if (!session.user) {
|
|
108
|
-
yield new Promise((resolve) => {
|
|
109
|
-
session.login(() => resolve());
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
111
|
(_e = agent.parameters) === null || _e === void 0 ? void 0 : _e.some((parameter) => {
|
|
113
112
|
if (parameter.required && (0, isEmpty_1.default)(form.getValues(parameter.key))) {
|
|
114
113
|
setExpand(true);
|
|
@@ -17,18 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
18
|
const material_1 = require("@mui/material");
|
|
19
19
|
const react_1 = require("react");
|
|
20
|
-
const assistant_1 = require("../../state/assistant");
|
|
21
20
|
const session_1 = require("../../state/session");
|
|
22
21
|
const MessageItemView_1 = __importDefault(require("../message/MessageItemView"));
|
|
23
22
|
function RuntimeFormResult(_a) {
|
|
24
23
|
var { page } = _a, props = __rest(_a, ["page"]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: page.
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: page.page === 'session' && (0, jsx_runtime_1.jsx)(ResultView, { page: page }) }) }) })));
|
|
26
25
|
}
|
|
27
26
|
exports.default = RuntimeFormResult;
|
|
28
27
|
function ResultView({ page }) {
|
|
29
|
-
const {
|
|
30
|
-
const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
|
|
31
|
-
const [, { messages = [] }] = (0, session_1.useSessionState)({ sessionId });
|
|
28
|
+
const [, { messages = [] }] = (0, session_1.useSessionState)(page);
|
|
32
29
|
const message = messages[messages.length - 1];
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, children: message && (
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, children: message && (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { hideAvatar: true, page: page, message: message }, message.taskId) }));
|
|
34
31
|
}
|
|
@@ -35,6 +35,10 @@ function RuntimeForm({ page }) {
|
|
|
35
35
|
display: 'flex',
|
|
36
36
|
flexDirection: 'column',
|
|
37
37
|
justifyContent: 'space-between',
|
|
38
|
+
mb: {
|
|
39
|
+
xs: 1,
|
|
40
|
+
md: 0,
|
|
41
|
+
},
|
|
38
42
|
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: isMobile ? spacing : 1, spacing: spacing, children: [(0, jsx_runtime_1.jsx)(RuntimeFormHeader_1.default, { agent: agent }), (0, jsx_runtime_1.jsx)(RuntimeFormResult_1.default, { page: page })] }), !isMobile && (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { mt: spacing, mb: 0.5, px: 2, pt: 0 } })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
39
43
|
flex: {
|
|
40
44
|
md: 1,
|
|
@@ -13,27 +13,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const react_1 = require("react");
|
|
16
|
-
const session_1 = require("
|
|
16
|
+
const session_1 = require("../../../../session");
|
|
17
|
+
const session_2 = require("../../api/session");
|
|
17
18
|
const useAsync_1 = __importDefault(require("../../hooks/useAsync"));
|
|
18
19
|
const assistant_1 = require("../../state/assistant");
|
|
19
20
|
const loading_1 = require("../../state/loading");
|
|
20
|
-
const
|
|
21
|
+
const session_3 = require("../../state/session");
|
|
21
22
|
const utils_1 = require("../../utils");
|
|
22
23
|
function CheckSession({ cacheId, page, autoCreateSession, children, }) {
|
|
24
|
+
var _a;
|
|
23
25
|
const { assistantId, sessionId } = page;
|
|
24
26
|
(0, assistant_1.useAssistantState)({ assistantId });
|
|
25
27
|
const result = (0, useAsync_1.default)(() => {
|
|
26
|
-
if (sessionId && (0,
|
|
28
|
+
if (sessionId && (0, session_3.createSessionState)({ sessionId }).getState().session)
|
|
27
29
|
return undefined;
|
|
28
30
|
return loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
|
|
29
31
|
var _a;
|
|
30
32
|
if (!sessionId) {
|
|
31
33
|
try {
|
|
32
34
|
// get the last session or create a new session if `autoCreateSession` is enabled
|
|
33
|
-
const { sessions } = yield (0,
|
|
34
|
-
const session = (_a = sessions[0]) !== null && _a !== void 0 ? _a : (autoCreateSession ? (yield (0,
|
|
35
|
+
const { sessions } = yield (0, session_2.getSessions)((0, utils_1.parseIdentity)(assistantId, { rejectWhenError: true }));
|
|
36
|
+
const session = (_a = sessions[0]) !== null && _a !== void 0 ? _a : (autoCreateSession ? (yield (0, session_2.createSession)({ assistantId })).created : undefined);
|
|
35
37
|
if (session) {
|
|
36
|
-
yield (0,
|
|
38
|
+
yield (0, session_3.createSessionState)({ sessionId: session.id, session }).getState().load();
|
|
37
39
|
return [{ page: 'session', assistantId, sessionId: session.id }];
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -43,7 +45,7 @@ function CheckSession({ cacheId, page, autoCreateSession, children, }) {
|
|
|
43
45
|
}
|
|
44
46
|
else {
|
|
45
47
|
try {
|
|
46
|
-
const state = (0,
|
|
48
|
+
const state = (0, session_3.createSessionState)({ sessionId });
|
|
47
49
|
yield state.getState().load();
|
|
48
50
|
}
|
|
49
51
|
catch (error) {
|
|
@@ -58,6 +60,13 @@ function CheckSession({ cacheId, page, autoCreateSession, children, }) {
|
|
|
58
60
|
if (result)
|
|
59
61
|
page.navigate(...result);
|
|
60
62
|
}, [result, page.navigate]);
|
|
63
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
64
|
+
(0, react_1.useEffect)(() => {
|
|
65
|
+
var _a;
|
|
66
|
+
if (!((_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did)) {
|
|
67
|
+
page.navigate({ page: 'assistant', assistantId: page.assistantId, sessionId: undefined }, { replace: true });
|
|
68
|
+
}
|
|
69
|
+
}, [(_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
|
|
61
70
|
if (result)
|
|
62
71
|
return null;
|
|
63
72
|
return children;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useLogin = void 0;
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const session_1 = require("../../../session");
|
|
15
|
+
const assistant_1 = require("../state/assistant");
|
|
16
|
+
const session_2 = require("../state/session");
|
|
17
|
+
const subscription_1 = require("../state/subscription");
|
|
18
|
+
function useLogin({ page }) {
|
|
19
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
20
|
+
return (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield new Promise((resolve) => {
|
|
22
|
+
authSession.login(() => resolve());
|
|
23
|
+
});
|
|
24
|
+
yield Promise.all([
|
|
25
|
+
(0, assistant_1.createAssistantState)({ assistantId: page.assistantId }).getState().load(),
|
|
26
|
+
(0, subscription_1.createSubscriptionState)({ aid: page.assistantId }).getState().load(),
|
|
27
|
+
page.sessionId && (0, session_2.createSessionState)({ sessionId: page.sessionId }).getState().load(),
|
|
28
|
+
]);
|
|
29
|
+
}), [authSession, page]);
|
|
30
|
+
}
|
|
31
|
+
exports.useLogin = useLogin;
|
|
@@ -11,13 +11,18 @@ const react_1 = require("react");
|
|
|
11
11
|
const ux_1 = require("../../../arcblock/ux");
|
|
12
12
|
const locale_1 = require("../../../locale");
|
|
13
13
|
const header_1 = require("../../../page/header");
|
|
14
|
+
const session_1 = require("../../../session");
|
|
14
15
|
const SocialShare_1 = __importDefault(require("../components/SocialShare"));
|
|
15
16
|
const ThemeProvider_1 = __importDefault(require("../components/ThemeProvider"));
|
|
16
17
|
const subscribe_1 = require("./subscribe");
|
|
17
18
|
const logoSize = 44;
|
|
18
19
|
function useSetHeader({ assistant, assistantId }) {
|
|
19
|
-
|
|
20
|
+
var _a;
|
|
21
|
+
const { subscribeLink, isPaymentProject } = (0, subscribe_1.useSubscribeLink)({ assistantId });
|
|
22
|
+
const theme = (0, material_1.useTheme)();
|
|
23
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
|
|
20
24
|
const { t, locale } = (0, locale_1.useLocaleContext)();
|
|
25
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
21
26
|
// set logo
|
|
22
27
|
(0, react_1.useEffect)(() => {
|
|
23
28
|
const { release } = assistant;
|
|
@@ -26,27 +31,32 @@ function useSetHeader({ assistant, assistantId }) {
|
|
|
26
31
|
width: logoSize,
|
|
27
32
|
height: logoSize,
|
|
28
33
|
} }));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (!isMobile) {
|
|
35
|
+
state.brand = (release === null || release === void 0 ? void 0 : release.title) || assistant.name;
|
|
36
|
+
state.description = assistant.createdBy && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
37
|
+
display: 'inline-flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
gap: 0.5,
|
|
40
|
+
mt: 0.5,
|
|
41
|
+
}, children: [t('by'), " ", (0, jsx_runtime_1.jsx)(DID_1.default, { did: assistant.createdBy, copyable: false })] }));
|
|
42
|
+
}
|
|
36
43
|
const shareContent = `${(release === null || release === void 0 ? void 0 : release.title) || assistant.name}
|
|
37
44
|
|
|
38
45
|
${release === null || release === void 0 ? void 0 : release.description}
|
|
39
46
|
`;
|
|
40
|
-
state.addons = (...exists) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
state.addons = (...exists) => {
|
|
48
|
+
var _a;
|
|
49
|
+
return [
|
|
50
|
+
((_a = authSession === null || authSession === void 0 ? void 0 : authSession.user) === null || _a === void 0 ? void 0 : _a.did) && isPaymentProject && ((0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { disabled: !subscribeLink, variant: "outlined", href: subscribeLink,
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
color: "black", sx: {
|
|
53
|
+
// 字母不大写
|
|
54
|
+
textTransform: 'none',
|
|
55
|
+
}, children: subscribeLink ? t('subscribe') : t('subscribed') }) })),
|
|
56
|
+
(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }),
|
|
57
|
+
...exists,
|
|
58
|
+
].filter(Boolean);
|
|
59
|
+
};
|
|
50
60
|
});
|
|
51
61
|
return () => header_1.useHeaderState.setState((state) => {
|
|
52
62
|
state.logo = undefined;
|
|
@@ -54,6 +64,6 @@ ${release === null || release === void 0 ? void 0 : release.description}
|
|
|
54
64
|
state.description = undefined;
|
|
55
65
|
state.addons = (...exists) => [...exists];
|
|
56
66
|
});
|
|
57
|
-
}, [locale]);
|
|
67
|
+
}, [locale, isMobile, (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
|
|
58
68
|
}
|
|
59
69
|
exports.useSetHeader = useSetHeader;
|
|
@@ -8,21 +8,23 @@ const constants_1 = require("../constants");
|
|
|
8
8
|
const assistant_1 = require("../state/assistant");
|
|
9
9
|
const subscription_1 = require("../state/subscription");
|
|
10
10
|
function useSubscribeLink({ assistantId }) {
|
|
11
|
-
var _a, _b, _c;
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
12
|
const [, state] = (0, subscription_1.useSubscriptionState)({ aid: assistantId });
|
|
13
13
|
const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
|
|
14
|
-
const { session } = (0, session_1.useSessionContext)();
|
|
14
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
15
15
|
const requireSubscribe = ((_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.enable) && !state.subscription;
|
|
16
|
-
const
|
|
16
|
+
const isPaymentProject = (_d = (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.payment) === null || _d === void 0 ? void 0 : _d.enable;
|
|
17
|
+
const subscribeLink = requireSubscribe && authSession.user && ((_e = state.release) === null || _e === void 0 ? void 0 : _e.paymentLinkId)
|
|
17
18
|
? getSubscribeLink({
|
|
18
19
|
aid: assistantId,
|
|
19
|
-
userId:
|
|
20
|
+
userId: authSession.user.did,
|
|
20
21
|
paymentLinkId: state.release.paymentLinkId,
|
|
21
22
|
})
|
|
22
23
|
: undefined;
|
|
23
24
|
return {
|
|
24
25
|
requireSubscribe,
|
|
25
26
|
subscribeLink,
|
|
27
|
+
isPaymentProject,
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
exports.useSubscribeLink = useSubscribeLink;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
10
15
|
};
|
|
11
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
18
|
};
|
|
14
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ChatBot = exports.
|
|
20
|
+
exports.ChatBot = exports.AIRuntime = exports.PhotoGalleryItem = exports.ChatOutput = exports.BaseOutputs = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.Runtime = void 0;
|
|
16
21
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
22
|
const material_1 = require("@mui/material");
|
|
18
23
|
const react_1 = require("react");
|
|
19
24
|
const react_error_boundary_1 = require("react-error-boundary");
|
|
20
25
|
const ux_1 = require("../../arcblock/ux");
|
|
21
|
-
const utils_1 = require("../../utils");
|
|
22
|
-
const assistant_1 = require("./api/assistant");
|
|
23
26
|
const common_1 = require("./components/common");
|
|
24
27
|
const runtime_chat_1 = __importDefault(require("./components/runtime-chat"));
|
|
25
28
|
const runtime_form_1 = __importDefault(require("./components/runtime-form"));
|
|
@@ -28,36 +31,41 @@ const ScrollView_1 = __importDefault(require("./components/ScrollView"));
|
|
|
28
31
|
const CheckSession_1 = __importDefault(require("./components/session/CheckSession"));
|
|
29
32
|
const header_1 = require("./hooks/header");
|
|
30
33
|
const navigate_1 = require("./hooks/navigate");
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
34
|
+
const assistant_1 = require("./state/assistant");
|
|
35
|
+
__exportStar(require("./components/runtime/contexts/CurrentAgent"), exports);
|
|
36
|
+
__exportStar(require("./components/runtime/contexts/CurrentMessage"), exports);
|
|
37
|
+
__exportStar(require("./components/runtime/state/runtime"), exports);
|
|
38
|
+
__exportStar(require("./components/runtime/state/session"), exports);
|
|
39
|
+
var runtime_1 = require("./components/runtime");
|
|
40
|
+
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return __importDefault(runtime_1).default; } });
|
|
41
|
+
var SimplePage_1 = require("./components/runtime/components/SimplePage");
|
|
42
|
+
Object.defineProperty(exports, "SimplePage", { enumerable: true, get: function () { return __importDefault(SimplePage_1).default; } });
|
|
43
|
+
var SimpleChat_1 = require("./components/runtime/components/SimpleChat");
|
|
44
|
+
Object.defineProperty(exports, "SimpleChat", { enumerable: true, get: function () { return __importDefault(SimpleChat_1).default; } });
|
|
45
|
+
var PhotoGallery_1 = require("./components/runtime/components/PhotoGallery");
|
|
46
|
+
Object.defineProperty(exports, "PhotoGallery", { enumerable: true, get: function () { return __importDefault(PhotoGallery_1).default; } });
|
|
47
|
+
var AutoForm_1 = require("./components/runtime/components/AutoForm");
|
|
48
|
+
Object.defineProperty(exports, "AutoForm", { enumerable: true, get: function () { return __importDefault(AutoForm_1).default; } });
|
|
49
|
+
var SimpleOutput_1 = require("./components/runtime/components/SimpleOutput");
|
|
50
|
+
Object.defineProperty(exports, "BaseOutputs", { enumerable: true, get: function () { return __importDefault(SimpleOutput_1).default; } });
|
|
51
|
+
var ChatOutput_1 = require("./components/runtime/components/ChatOutput");
|
|
52
|
+
Object.defineProperty(exports, "ChatOutput", { enumerable: true, get: function () { return __importDefault(ChatOutput_1).default; } });
|
|
53
|
+
var PhotoGalleryItem_1 = require("./components/runtime/components/PhotoGalleryItem");
|
|
54
|
+
Object.defineProperty(exports, "PhotoGalleryItem", { enumerable: true, get: function () { return __importDefault(PhotoGalleryItem_1).default; } });
|
|
43
55
|
function App(props) {
|
|
44
56
|
const cacheId = (0, react_1.useId)();
|
|
45
57
|
return ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(AIRuntime, Object.assign({}, props, { cacheId: cacheId })) }));
|
|
46
58
|
}
|
|
47
59
|
exports.default = App;
|
|
48
|
-
function AIRuntime({ cacheId
|
|
60
|
+
function AIRuntime({ cacheId }) {
|
|
49
61
|
var _a;
|
|
50
62
|
const page = (0, navigate_1.useCurrentPage)();
|
|
51
63
|
const { assistantId } = page;
|
|
52
|
-
const [assistant] = (0,
|
|
64
|
+
const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
|
|
53
65
|
(0, header_1.useSetHeader)({ assistant, assistantId });
|
|
54
|
-
(0, react_1.useMemo)(() => {
|
|
55
|
-
// preload assistant from server side props
|
|
56
|
-
if (preload)
|
|
57
|
-
(0, assistant_2.createAssistantState)(preload);
|
|
58
|
-
}, []);
|
|
59
66
|
return ((0, jsx_runtime_1.jsx)(CheckSession_1.default, { cacheId: cacheId, page: page, children: (0, jsx_runtime_1.jsx)(ScrollView_1.default, { scroller: "window", initialScrollBehavior: "auto", children: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, height: "100%", className: "ai-runtime-root", children: ((_a = assistant.release) === null || _a === void 0 ? void 0 : _a.template) === 'form' ? (0, jsx_runtime_1.jsx)(runtime_form_1.default, { page: page }) : (0, jsx_runtime_1.jsx)(runtime_chat_1.default, { page: page }) }) }) }));
|
|
60
67
|
}
|
|
68
|
+
exports.AIRuntime = AIRuntime;
|
|
61
69
|
function ChatBot(props) {
|
|
62
70
|
if (!props.assistantId)
|
|
63
71
|
throw new Error('Missing required parameter assistantId');
|
|
@@ -14,6 +14,12 @@ exports.translations = {
|
|
|
14
14
|
shareToLinkedin: 'Share to Linkedin',
|
|
15
15
|
copyLink: 'Copy Link',
|
|
16
16
|
},
|
|
17
|
+
photoWall: {
|
|
18
|
+
dialog: {
|
|
19
|
+
title: 'AI Art Image',
|
|
20
|
+
prompt: 'Prompt',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
17
23
|
questionPlaceholder: 'Ask Anything...',
|
|
18
24
|
parameters: 'Parameters',
|
|
19
25
|
parametersTitle: 'Tell me what do you want?',
|
|
@@ -53,6 +59,12 @@ exports.translations = {
|
|
|
53
59
|
Subscribe now to unlock more possibilities!`,
|
|
54
60
|
requireNewSubscriptionFooter: 'You need to subscribe to access this feature:',
|
|
55
61
|
thanksForSubscription: 'Thanks for subscribing, now you can start enjoying it!',
|
|
62
|
+
requireLogin: `Thank you for using our service!
|
|
63
|
+
|
|
64
|
+
In order to use our service properly, please click below to log in now!
|
|
65
|
+
`,
|
|
66
|
+
thanksForLogin: 'Now you can start experiencing it to the fullest!',
|
|
67
|
+
loginNow: 'Login Now',
|
|
56
68
|
clickTheButton: 'Click The Button 👉',
|
|
57
69
|
cleanSessionTip: 'Clean conversation messages',
|
|
58
70
|
poweredBy: 'Powered by',
|
|
@@ -77,6 +89,8 @@ exports.translations = {
|
|
|
77
89
|
uploadFile: 'Upload File',
|
|
78
90
|
submit: 'Submit',
|
|
79
91
|
send: 'Send',
|
|
92
|
+
session: 'Session',
|
|
93
|
+
loadMore: 'Load More',
|
|
80
94
|
},
|
|
81
95
|
zh: {
|
|
82
96
|
by: '来自',
|
|
@@ -90,6 +104,12 @@ exports.translations = {
|
|
|
90
104
|
shareToLinkedin: '分享到 Linkedin',
|
|
91
105
|
copyLink: '复制链接',
|
|
92
106
|
},
|
|
107
|
+
photoWall: {
|
|
108
|
+
dialog: {
|
|
109
|
+
title: 'AI 艺术图片',
|
|
110
|
+
prompt: '提示词',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
93
113
|
questionPlaceholder: '问点什么...',
|
|
94
114
|
parameters: '参数',
|
|
95
115
|
parametersTitle: '告诉我你想要什么?',
|
|
@@ -129,6 +149,12 @@ exports.translations = {
|
|
|
129
149
|
立即订阅以解锁更多可能性!`,
|
|
130
150
|
requireNewSubscriptionFooter: '您需要订阅才能访问此功能:',
|
|
131
151
|
thanksForSubscription: '感谢您的订阅,现在,您可以开始尽情体验了!',
|
|
152
|
+
requireLogin: `感谢您使用我们的服务!
|
|
153
|
+
|
|
154
|
+
为了能正常使用我们的服务,请点击下方立即登录!
|
|
155
|
+
`,
|
|
156
|
+
thanksForLogin: '现在,您可以开始尽情体验了!',
|
|
157
|
+
loginNow: '立即登录',
|
|
132
158
|
clickTheButton: '点我生成 👉',
|
|
133
159
|
cleanSessionTip: '清除会话消息记录',
|
|
134
160
|
poweredBy: '技术支持来自',
|
|
@@ -153,5 +179,7 @@ exports.translations = {
|
|
|
153
179
|
uploadFile: '上传文件',
|
|
154
180
|
submit: '提交',
|
|
155
181
|
send: '发送',
|
|
182
|
+
session: '会话',
|
|
183
|
+
loadMore: '加载更多',
|
|
156
184
|
},
|
|
157
185
|
};
|