@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.
Files changed (209) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/assistant.js +26 -0
  2. package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +127 -0
  3. package/lib/cjs/builtin/async/ai-runtime/api/message.js +33 -0
  4. package/lib/cjs/builtin/async/ai-runtime/api/request.js +47 -0
  5. package/lib/cjs/builtin/async/ai-runtime/api/session.js +121 -0
  6. package/lib/cjs/builtin/async/ai-runtime/api/subscription.js +32 -0
  7. package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +63 -0
  8. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +60 -0
  9. package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +40 -0
  10. package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +51 -0
  11. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +156 -0
  12. package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +43 -0
  13. package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +30 -0
  14. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
  15. package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +109 -0
  16. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +102 -0
  17. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +193 -0
  18. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  19. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  20. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  21. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  22. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  23. package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +105 -0
  24. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +21 -0
  25. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +35 -0
  26. package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +12 -0
  27. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +48 -0
  28. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +66 -0
  29. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +43 -0
  30. package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +44 -0
  31. package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +76 -0
  32. package/lib/cjs/builtin/async/ai-runtime/components/layout/index.js +15 -0
  33. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
  34. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
  35. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
  36. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +134 -0
  37. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +48 -0
  38. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
  39. package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
  40. package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
  41. package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
  42. package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
  43. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
  44. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +94 -0
  45. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +48 -0
  46. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +21 -0
  47. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +67 -0
  48. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +15 -0
  49. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +103 -0
  50. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
  51. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
  52. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
  53. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
  54. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +62 -0
  55. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  56. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
  57. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
  58. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +37 -0
  59. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
  60. package/lib/cjs/builtin/async/ai-runtime/index.js +75 -0
  61. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +147 -0
  62. package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +59 -0
  63. package/lib/cjs/builtin/async/ai-runtime/state/index.js +423 -0
  64. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
  65. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
  66. package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
  67. package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
  68. package/lib/cjs/utils/builtin.js +1 -0
  69. package/lib/cjs/utils/inject-global-components.js +2 -0
  70. package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
  71. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
  72. package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
  73. package/lib/esm/builtin/async/ai-runtime/api/request.js +43 -0
  74. package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
  75. package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
  76. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
  77. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +56 -0
  78. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
  79. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +48 -0
  80. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
  81. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
  82. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
  83. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +10 -0
  84. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
  85. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
  86. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
  87. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  88. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  89. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  90. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  91. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  92. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +99 -0
  93. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
  94. package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
  95. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
  96. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +42 -0
  97. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
  98. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +37 -0
  99. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
  100. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +73 -0
  101. package/lib/esm/builtin/async/ai-runtime/components/layout/index.js +12 -0
  102. package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +8 -0
  103. package/lib/esm/builtin/async/ai-runtime/components/message/MessageActions.js +35 -0
  104. package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +24 -0
  105. package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +105 -0
  106. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +42 -0
  107. package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +8 -0
  108. package/lib/esm/builtin/async/ai-runtime/components/parameters/LanguageField.js +53 -0
  109. package/lib/esm/builtin/async/ai-runtime/components/parameters/NumberField.js +19 -0
  110. package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +22 -0
  111. package/lib/esm/builtin/async/ai-runtime/components/parameters/StringField.js +19 -0
  112. package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +31 -0
  113. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +88 -0
  114. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +22 -0
  115. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +15 -0
  116. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +61 -0
  117. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +9 -0
  118. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +97 -0
  119. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
  120. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
  121. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
  122. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
  123. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
  124. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  125. package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
  126. package/lib/esm/builtin/async/ai-runtime/hooks/header.js +25 -0
  127. package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +31 -0
  128. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
  129. package/lib/esm/builtin/async/ai-runtime/index.js +66 -0
  130. package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
  131. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
  132. package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
  133. package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
  134. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
  135. package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
  136. package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
  137. package/lib/esm/utils/builtin.js +1 -0
  138. package/lib/esm/utils/inject-global-components.js +2 -0
  139. package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
  140. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
  141. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
  142. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
  143. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
  144. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
  145. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
  146. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +33 -0
  147. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
  148. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +2 -0
  149. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
  150. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
  151. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
  152. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
  153. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
  154. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
  155. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
  156. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  157. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  158. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  159. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  160. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  161. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
  162. package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
  163. package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
  164. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
  165. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
  166. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
  167. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +8 -0
  168. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
  169. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +4 -0
  170. package/lib/types/builtin/async/ai-runtime/components/layout/index.d.ts +7 -0
  171. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
  172. package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
  173. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
  174. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +10 -0
  175. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
  176. package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
  177. package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
  178. package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
  179. package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
  180. package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
  181. package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
  182. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +4 -0
  183. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +4 -0
  184. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.d.ts +4 -0
  185. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +6 -0
  186. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +4 -0
  187. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +5 -0
  188. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +5 -0
  189. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +5 -0
  190. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +5 -0
  191. package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +4 -0
  192. package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +9 -0
  193. package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
  194. package/lib/types/builtin/async/ai-runtime/constants.d.ts +2 -0
  195. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
  196. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
  197. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
  198. package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
  199. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
  200. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
  201. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  202. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
  203. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
  204. package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
  205. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
  206. package/lib/types/builtin/session.d.ts +11 -1
  207. package/lib/types/utils/builtin.d.ts +1 -0
  208. package/package.json +13 -8
  209. 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;