@blocklet/pages-kit 0.2.286 → 0.2.288

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 (214) 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 +55 -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 +24 -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 +49 -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 +22 -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 +104 -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 +89 -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 +57 -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 +81 -0
  32. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
  33. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
  34. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
  35. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +129 -0
  36. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +47 -0
  37. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
  38. package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
  39. package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
  40. package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
  41. package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
  42. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
  43. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +111 -0
  44. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +60 -0
  45. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +52 -0
  46. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +28 -0
  47. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +120 -0
  48. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
  49. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
  50. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
  51. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
  52. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +65 -0
  53. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  54. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
  55. package/lib/cjs/builtin/async/ai-runtime/error.js +10 -0
  56. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
  57. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +38 -0
  58. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
  59. package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +32 -0
  60. package/lib/cjs/builtin/async/ai-runtime/index.js +81 -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/loading.js +39 -0
  65. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
  66. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
  67. package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
  68. package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
  69. package/lib/cjs/utils/builtin.js +1 -0
  70. package/lib/cjs/utils/inject-global-components.js +2 -0
  71. package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
  72. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
  73. package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
  74. package/lib/esm/builtin/async/ai-runtime/api/request.js +51 -0
  75. package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
  76. package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
  77. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
  78. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +21 -0
  79. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
  80. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +46 -0
  81. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
  82. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
  83. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
  84. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
  85. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
  86. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
  87. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
  88. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  89. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  90. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  91. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  92. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  93. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +98 -0
  94. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
  95. package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
  96. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
  97. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +60 -0
  98. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
  99. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +50 -0
  100. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
  101. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +75 -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 +100 -0
  106. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +41 -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 +103 -0
  114. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +34 -0
  115. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +46 -0
  116. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +22 -0
  117. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +114 -0
  118. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
  119. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
  120. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
  121. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
  122. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
  123. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  124. package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
  125. package/lib/esm/builtin/async/ai-runtime/error.js +6 -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 +32 -0
  128. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
  129. package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +29 -0
  130. package/lib/esm/builtin/async/ai-runtime/index.js +72 -0
  131. package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
  132. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
  133. package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
  134. package/lib/esm/builtin/async/ai-runtime/state/loading.js +36 -0
  135. package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
  136. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
  137. package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
  138. package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
  139. package/lib/esm/utils/builtin.js +1 -0
  140. package/lib/esm/utils/inject-global-components.js +2 -0
  141. package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
  142. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
  143. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
  144. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
  145. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
  146. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
  147. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
  148. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +2 -0
  149. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
  150. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +5 -0
  151. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
  152. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
  153. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
  154. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
  155. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
  156. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
  157. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
  158. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  159. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  160. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  161. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  162. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  163. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
  164. package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
  165. package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
  166. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
  167. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
  168. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
  169. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +11 -0
  170. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
  171. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +6 -0
  172. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
  173. package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
  174. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
  175. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +8 -0
  176. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
  177. package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
  178. package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
  179. package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
  180. package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
  181. package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
  182. package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
  183. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +10 -0
  184. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +5 -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 +5 -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 +8 -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/error.d.ts +4 -0
  196. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
  197. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
  198. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
  199. package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +1 -0
  200. package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
  201. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
  202. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
  203. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  204. package/lib/types/builtin/async/ai-runtime/state/loading.d.ts +10 -0
  205. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
  206. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
  207. package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
  208. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
  209. package/lib/types/builtin/page/header.d.ts +1 -6
  210. package/lib/types/builtin/session.d.ts +11 -1
  211. package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -116
  212. package/lib/types/utils/builtin.d.ts +1 -0
  213. package/package.json +14 -9
  214. package/tsconfig.json +5 -1
@@ -0,0 +1,144 @@
1
+ export const translations = {
2
+ en: {
3
+ socialShare: {
4
+ shareToX: 'Share to X',
5
+ shareToTelegram: 'Share to Telegram',
6
+ shareToReddit: 'Share to Reddit',
7
+ shareToWeibo: 'Share to Weibo',
8
+ shareToFacebook: 'Share to Facebook',
9
+ shareToLinkedin: 'Share to Linkedin',
10
+ copyLink: 'Copy Link',
11
+ },
12
+ questionPlaceholder: 'Ask Anything...',
13
+ parameters: 'Parameters',
14
+ parametersTitle: 'Tell me what do you want?',
15
+ parametersSetting: 'Setting',
16
+ clearSession: 'Clear Session',
17
+ generate: 'Generate',
18
+ startChat: 'Start Chat',
19
+ collections: 'Collections',
20
+ collection: 'Collection',
21
+ collectionName: 'Collection Name',
22
+ document: 'Document',
23
+ rename: 'Rename',
24
+ delete: 'Delete',
25
+ confirmDelete: 'Confirm Delete?',
26
+ noData: 'No {data} yet',
27
+ createObject: 'Create {object}',
28
+ title: 'Title',
29
+ titlePlaceholder: 'Title',
30
+ content: 'Content',
31
+ contentPlaceholder: 'Write anything...',
32
+ cancel: 'Cancel',
33
+ save: 'Save',
34
+ edit: 'Edit',
35
+ chat: 'Chat',
36
+ subscribeNow: 'Subscribe Now',
37
+ requireNewSubscription: `Thank you for using our service!
38
+
39
+ To get more features and exclusive content, please subscribe to our service. After subscribing, you will enjoy the following privileges:
40
+
41
+ - Unlock all features and tools
42
+ - Support us to continue to provide quality services
43
+
44
+ Pricing: {price} ABT/Message
45
+
46
+ Subscribe now to unlock more possibilities!`,
47
+ requireNewSubscriptionFooter: 'You need to subscribe to access this feature:',
48
+ thanksForSubscription: 'Thanks for subscribing, now you can start enjoying it!',
49
+ clickTheButton: 'Click The Button 👉',
50
+ cleanSessionTip: 'Clean conversation messages',
51
+ poweredBy: 'Powered by',
52
+ selectPromptToStart: 'Select a prompt to get started',
53
+ history: 'History',
54
+ unnamed: 'Unnamed',
55
+ newObject: 'New {object}',
56
+ editObject: 'Edit {object}',
57
+ name: 'Name',
58
+ description: 'Description',
59
+ create: 'Create',
60
+ back: 'Back',
61
+ unauthorized: 'Unauthorized',
62
+ unauthorizedDescription: 'Please log in to visit this page',
63
+ login: 'Login',
64
+ copy: 'Copy',
65
+ copied: 'Copied',
66
+ copyToClipboard: 'Copy to clipboard',
67
+ saveToNoteTip: 'Save to collection',
68
+ saveToNote: 'Save',
69
+ savedToNote: 'Saved as a new document',
70
+ uploadFile: 'Upload File',
71
+ submit: 'Submit',
72
+ },
73
+ zh: {
74
+ socialShare: {
75
+ shareToX: '分享到 X',
76
+ shareToTelegram: '分享到 Telegram',
77
+ shareToReddit: '分享到 Reddit',
78
+ shareToWeibo: '分享到 微博',
79
+ shareToFacebook: '分享到 Facebook',
80
+ shareToLinkedin: '分享到 Linkedin',
81
+ copyLink: '复制链接',
82
+ },
83
+ questionPlaceholder: '问点什么...',
84
+ parameters: '参数',
85
+ parametersTitle: '告诉我你想要什么?',
86
+ parametersSetting: '设置',
87
+ clearSession: '清空对话',
88
+ generate: '生成',
89
+ startChat: '开始对话',
90
+ collections: '知识库',
91
+ collection: '知识库',
92
+ collectionName: '知识库名称',
93
+ document: '文档',
94
+ rename: '重命名',
95
+ delete: '删除',
96
+ confirmDelete: '确定删除?',
97
+ noData: '暂无{data}',
98
+ createObject: '创建{object}',
99
+ title: '标题',
100
+ titlePlaceholder: '标题',
101
+ content: '内容',
102
+ contentPlaceholder: '写点什么吧...',
103
+ cancel: '取消',
104
+ save: '保存',
105
+ edit: '编辑',
106
+ chat: '对话',
107
+ subscribeNow: '立即订阅',
108
+ requireNewSubscription: `感谢您使用我们的服务!
109
+
110
+ 为了获得更多功能和专属内容,请订阅我们的服务。订阅后,您将享有以下特权:
111
+
112
+ - 解锁全部功能和工具
113
+ - 支持我们持续提供优质服务
114
+
115
+ 价格: {price} ABT/次对话
116
+
117
+ 立即订阅以解锁更多可能性!`,
118
+ requireNewSubscriptionFooter: '您需要订阅才能访问此功能:',
119
+ thanksForSubscription: '感谢您的订阅,现在,您可以开始尽情体验了!',
120
+ clickTheButton: '点我生成 👉',
121
+ cleanSessionTip: '清除会话消息记录',
122
+ poweredBy: '技术支持来自',
123
+ selectPromptToStart: '选择一个提示词开始吧',
124
+ history: '历史记录',
125
+ unnamed: '未命名',
126
+ newObject: '新建{object}',
127
+ editObject: '编辑{object}',
128
+ name: '名称',
129
+ description: '描述',
130
+ create: '创建',
131
+ back: '返回',
132
+ unauthorized: '未登录',
133
+ unauthorizedDescription: '请登录后访问该页面',
134
+ login: '登录',
135
+ copy: '复制',
136
+ copied: '已复制',
137
+ copyToClipboard: '复制到剪贴板',
138
+ saveToNoteTip: '保存到知识库',
139
+ saveToNote: '保存',
140
+ savedToNote: '已保存到知识库',
141
+ uploadFile: '上传文件',
142
+ submit: '提交',
143
+ },
144
+ };
@@ -0,0 +1,54 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { create } from 'zustand';
11
+ import { immer } from 'zustand/middleware/immer';
12
+ import { getAssistant } from '../api/assistant';
13
+ const STATES = {};
14
+ export const createAssistantState = ({ assistantId, assistant }) => {
15
+ var _a;
16
+ (_a = STATES[assistantId]) !== null && _a !== void 0 ? _a : (STATES[assistantId] = create()(immer((set) => ({
17
+ assistant,
18
+ load: () => __awaiter(void 0, void 0, void 0, function* () {
19
+ set((state) => {
20
+ state.loading = true;
21
+ });
22
+ try {
23
+ const assistant = yield getAssistant({ assistantId });
24
+ set((state) => {
25
+ state.assistant = assistant;
26
+ });
27
+ }
28
+ catch (error) {
29
+ console.error(error);
30
+ set((state) => {
31
+ state.error = error;
32
+ });
33
+ }
34
+ finally {
35
+ set((state) => {
36
+ state.loading = false;
37
+ });
38
+ }
39
+ }),
40
+ }))));
41
+ return STATES[assistantId];
42
+ };
43
+ const LOADING_TASKS = {};
44
+ export function useAssistantState({ assistantId }) {
45
+ var _a;
46
+ const state = createAssistantState({ assistantId })();
47
+ if (!state.assistant) {
48
+ if (state.error)
49
+ throw state.error;
50
+ (_a = LOADING_TASKS[assistantId]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[assistantId] = state.load());
51
+ throw LOADING_TASKS[assistantId];
52
+ }
53
+ return [state.assistant, state];
54
+ }
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+ // import { StoreApi, UseBoundStore, create } from 'zustand';
3
+ // import { immer } from 'zustand/middleware/immer';
4
+ // import { EventSourceParserStream } from '../../../stream';
5
+ // import { getComponentMountPoint, joinURL } from '../../../utils';
6
+ // import { Assistant, getAssistant } from '../api/assistant';
7
+ // import {
8
+ // Dataset,
9
+ // createDataset,
10
+ // createDocument,
11
+ // deleteDataset,
12
+ // deleteDocument,
13
+ // getDataset,
14
+ // getDatasets,
15
+ // getDocuments,
16
+ // updateDataset,
17
+ // updateDocument,
18
+ // } from '../api/dataset';
19
+ // import { deleteMessages, getMessages } from '../api/message';
20
+ // import { Session, createSession, getSessions, updateSession } from '../api/session';
21
+ // import { Subscription, getSubscription } from '../api/subscription';
22
+ // import { AI_STUDIO_DID } from '../constants';
23
+ // import { parseIdentity } from '../utils';
24
+ // const STATES: {
25
+ // assistant: { [key: string]: UseBoundStore<StoreApi<State>> };
26
+ // dataset: { [key: string]: ReturnType<typeof createDatasetState> };
27
+ // datasetDetail: { [key: string]: ReturnType<typeof createDatasetDetailState> };
28
+ // } = { assistant: {}, dataset: {}, datasetDetail: {} };
29
+ // export interface State {
30
+ // loading: boolean;
31
+ // loaded: boolean;
32
+ // assistant?: Assistant;
33
+ // sessions?: Session[];
34
+ // subscription?: Subscription;
35
+ // sessionMap: { [sessionId: string]: { session: Session } };
36
+ // computed: {
37
+ // get isChat(): boolean | undefined;
38
+ // get requireNewSubscription(): boolean | undefined;
39
+ // };
40
+ // }
41
+ // export const createState = ({
42
+ // releaseId,
43
+ // preload: { assistant, sessions, subscription } = {},
44
+ // }: {
45
+ // releaseId: string;
46
+ // preload?: {
47
+ // assistant?: Assistant;
48
+ // sessions?: Session[];
49
+ // subscription?: Subscription;
50
+ // };
51
+ // }) => {
52
+ // STATES.assistant[releaseId] ??= create<State>()(
53
+ // immer<State>((set, get) => ({
54
+ // loading: false,
55
+ // loaded: false,
56
+ // assistant,
57
+ // sessions,
58
+ // subscription,
59
+ // sessionMap: Object.fromEntries((sessions ?? []).map((session) => [session.id, { session }])),
60
+ // computed: {
61
+ // get isChat() {
62
+ // const parameters = get().assistant?.parameters;
63
+ // return parameters?.some((i) => i.key === 'question');
64
+ // },
65
+ // get requireNewSubscription() {
66
+ // // TODO: implement payment
67
+ // // const { subscription } = get();
68
+ // // const { paymentEnabled, paymentLinkId } = release;
69
+ // // return !!paymentEnabled && !!paymentLinkId && !subscription;
70
+ // return false;
71
+ // },
72
+ // get withCollection() {
73
+ // const parameters = get().assistant?.parameters;
74
+ // return parameters?.some((i) => i.key === 'datasetId');
75
+ // },
76
+ // },
77
+ // getPaymentLink({ userId }: { userId: string }) {
78
+ // // TODO: implement
79
+ // // return withQuery(
80
+ // // joinURL('/', getComponentMountPoint(PAYMENT_KIT_DID), '/checkout/pay', release.paymentLinkId),
81
+ // // {
82
+ // // 'metadata.releaseId': release.id,
83
+ // // 'metadata.userId': userId,
84
+ // // redirect: window.location.href,
85
+ // // }
86
+ // // );
87
+ // },
88
+ // getAssistant: async () => {
89
+ // set((state) => {
90
+ // state.loading = true;
91
+ // });
92
+ // try {
93
+ // const { subscription } = await getSubscription({ releaseId });
94
+ // const identity = parseIdentity(releaseId, { rejectWhenError: true });
95
+ // const [assistant, { sessions }] = await Promise.all([getAssistant(identity), getSessions(identity)]);
96
+ // set((state) => {
97
+ // state.assistant = assistant;
98
+ // state.sessions = sessions;
99
+ // state.subscription = subscription;
100
+ // state.sessionMap = Object.fromEntries(
101
+ // (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
102
+ // );
103
+ // });
104
+ // } finally {
105
+ // set((state) => {
106
+ // state.loading = false;
107
+ // state.loaded = true;
108
+ // });
109
+ // }
110
+ // },
111
+ // getSessions: async () => {
112
+ // const identity = parseIdentity(releaseId, { rejectWhenError: true });
113
+ // const { sessions } = await getSessions(identity);
114
+ // set((state) => {
115
+ // state.sessions = sessions;
116
+ // state.sessionMap = Object.fromEntries(
117
+ // (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
118
+ // );
119
+ // });
120
+ // },
121
+ // reloadMessages: async ({ sessionId }) => {
122
+ // set((state) => {
123
+ // const s = state.sessionMap[sessionId];
124
+ // if (!s) return;
125
+ // s.loading = true;
126
+ // });
127
+ // try {
128
+ // const { messages, count } = await getMessages({ sessionId });
129
+ // set((state) => {
130
+ // const s = state.sessionMap[sessionId];
131
+ // if (!s) return;
132
+ // s.messages = messages;
133
+ // s.messageCount = count;
134
+ // });
135
+ // } finally {
136
+ // set((state) => {
137
+ // const s = state.sessionMap[sessionId];
138
+ // if (!s) return;
139
+ // s.loading = false;
140
+ // });
141
+ // }
142
+ // },
143
+ // cleanSession: async ({ sessionId }) => {
144
+ // set((state) => {
145
+ // const s = state.sessionMap[sessionId];
146
+ // if (s) s.sessionReseting = true;
147
+ // });
148
+ // await deleteMessages({ sessionId });
149
+ // set((state) => {
150
+ // const s = state.sessionMap[sessionId];
151
+ // if (s) {
152
+ // s.sessionReseting = false;
153
+ // s.messages = [];
154
+ // }
155
+ // });
156
+ // },
157
+ // createSession: async ({ name, parameters, entry }) => {
158
+ // const identity = parseIdentity(releaseId);
159
+ // const { sessions, created } = await createSession({ ...identity, name, parameters, entry });
160
+ // set((state) => {
161
+ // state.sessions = sessions;
162
+ // state.sessionMap = Object.fromEntries(
163
+ // (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
164
+ // );
165
+ // });
166
+ // return created;
167
+ // },
168
+ // updateSession: async ({ sessionId, parameters }) => {
169
+ // set((state) => {
170
+ // const s = state.sessionMap[sessionId].session;
171
+ // if (s.parameters) Object.assign(s.parameters, parameters);
172
+ // });
173
+ // const { sessions } = await updateSession({ sessionId, parameters });
174
+ // set((state) => {
175
+ // state.sessions = sessions;
176
+ // state.sessionMap = Object.fromEntries(
177
+ // (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
178
+ // );
179
+ // });
180
+ // },
181
+ // execute: async ({ sessionId, parameters, onResponseStart, assistantIdentity }) => {
182
+ // const identity = parseIdentity(releaseId);
183
+ // let message;
184
+ // const childMessages = [];
185
+ // const childMessagesMap = {};
186
+ // set((state) => {
187
+ // const session = state.sessionMap[sessionId];
188
+ // if (session) session.executing = true;
189
+ // });
190
+ // try {
191
+ // const res = await fetch(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/ai/call'), {
192
+ // method: 'POST',
193
+ // headers: {
194
+ // 'Content-Type': 'application/json',
195
+ // Accept: 'text/event-stream',
196
+ // },
197
+ // body: JSON.stringify({
198
+ // sessionId,
199
+ // parameters: { ...parameters, $clientTime: new Date().toISOString() },
200
+ // ...(assistantIdentity || identity),
201
+ // ref: (assistantIdentity || identity).projectRef,
202
+ // working: true,
203
+ // }),
204
+ // });
205
+ // if (!(res.status >= 200 && res.status < 300)) {
206
+ // let json: any;
207
+ // try {
208
+ // json = await res.json();
209
+ // } catch (error) {}
210
+ // const { message } = json.error;
211
+ // if (typeof message === 'string') {
212
+ // throw new Error(message);
213
+ // }
214
+ // throw new Error(`Unknown Error: ${res.status}`);
215
+ // }
216
+ // const stream = res
217
+ // .body!.pipeThrough(new TextDecoderStream())
218
+ // .pipeThrough(new EventSourceParserStream())
219
+ // .getReader();
220
+ // let responseStarted = false;
221
+ // for (;;) {
222
+ // const { value, done } = await stream.read();
223
+ // if (!responseStarted) {
224
+ // responseStarted = true;
225
+ // onResponseStart?.();
226
+ // }
227
+ // if (value?.type === 'CHUNK') {
228
+ // if (!message) {
229
+ // message = {
230
+ // taskId: value.taskId,
231
+ // parameters,
232
+ // loading: true,
233
+ // createdAt: new Date().toISOString(),
234
+ // };
235
+ // set((state) => {
236
+ // state.sessionMap[sessionId] ??= {};
237
+ // state.sessionMap[sessionId].messages ??= [];
238
+ // state.sessionMap[sessionId].messages.push(message);
239
+ // });
240
+ // }
241
+ // if (message.taskId === value.taskId) {
242
+ // set((state) => {
243
+ // const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
244
+ // if (!msg) return;
245
+ // msg.result ??= {};
246
+ // msg.result.content = (msg.result.content || '') + (value.delta.content || '');
247
+ // if (value.delta.object) {
248
+ // msg.result.objects ??= [];
249
+ // msg.result.objects.push(value.delta.object);
250
+ // if (value.delta.object.metadata) {
251
+ // const session = state.sessionMap[sessionId];
252
+ // session.metadata ??= {};
253
+ // deepMerge(session.metadata, value.delta.object.metadata);
254
+ // }
255
+ // }
256
+ // if (value.delta?.images?.length) {
257
+ // msg.result.images = (msg.result.images ?? []).concat(value.delta.images);
258
+ // }
259
+ // });
260
+ // } else if (value.respondAs && value.respondAs !== 'none') {
261
+ // let childMessage = childMessagesMap[value.taskId];
262
+ // if (!childMessage) {
263
+ // childMessage = {
264
+ // taskId: value.taskId,
265
+ // createdAt: new Date().toISOString(),
266
+ // respondAs: value.respondAs,
267
+ // };
268
+ // childMessagesMap[value.taskId] = childMessage;
269
+ // childMessages.push(childMessage);
270
+ // }
271
+ // childMessage.result ??= {};
272
+ // childMessage.result.content = (childMessage.result.content || '') + (value.delta.content || '');
273
+ // if (value.delta?.images?.length) {
274
+ // childMessage.result.images = (childMessage.result.images ?? []).concat(value.delta.images);
275
+ // }
276
+ // set((state) => {
277
+ // const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
278
+ // if (!msg) return;
279
+ // msg.result ??= {};
280
+ // msg.result.messages = JSON.parse(JSON.stringify(childMessages));
281
+ // });
282
+ // }
283
+ // }
284
+ // if (value?.type === 'ERROR') {
285
+ // set((state) => {
286
+ // const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
287
+ // if (msg) msg.error = value.error;
288
+ // else throw new Error(value.error.message);
289
+ // });
290
+ // }
291
+ // if (done) break;
292
+ // }
293
+ // } finally {
294
+ // set((state) => {
295
+ // const session = state.sessionMap[sessionId];
296
+ // session.executing = false;
297
+ // if (session && message) {
298
+ // const msg = session.messages?.findLast((i) => i.taskId === message.taskId);
299
+ // if (msg) msg.loading = false;
300
+ // }
301
+ // });
302
+ // }
303
+ // },
304
+ // }))
305
+ // );
306
+ // return STATES.assistant[releaseId]!;
307
+ // };
308
+ // export function createDatasetState({ releaseId, datasets }: { releaseId: string; datasets?: Dataset[] }) {
309
+ // STATES.dataset[releaseId] ??= create()(
310
+ // immer((set) => ({
311
+ // loading: false,
312
+ // list: datasets,
313
+ // error: undefined,
314
+ // creating: false,
315
+ // async reload() {
316
+ // try {
317
+ // set((state) => {
318
+ // state.loading = true;
319
+ // });
320
+ // const datasets = await getDatasets({ appId: releaseId });
321
+ // set((state) => {
322
+ // state.loading = false;
323
+ // state.list = datasets;
324
+ // state.error = undefined;
325
+ // });
326
+ // } catch (error) {
327
+ // set((state) => {
328
+ // state.loading = false;
329
+ // state.error = error;
330
+ // });
331
+ // }
332
+ // },
333
+ // async createDataset({ name, description }: { name: string; description?: string }) {
334
+ // try {
335
+ // set((state) => {
336
+ // state.creating = true;
337
+ // });
338
+ // const created = await createDataset({ appId: releaseId, name, description });
339
+ // await this.reload();
340
+ // return created;
341
+ // } finally {
342
+ // set((state) => {
343
+ // state.creating = false;
344
+ // });
345
+ // }
346
+ // },
347
+ // async updateDataset(datasetId: string, { name, description }: { name: string; description?: string }) {
348
+ // const updated = await updateDataset(datasetId, { name, description });
349
+ // await this.reload();
350
+ // return updated;
351
+ // },
352
+ // async deleteDataset(datasetId: string) {
353
+ // await deleteDataset(datasetId);
354
+ // await this.reload();
355
+ // },
356
+ // }))
357
+ // );
358
+ // return STATES.dataset[releaseId];
359
+ // }
360
+ // export function createDatasetDetailState({ datasetId, list }: { datasetId: string; list?: Document[] }) {
361
+ // STATES.datasetDetail[datasetId] ??= create()(
362
+ // immer((set, get) => ({
363
+ // loading: false,
364
+ // dataset: undefined,
365
+ // list,
366
+ // error: undefined,
367
+ // creating: false,
368
+ // async reload() {
369
+ // if (get().loading) return;
370
+ // set((state) => {
371
+ // state.loading = true;
372
+ // });
373
+ // try {
374
+ // const [dataset, { items }] = await Promise.all([getDataset({ datasetId }), getDocuments(datasetId)]);
375
+ // set((state) => {
376
+ // state.dataset = dataset;
377
+ // state.loading = false;
378
+ // state.list = items;
379
+ // state.error = undefined;
380
+ // });
381
+ // } catch (error) {
382
+ // set((state) => {
383
+ // state.loading = false;
384
+ // state.error = error;
385
+ // });
386
+ // }
387
+ // },
388
+ // async createDocument(type: 'text' | 'file', input: Parameters<typeof createDocument>[1]) {
389
+ // try {
390
+ // set((state) => {
391
+ // state.creating = true;
392
+ // });
393
+ // const created = await createDocument(datasetId, type, input);
394
+ // await this.reload();
395
+ // return created;
396
+ // } finally {
397
+ // set((state) => {
398
+ // state.creating = false;
399
+ // });
400
+ // }
401
+ // },
402
+ // async updateDocument(documentId: string, type: 'text', input: Parameters<typeof updateDocument>[1]) {
403
+ // try {
404
+ // set((state) => {
405
+ // state.updating = true;
406
+ // });
407
+ // const updated = await updateDocument(datasetId, documentId, type, input);
408
+ // await this.reload();
409
+ // return updated;
410
+ // } finally {
411
+ // set((state) => {
412
+ // state.updating = false;
413
+ // });
414
+ // }
415
+ // },
416
+ // async deleteDocument(documentId) {
417
+ // await deleteDocument(datasetId, documentId);
418
+ // await this.reload();
419
+ // },
420
+ // }))
421
+ // );
422
+ // return STATES.datasetDetail[datasetId];
423
+ // }
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { create } from 'zustand';
11
+ import { immer } from 'zustand/middleware/immer';
12
+ export const globalLoadingState = create()(immer((set, get) => ({
13
+ loading: false,
14
+ count: 0,
15
+ run: (fn) => __awaiter(void 0, void 0, void 0, function* () {
16
+ try {
17
+ get().start();
18
+ return (yield (typeof fn === 'function' ? fn() : fn));
19
+ }
20
+ finally {
21
+ get().end();
22
+ }
23
+ }),
24
+ start: () => {
25
+ set((state) => {
26
+ state.count += 1;
27
+ state.loading = true;
28
+ });
29
+ },
30
+ end: () => {
31
+ set((state) => {
32
+ state.count = Math.max(0, state.count - 1);
33
+ state.loading = state.count > 0;
34
+ });
35
+ },
36
+ })));