@blocklet/pages-kit 0.2.285 → 0.2.287
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 +26 -0
- package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +127 -0
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +33 -0
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +47 -0
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +121 -0
- package/lib/cjs/builtin/async/ai-runtime/api/subscription.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +63 -0
- package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +60 -0
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +40 -0
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +51 -0
- package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +156 -0
- package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +43 -0
- package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +30 -0
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +109 -0
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +102 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +193 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +105 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +35 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +12 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +48 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +66 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +43 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +44 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +76 -0
- package/lib/cjs/builtin/async/ai-runtime/components/layout/index.js +15 -0
- package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +134 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +48 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +94 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +48 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +67 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +15 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +103 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +62 -0
- package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
- package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +37 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
- package/lib/cjs/builtin/async/ai-runtime/index.js +75 -0
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +147 -0
- package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +59 -0
- package/lib/cjs/builtin/async/ai-runtime/state/index.js +423 -0
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
- package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
- package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
- package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
- package/lib/cjs/utils/builtin.js +1 -0
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
- package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
- package/lib/esm/builtin/async/ai-runtime/api/request.js +43 -0
- package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
- package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
- package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +56 -0
- package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
- package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +48 -0
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
- package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
- package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +10 -0
- package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
- package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +99 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +42 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +37 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +73 -0
- package/lib/esm/builtin/async/ai-runtime/components/layout/index.js +12 -0
- package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +8 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageActions.js +35 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +24 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +105 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +42 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +8 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/LanguageField.js +53 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/NumberField.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/StringField.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +31 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +88 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +15 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +61 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +9 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +97 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
- package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
- package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
- package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/header.js +25 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +31 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
- package/lib/esm/builtin/async/ai-runtime/index.js +66 -0
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
- package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
- package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
- package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
- package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
- package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
- package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
- package/lib/esm/utils/builtin.js +1 -0
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
- package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
- package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
- package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
- package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
- package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +33 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
- package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
- package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
- package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +8 -0
- package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
- package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/layout/index.d.ts +7 -0
- package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +10 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
- package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
- package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
- package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
- package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
- package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
- package/lib/types/builtin/session.d.ts +11 -1
- package/lib/types/utils/builtin.d.ts +1 -0
- package/package.json +13 -8
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ChatBot = exports.getServerSideProps = void 0;
|
|
16
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
+
const material_1 = require("@mui/material");
|
|
18
|
+
const react_1 = require("react");
|
|
19
|
+
const utils_1 = require("../../utils");
|
|
20
|
+
const assistant_1 = require("./api/assistant");
|
|
21
|
+
const common_1 = require("./components/common");
|
|
22
|
+
const runtime_chat_1 = __importDefault(require("./components/runtime-chat"));
|
|
23
|
+
const runtime_form_1 = __importDefault(require("./components/runtime-form"));
|
|
24
|
+
const RuntimeProvider_1 = __importDefault(require("./components/RuntimeProvider"));
|
|
25
|
+
const ScrollView_1 = __importDefault(require("./components/ScrollView"));
|
|
26
|
+
const CheckSession_1 = __importDefault(require("./components/session/CheckSession"));
|
|
27
|
+
const header_1 = require("./hooks/header");
|
|
28
|
+
const navigate_1 = require("./hooks/navigate");
|
|
29
|
+
const assistant_2 = require("./state/assistant");
|
|
30
|
+
const utils_2 = require("./utils");
|
|
31
|
+
function getServerSideProps() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const query = (0, utils_1.getQuery)(globalThis.location.href);
|
|
34
|
+
const assistantId = typeof query.assistantId === 'string' ? query.assistantId : undefined;
|
|
35
|
+
const identity = assistantId ? (0, utils_2.parseIdentity)(assistantId) : undefined;
|
|
36
|
+
const assistant = identity && (yield (0, assistant_1.getAssistant)(identity));
|
|
37
|
+
return { props: { preload: assistantId ? { assistantId, assistant } : undefined } };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.getServerSideProps = getServerSideProps;
|
|
41
|
+
function AIRuntime({ preload }) {
|
|
42
|
+
const { assistantId, sessionId } = (0, navigate_1.useCurrentPage)();
|
|
43
|
+
const navigate = (0, navigate_1.useNavigateWithQuery)();
|
|
44
|
+
(0, react_1.useMemo)(() => {
|
|
45
|
+
// preload assistant from server side props
|
|
46
|
+
if (preload)
|
|
47
|
+
(0, assistant_2.createAssistantState)(preload);
|
|
48
|
+
}, []);
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(CheckSession_1.default, { assistantId: assistantId, sessionId: sessionId, navigate: navigate, 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: (0, jsx_runtime_1.jsx)(Main, {}) }) }) }) }));
|
|
50
|
+
}
|
|
51
|
+
exports.default = AIRuntime;
|
|
52
|
+
function Main() {
|
|
53
|
+
var _a;
|
|
54
|
+
const page = (0, navigate_1.useCurrentPage)();
|
|
55
|
+
const [assistant] = (0, assistant_2.useAssistantState)({ assistantId: page.assistantId });
|
|
56
|
+
(0, header_1.useSetHeader)({ assistant });
|
|
57
|
+
if (((_a = assistant.release) === null || _a === void 0 ? void 0 : _a.template) === 'form') {
|
|
58
|
+
return (0, jsx_runtime_1.jsx)(runtime_form_1.default, { page: page });
|
|
59
|
+
}
|
|
60
|
+
return (0, jsx_runtime_1.jsx)(runtime_chat_1.default, { page: page });
|
|
61
|
+
}
|
|
62
|
+
function ChatBot(props) {
|
|
63
|
+
if (!props.assistantId)
|
|
64
|
+
throw new Error('Missing required parameter assistantId');
|
|
65
|
+
const navigate = (0, react_1.useCallback)((page) => {
|
|
66
|
+
setPage((state) => (Object.assign(Object.assign({}, state), page)));
|
|
67
|
+
}, []);
|
|
68
|
+
const [page, setPage] = (0, react_1.useState)({
|
|
69
|
+
page: 'assistant',
|
|
70
|
+
assistantId: props.assistantId,
|
|
71
|
+
navigate,
|
|
72
|
+
});
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(CheckSession_1.default, { assistantId: props.assistantId, autoCreateSession: true, navigate: page.navigate, children: (0, jsx_runtime_1.jsx)(common_1.ChatBot, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(runtime_chat_1.default, { page: page }) })) }) }));
|
|
74
|
+
}
|
|
75
|
+
exports.ChatBot = ChatBot;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translations = void 0;
|
|
4
|
+
exports.translations = {
|
|
5
|
+
en: {
|
|
6
|
+
socialShare: {
|
|
7
|
+
shareToX: 'Share to X',
|
|
8
|
+
shareToTelegram: 'Share to Telegram',
|
|
9
|
+
shareToReddit: 'Share to Reddit',
|
|
10
|
+
shareToWeibo: 'Share to Weibo',
|
|
11
|
+
shareToFacebook: 'Share to Facebook',
|
|
12
|
+
shareToLinkedin: 'Share to Linkedin',
|
|
13
|
+
copyLink: 'Copy Link',
|
|
14
|
+
},
|
|
15
|
+
questionPlaceholder: 'Ask Anything...',
|
|
16
|
+
parameters: 'Parameters',
|
|
17
|
+
parametersTitle: 'Tell me what do you want?',
|
|
18
|
+
parametersSetting: 'Setting',
|
|
19
|
+
clearSession: 'Clear Session',
|
|
20
|
+
generate: 'Generate',
|
|
21
|
+
startChat: 'Start Chat',
|
|
22
|
+
collections: 'Collections',
|
|
23
|
+
collection: 'Collection',
|
|
24
|
+
collectionName: 'Collection Name',
|
|
25
|
+
document: 'Document',
|
|
26
|
+
rename: 'Rename',
|
|
27
|
+
delete: 'Delete',
|
|
28
|
+
confirmDelete: 'Confirm Delete?',
|
|
29
|
+
noData: 'No {data} yet',
|
|
30
|
+
createObject: 'Create {object}',
|
|
31
|
+
title: 'Title',
|
|
32
|
+
titlePlaceholder: 'Title',
|
|
33
|
+
content: 'Content',
|
|
34
|
+
contentPlaceholder: 'Write anything...',
|
|
35
|
+
cancel: 'Cancel',
|
|
36
|
+
save: 'Save',
|
|
37
|
+
edit: 'Edit',
|
|
38
|
+
chat: 'Chat',
|
|
39
|
+
subscribeNow: 'Subscribe Now',
|
|
40
|
+
requireNewSubscription: `Thank you for using our service!
|
|
41
|
+
|
|
42
|
+
To get more features and exclusive content, please subscribe to our service. After subscribing, you will enjoy the following privileges:
|
|
43
|
+
|
|
44
|
+
- Unlock all features and tools
|
|
45
|
+
- Support us to continue to provide quality services
|
|
46
|
+
|
|
47
|
+
Pricing: {price} ABT/Message
|
|
48
|
+
|
|
49
|
+
Subscribe now to unlock more possibilities!`,
|
|
50
|
+
requireNewSubscriptionFooter: 'You need to subscribe to access this feature:',
|
|
51
|
+
thanksForSubscription: 'Thanks for subscribing, now you can start enjoying it!',
|
|
52
|
+
clickTheButton: 'Click The Button 👉',
|
|
53
|
+
cleanSessionTip: 'Clean conversation messages',
|
|
54
|
+
poweredBy: 'Powered by',
|
|
55
|
+
selectPromptToStart: 'Select a prompt to get started',
|
|
56
|
+
history: 'History',
|
|
57
|
+
unnamed: 'Unnamed',
|
|
58
|
+
newObject: 'New {object}',
|
|
59
|
+
editObject: 'Edit {object}',
|
|
60
|
+
name: 'Name',
|
|
61
|
+
description: 'Description',
|
|
62
|
+
create: 'Create',
|
|
63
|
+
back: 'Back',
|
|
64
|
+
unauthorized: 'Unauthorized',
|
|
65
|
+
unauthorizedDescription: 'Please log in to visit this page',
|
|
66
|
+
login: 'Login',
|
|
67
|
+
copy: 'Copy',
|
|
68
|
+
copied: 'Copied',
|
|
69
|
+
copyToClipboard: 'Copy to clipboard',
|
|
70
|
+
saveToNoteTip: 'Save to collection',
|
|
71
|
+
saveToNote: 'Save',
|
|
72
|
+
savedToNote: 'Saved as a new document',
|
|
73
|
+
uploadFile: 'Upload File',
|
|
74
|
+
submit: 'Submit',
|
|
75
|
+
},
|
|
76
|
+
zh: {
|
|
77
|
+
socialShare: {
|
|
78
|
+
shareToX: '分享到 X',
|
|
79
|
+
shareToTelegram: '分享到 Telegram',
|
|
80
|
+
shareToReddit: '分享到 Reddit',
|
|
81
|
+
shareToWeibo: '分享到 微博',
|
|
82
|
+
shareToFacebook: '分享到 Facebook',
|
|
83
|
+
shareToLinkedin: '分享到 Linkedin',
|
|
84
|
+
copyLink: '复制链接',
|
|
85
|
+
},
|
|
86
|
+
questionPlaceholder: '问点什么...',
|
|
87
|
+
parameters: '参数',
|
|
88
|
+
parametersTitle: '告诉我你想要什么?',
|
|
89
|
+
parametersSetting: '设置',
|
|
90
|
+
clearSession: '清空对话',
|
|
91
|
+
generate: '生成',
|
|
92
|
+
startChat: '开始对话',
|
|
93
|
+
collections: '知识库',
|
|
94
|
+
collection: '知识库',
|
|
95
|
+
collectionName: '知识库名称',
|
|
96
|
+
document: '文档',
|
|
97
|
+
rename: '重命名',
|
|
98
|
+
delete: '删除',
|
|
99
|
+
confirmDelete: '确定删除?',
|
|
100
|
+
noData: '暂无{data}',
|
|
101
|
+
createObject: '创建{object}',
|
|
102
|
+
title: '标题',
|
|
103
|
+
titlePlaceholder: '标题',
|
|
104
|
+
content: '内容',
|
|
105
|
+
contentPlaceholder: '写点什么吧...',
|
|
106
|
+
cancel: '取消',
|
|
107
|
+
save: '保存',
|
|
108
|
+
edit: '编辑',
|
|
109
|
+
chat: '对话',
|
|
110
|
+
subscribeNow: '立即订阅',
|
|
111
|
+
requireNewSubscription: `感谢您使用我们的服务!
|
|
112
|
+
|
|
113
|
+
为了获得更多功能和专属内容,请订阅我们的服务。订阅后,您将享有以下特权:
|
|
114
|
+
|
|
115
|
+
- 解锁全部功能和工具
|
|
116
|
+
- 支持我们持续提供优质服务
|
|
117
|
+
|
|
118
|
+
价格: {price} ABT/次对话
|
|
119
|
+
|
|
120
|
+
立即订阅以解锁更多可能性!`,
|
|
121
|
+
requireNewSubscriptionFooter: '您需要订阅才能访问此功能:',
|
|
122
|
+
thanksForSubscription: '感谢您的订阅,现在,您可以开始尽情体验了!',
|
|
123
|
+
clickTheButton: '点我生成 👉',
|
|
124
|
+
cleanSessionTip: '清除会话消息记录',
|
|
125
|
+
poweredBy: '技术支持源自',
|
|
126
|
+
selectPromptToStart: '选择一个提示词开始吧',
|
|
127
|
+
history: '历史记录',
|
|
128
|
+
unnamed: '未命名',
|
|
129
|
+
newObject: '新建{object}',
|
|
130
|
+
editObject: '编辑{object}',
|
|
131
|
+
name: '名称',
|
|
132
|
+
description: '描述',
|
|
133
|
+
create: '创建',
|
|
134
|
+
back: '返回',
|
|
135
|
+
unauthorized: '未登录',
|
|
136
|
+
unauthorizedDescription: '请登录后访问该页面',
|
|
137
|
+
login: '登录',
|
|
138
|
+
copy: '复制',
|
|
139
|
+
copied: '已复制',
|
|
140
|
+
copyToClipboard: '复制到剪贴板',
|
|
141
|
+
saveToNoteTip: '保存到知识库',
|
|
142
|
+
saveToNote: '保存',
|
|
143
|
+
savedToNote: '已保存到知识库',
|
|
144
|
+
uploadFile: '上传文件',
|
|
145
|
+
submit: '提交',
|
|
146
|
+
},
|
|
147
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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.useAssistantState = exports.createAssistantState = void 0;
|
|
13
|
+
const zustand_1 = require("zustand");
|
|
14
|
+
const immer_1 = require("zustand/middleware/immer");
|
|
15
|
+
const assistant_1 = require("../api/assistant");
|
|
16
|
+
const STATES = {};
|
|
17
|
+
const createAssistantState = ({ assistantId, assistant }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = STATES[assistantId]) !== null && _a !== void 0 ? _a : (STATES[assistantId] = (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
|
|
20
|
+
assistant,
|
|
21
|
+
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
set((state) => {
|
|
23
|
+
state.loading = true;
|
|
24
|
+
});
|
|
25
|
+
try {
|
|
26
|
+
const assistant = yield (0, assistant_1.getAssistant)({ assistantId });
|
|
27
|
+
set((state) => {
|
|
28
|
+
state.assistant = assistant;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error(error);
|
|
33
|
+
set((state) => {
|
|
34
|
+
state.error = error;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
set((state) => {
|
|
39
|
+
state.loading = false;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
}))));
|
|
44
|
+
return STATES[assistantId];
|
|
45
|
+
};
|
|
46
|
+
exports.createAssistantState = createAssistantState;
|
|
47
|
+
const LOADING_TASKS = {};
|
|
48
|
+
function useAssistantState({ assistantId }) {
|
|
49
|
+
var _a;
|
|
50
|
+
const state = (0, exports.createAssistantState)({ assistantId })();
|
|
51
|
+
if (!state.assistant) {
|
|
52
|
+
if (state.error)
|
|
53
|
+
throw state.error;
|
|
54
|
+
(_a = LOADING_TASKS[assistantId]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[assistantId] = state.load());
|
|
55
|
+
throw LOADING_TASKS[assistantId];
|
|
56
|
+
}
|
|
57
|
+
return [state.assistant, state];
|
|
58
|
+
}
|
|
59
|
+
exports.useAssistantState = useAssistantState;
|