@blocklet/pages-kit 0.2.299 → 0.2.301
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 → agent.js} +5 -7
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +20 -18
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +5 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormHeader.js → Header/SimpleHeader.js} +9 -16
- package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +6 -8
- package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +40 -57
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +8 -3
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
- package/lib/cjs/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
- package/lib/cjs/builtin/async/ai-runtime/constants.js +4 -1
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/index.js +16 -63
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +72 -0
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +11 -7
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +7 -4
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +6 -6
- package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +102 -0
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.js +25 -12
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +12 -12
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +91 -92
- package/lib/esm/builtin/async/ai-runtime/api/{assistant.js → agent.js} +3 -5
- package/lib/esm/builtin/async/ai-runtime/api/session.js +19 -17
- package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +2 -1
- package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +23 -0
- package/lib/esm/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +5 -4
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +19 -57
- package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +8 -3
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
- package/lib/esm/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
- package/lib/esm/builtin/async/ai-runtime/constants.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +3 -3
- package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +26 -0
- package/lib/esm/builtin/async/ai-runtime/index.js +13 -58
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +66 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +9 -5
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
- package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +73 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +63 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +9 -9
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
- package/lib/esm/builtin/async/ai-runtime/state/session.js +91 -88
- package/lib/types/builtin/async/ai-runtime/api/{assistant.d.ts → agent.d.ts} +4 -4
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +7 -13
- package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/{GlobalLoading.d.ts → GlobalLoading/index.d.ts} +1 -0
- package/lib/types/builtin/async/ai-runtime/components/Header/SimpleHeader.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/Layout/SimpleLayout.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/components/{RuntimeProvider.d.ts → RuntimeCommonProvider.d.ts} +1 -1
- package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +8 -59
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +14 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +13 -24
- package/lib/types/builtin/async/ai-runtime/runtime/ChatBotButton/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.d.ts +2 -2
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +10 -18
- package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +2 -2
- package/package.json +7 -7
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -49
- package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +0 -22
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
- package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +0 -104
- package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +0 -12
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -89
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -66
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -61
- package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +0 -44
- package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +0 -88
- package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -35
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -177
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +0 -48
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -121
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/constants.js +0 -6
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/session.js +0 -213
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -133
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -60
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -59
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -28
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -138
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -31
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +0 -54
- package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +0 -74
- package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
- package/lib/cjs/builtin/async/ai-runtime/hooks/auth.js +0 -31
- package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +0 -69
- package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +0 -38
- package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +0 -37
- package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +0 -32
- package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +0 -59
- package/lib/cjs/builtin/async/ai-runtime/state/index.js +0 -423
- package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +0 -52
- package/lib/cjs/builtin/async/ai-runtime/utils.js +0 -49
- package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -46
- package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
- package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +0 -98
- package/lib/esm/builtin/async/ai-runtime/components/common/index.js +0 -3
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -60
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -59
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -54
- package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +0 -38
- package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +0 -82
- package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +0 -8
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -29
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -146
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +0 -42
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -92
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +0 -50
- package/lib/esm/builtin/async/ai-runtime/components/runtime/constants.js +0 -3
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/session.js +0 -209
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -102
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -34
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -53
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -132
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +0 -30
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -25
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +0 -48
- package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +0 -68
- package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
- package/lib/esm/builtin/async/ai-runtime/hooks/auth.js +0 -27
- package/lib/esm/builtin/async/ai-runtime/hooks/header.js +0 -62
- package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +0 -32
- package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +0 -33
- package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +0 -29
- package/lib/esm/builtin/async/ai-runtime/state/assistant.js +0 -54
- package/lib/esm/builtin/async/ai-runtime/state/index.js +0 -423
- package/lib/esm/builtin/async/ai-runtime/state/subscription.js +0 -47
- package/lib/esm/builtin/async/ai-runtime/utils.js +0 -42
- package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +0 -4
- 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 +0 -13
- package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +0 -13
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +0 -28
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +0 -11
- package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +0 -14
- package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +0 -9
- package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/runtime/constants.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/assistant.d.ts +0 -17
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/session.d.ts +0 -29
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +0 -6
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/hooks/auth.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +0 -25
- package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/utils.d.ts +0 -20
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{state/loading.d.ts → components/GlobalLoading/state.d.ts} +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{common/UserInfo.d.ts → UserInfo.d.ts} +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.d.ts +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import ImagePreview from '@blocklet/ai-kit/components/image-preview';
|
|
14
|
-
import { cx } from '@emotion/css';
|
|
15
|
-
import { Box, Skeleton, Stack, Tooltip, Typography, styled, useMediaQuery, useTheme } from '@mui/material';
|
|
16
|
-
import dayjs from 'dayjs';
|
|
17
|
-
import React, { useMemo, useState } from 'react';
|
|
18
|
-
import { Avatar } from '../../../../arcblock/ux';
|
|
19
|
-
import { useSessionContext } from '../../../../session';
|
|
20
|
-
import { useAssistantState } from '../../state/assistant';
|
|
21
|
-
import { MessageMetadataRenderer } from '../common';
|
|
22
|
-
import MarkdownRenderer from '../MarkdownRenderer';
|
|
23
|
-
import MessageActions from './MessageActions';
|
|
24
|
-
import MessageErrorView from './MessageErrorView';
|
|
25
|
-
export default function MessageItemView(_a) {
|
|
26
|
-
var _b, _c;
|
|
27
|
-
var { page, message, hideAvatar } = _a, props = __rest(_a, ["page", "message", "hideAvatar"]);
|
|
28
|
-
const [assistant] = useAssistantState(page);
|
|
29
|
-
const showUserMessage = ((_b = assistant.release) === null || _b === void 0 ? void 0 : _b.template) !== 'form' && !!((_c = message.parameters) === null || _c === void 0 ? void 0 : _c.question);
|
|
30
|
-
return (_jsxs(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && _jsx(UserMessage, { message: message }), _jsx(AgentMessage, { page: page, message: message, hideAvatar: hideAvatar })] })));
|
|
31
|
-
}
|
|
32
|
-
const MessageItemContainer = styled(Stack) `
|
|
33
|
-
gap: 2.5;
|
|
34
|
-
overflow: hidden;
|
|
35
|
-
|
|
36
|
-
.message-question {
|
|
37
|
-
position: relative;
|
|
38
|
-
border-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
39
|
-
border-top-right-radius: 2px;
|
|
40
|
-
padding: ${({ theme }) => theme.spacing(1, 2)};
|
|
41
|
-
margin-top: ${({ theme }) => theme.spacing(0.5)};
|
|
42
|
-
// without logo width
|
|
43
|
-
max-width: calc(100% - 40px);
|
|
44
|
-
background-color: rgba(239, 246, 255, 1);
|
|
45
|
-
|
|
46
|
-
&.hide-avatar {
|
|
47
|
-
border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.message-response {
|
|
52
|
-
position: relative;
|
|
53
|
-
border-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
54
|
-
border-top-left-radius: 2px;
|
|
55
|
-
padding: ${({ theme }) => theme.spacing(1, 2)};
|
|
56
|
-
margin-top: ${({ theme }) => theme.spacing(0.5)};
|
|
57
|
-
// without logo width
|
|
58
|
-
max-width: calc(100% - 40px);
|
|
59
|
-
background-color: rgba(229, 231, 235, 1);
|
|
60
|
-
|
|
61
|
-
&.hide-avatar {
|
|
62
|
-
border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
function UserMessage({ message }) {
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
|
-
const { session: authSession } = useSessionContext();
|
|
69
|
-
return (_jsxs(Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
|
|
70
|
-
display: 'flex',
|
|
71
|
-
flexDirection: 'row-reverse',
|
|
72
|
-
textAlign: 'right',
|
|
73
|
-
justifyContent: 'flex-end',
|
|
74
|
-
}, children: [_jsx(Box, { children: _jsx(Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) }), _jsxs(Stack, { flex: 1, overflow: "hidden", sx: {
|
|
75
|
-
display: 'flex',
|
|
76
|
-
flexDirection: 'column',
|
|
77
|
-
alignItems: 'flex-end',
|
|
78
|
-
}, children: [_jsxs(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, _jsx(MessageTime, { time: message.createdAt })] }), _jsx(Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
|
|
79
|
-
}
|
|
80
|
-
function AgentMessage({ page, message, hideAvatar }) {
|
|
81
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
82
|
-
const [assistant] = useAssistantState(page);
|
|
83
|
-
const showMainMessage = !!(((_a = message.result) === null || _a === void 0 ? void 0 : _a.content) || ((_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.length));
|
|
84
|
-
const isMessageLoading = (message.loading || !message.result) && !message.error;
|
|
85
|
-
const theme = useTheme();
|
|
86
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
|
87
|
-
const isFormTemplate = ((_d = assistant.release) === null || _d === void 0 ? void 0 : _d.template) === 'form';
|
|
88
|
-
return (_jsxs(Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40, did: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, variant: "circle", shape: "circle", src: (_f = assistant.release) === null || _f === void 0 ? void 0 : _f.logo }) })), _jsxs(Box, { flex: 1, width: 0, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [((_g = assistant.release) === null || _g === void 0 ? void 0 : _g.title) || assistant.name, _jsx(MessageTime, { time: message.createdAt })] })), _jsxs(React.Suspense, { children: [showMainMessage ? (_jsx(Tooltip, Object.assign({}, (isFormTemplate && {
|
|
89
|
-
open: true,
|
|
90
|
-
}), { placement: "right-start", PopperProps: {
|
|
91
|
-
className: 'white-tooltip',
|
|
92
|
-
}, slotProps: {
|
|
93
|
-
popper: {
|
|
94
|
-
modifiers: [
|
|
95
|
-
{
|
|
96
|
-
name: 'offset',
|
|
97
|
-
options: {
|
|
98
|
-
offset: [-3, isMobile ? (!hideAvatar ? -18 : -8) : -6],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
}, title: !isMessageLoading && ((_h = message.result) === null || _h === void 0 ? void 0 : _h.content) && _jsx(MessageActions, { content: message.result.content }), children: _jsxs(Stack, { gap: 1, className: "message-response", children: [(_k = (_j = message.result) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k.map((childMsg, index) => {
|
|
104
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
105
|
-
return ((_a = childMsg.result) === null || _a === void 0 ? void 0 : _a.content) ? (_jsx(MarkdownRenderer, { className: isMessageLoading &&
|
|
106
|
-
!((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) &&
|
|
107
|
-
!((_d = (_c = message.result) === null || _c === void 0 ? void 0 : _c.images) === null || _d === void 0 ? void 0 : _d.length) &&
|
|
108
|
-
message.result.messages.length - 1 === index
|
|
109
|
-
? 'writing'
|
|
110
|
-
: '', sx: childMsg.respondAs === 'systemMessage' ? { color: 'text.secondary' } : {}, children: (_e = childMsg.result) === null || _e === void 0 ? void 0 : _e.content }, childMsg.taskId)) : ((_g = (_f = childMsg.result) === null || _f === void 0 ? void 0 : _f.images) === null || _g === void 0 ? void 0 : _g.length) ? (_jsx(ImagePreview, { itemWidth: 100, spacing: 1, dataSource: childMsg.result.images.map((i) => ({ src: i.url })) }, childMsg.taskId)) : null;
|
|
111
|
-
}), ((_l = message.result) === null || _l === void 0 ? void 0 : _l.content) && (_jsx(MarkdownRenderer, { className: isMessageLoading ? 'writing' : '', children: message.result.content }))] }) }))) : (isMessageLoading && (_jsx(Skeleton, { variant: "rectangular", height: 24 + 8 + 8,
|
|
112
|
-
// only response with loading
|
|
113
|
-
className: "message-response" }))), !!((_o = (_m = message.result) === null || _m === void 0 ? void 0 : _m.objects) === null || _o === void 0 ? void 0 : _o.length) &&
|
|
114
|
-
((_q = (_p = message.result) === null || _p === void 0 ? void 0 : _p.objects) === null || _q === void 0 ? void 0 : _q.map((object) => (_jsx(MessageMetadataRenderer, { object: object.data }, object.taskId)))), message.error && _jsx(MessageErrorView, { page: page, error: message.error })] })] })] }));
|
|
115
|
-
}
|
|
116
|
-
export function MessageItemWrapper(_a) {
|
|
117
|
-
var _b, _c, _d;
|
|
118
|
-
var { hideAvatar, assistant, agentMessage } = _a, props = __rest(_a, ["hideAvatar", "assistant", "agentMessage"]);
|
|
119
|
-
const [time] = useState(() => new Date().toISOString());
|
|
120
|
-
return (_jsx(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: agentMessage && (_jsxs(Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40, did: (_b = globalThis.blocklet) === null || _b === void 0 ? void 0 : _b.appId, variant: "circle", shape: "circle", src: (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.logo }) })), _jsxs(Box, { flex: 1, width: 0, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [((_d = assistant.release) === null || _d === void 0 ? void 0 : _d.title) || assistant.name, _jsx(MessageTime, { time: time })] })), agentMessage] })] })) })));
|
|
121
|
-
}
|
|
122
|
-
function MessageUserName({ children }) {
|
|
123
|
-
return (_jsx(Typography, { component: "div", noWrap: true, sx: {
|
|
124
|
-
fontSize: 14,
|
|
125
|
-
lineHeight: '24px',
|
|
126
|
-
fontWeight: 500,
|
|
127
|
-
display: 'flex',
|
|
128
|
-
alignItems: 'center',
|
|
129
|
-
gap: 1,
|
|
130
|
-
}, children: children }));
|
|
131
|
-
}
|
|
132
|
-
function MessageTime({ time }) {
|
|
133
|
-
const t = useMemo(() => {
|
|
134
|
-
const date = dayjs(time);
|
|
135
|
-
if (!date.isValid())
|
|
136
|
-
return undefined;
|
|
137
|
-
return date.isSame(dayjs(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
|
|
138
|
-
}, [time]);
|
|
139
|
-
if (!t)
|
|
140
|
-
return null;
|
|
141
|
-
return (_jsx(Typography, { sx: {
|
|
142
|
-
fontSize: 12,
|
|
143
|
-
lineHeight: '24px',
|
|
144
|
-
color: 'text.secondary',
|
|
145
|
-
}, children: t }, "user-time"));
|
|
146
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { Stack } from '@mui/material';
|
|
14
|
-
import { useMemo } from 'react';
|
|
15
|
-
import { useAssistantState } from '../../state/assistant';
|
|
16
|
-
import { useSessionState } from '../../state/session';
|
|
17
|
-
import MessageItemView from './MessageItemView';
|
|
18
|
-
export default function MessageListView(_a) {
|
|
19
|
-
var { page } = _a, props = __rest(_a, ["page"]);
|
|
20
|
-
const [assistant] = useAssistantState(page);
|
|
21
|
-
const [session, { messages = [] }] = useSessionState({ sessionId: page.sessionId, required: true });
|
|
22
|
-
const opener = useMemo(() => {
|
|
23
|
-
var _a;
|
|
24
|
-
const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
|
|
25
|
-
if (openerMessage) {
|
|
26
|
-
return {
|
|
27
|
-
taskId: '',
|
|
28
|
-
assistantId: assistant.id,
|
|
29
|
-
sessionId: session.id,
|
|
30
|
-
createdAt: session.createdAt,
|
|
31
|
-
updatedAt: session.createdAt,
|
|
32
|
-
result: { content: openerMessage },
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}, [assistant.release]);
|
|
37
|
-
if (!session)
|
|
38
|
-
return null;
|
|
39
|
-
return (_jsxs(Stack, Object.assign({ gap: 2.5 }, props, { children: [opener && _jsx(MessageItemView, { page: page, message: opener }), messages.map((message) => {
|
|
40
|
-
return _jsx(MessageItemView, { page: page, message: message }, message.taskId);
|
|
41
|
-
})] })));
|
|
42
|
-
}
|
package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Masonry } from '@mui/lab';
|
|
3
|
-
import { Box, Skeleton, Stack, ThemeProvider, Typography, createTheme, styled, useTheme } from '@mui/material';
|
|
4
|
-
import { Suspense, useMemo } from 'react';
|
|
5
|
-
import Balancer, { Provider } from 'react-wrap-balancer';
|
|
6
|
-
import CustomComponentRenderer from '../../../../../../../components/CustomComponentRenderer';
|
|
7
|
-
import { useLocaleContext } from '../../../../../../locale';
|
|
8
|
-
import LoadingButton from '../../../LoadingButton';
|
|
9
|
-
import CurrentAgentProvider, { useCurrentAgent } from '../../contexts/CurrentAgent';
|
|
10
|
-
import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
11
|
-
import { useRuntimeState } from '../../state/runtime';
|
|
12
|
-
import mapRight from '../../utils/map-right';
|
|
13
|
-
export default function PhotoGallery({ resultTitle, background, primaryColor, }) {
|
|
14
|
-
const { agent, appearancePage, childAgentId } = useRuntimeState();
|
|
15
|
-
const inheritedTheme = useTheme();
|
|
16
|
-
const theme = useMemo(() => {
|
|
17
|
-
let { primary } = inheritedTheme.palette;
|
|
18
|
-
try {
|
|
19
|
-
if (primaryColor) {
|
|
20
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error('augment primary color error', { error });
|
|
25
|
-
}
|
|
26
|
-
return createTheme(inheritedTheme, {
|
|
27
|
-
palette: { primary },
|
|
28
|
-
shape: {
|
|
29
|
-
borderRadius: 8,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}, [inheritedTheme, primaryColor]);
|
|
33
|
-
const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
|
|
34
|
-
const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
|
|
35
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Root, { className: "photo-wall-root", sx: { backgroundImage: `url(${background})` }, children: [_jsx(Stack, { className: "photo-wall-header", children: _jsxs(Provider, { children: [title && (_jsx(Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: title }) })), description && (_jsx(Typography, { fontSize: 20, textAlign: "center", children: _jsx(Balancer, { children: description }) }))] }) }), _jsx(Stack, { className: "photo-wall-input", children: _jsx(CurrentAgentProvider, { agentId: childAgentId, children: _jsx(AgentInputRender, {}) }) }), _jsxs(Stack, { className: "photo-wall-output", gap: 2, children: [resultTitle && (_jsx(Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: resultTitle }) })), _jsx(OutputView, {})] })] }) }));
|
|
36
|
-
}
|
|
37
|
-
const Root = styled(Stack)(({ theme }) => theme.unstable_sx({
|
|
38
|
-
gap: { xs: 3, sm: 4, md: 5 },
|
|
39
|
-
width: '100%',
|
|
40
|
-
backgroundSize: '100% auto',
|
|
41
|
-
backgroundRepeat: 'no-repeat',
|
|
42
|
-
backgroundPosition: 'top',
|
|
43
|
-
mt: 4,
|
|
44
|
-
'.photo-wall-header': {
|
|
45
|
-
maxWidth: 'md',
|
|
46
|
-
mx: 'auto',
|
|
47
|
-
width: '100%',
|
|
48
|
-
px: { xs: 2, sm: 3 },
|
|
49
|
-
gap: { xs: 2, sm: 3 },
|
|
50
|
-
},
|
|
51
|
-
'.photo-wall-input': {
|
|
52
|
-
maxWidth: 'md',
|
|
53
|
-
mx: 'auto',
|
|
54
|
-
width: '100%',
|
|
55
|
-
px: { xs: 2, sm: 3 },
|
|
56
|
-
},
|
|
57
|
-
'.photo-wall-output': {
|
|
58
|
-
width: '100%',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
px: { xs: 2, sm: 3 },
|
|
61
|
-
'.photo-wall-item': {
|
|
62
|
-
borderRadius: 1,
|
|
63
|
-
img: {
|
|
64
|
-
borderRadius: 1,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
function AgentInputRender() {
|
|
70
|
-
const { appearanceInput } = useCurrentAgent();
|
|
71
|
-
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
72
|
-
return null;
|
|
73
|
-
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
|
|
74
|
-
}
|
|
75
|
-
function NoOutputs() {
|
|
76
|
-
return (_jsx(Stack, { mt: 10, children: _jsx(Typography, { color: "text.disabled", children: "You haven't generated any pictures yet." }) }));
|
|
77
|
-
}
|
|
78
|
-
function OutputView() {
|
|
79
|
-
var _a, _b, _c, _d, _e;
|
|
80
|
-
const { t } = useLocaleContext();
|
|
81
|
-
const { sessionState } = useRuntimeState();
|
|
82
|
-
return (_jsxs(_Fragment, { children: [sessionState.loaded && !((_a = sessionState.messages) === null || _a === void 0 ? void 0 : _a.length) && _jsx(NoOutputs, {}), _jsxs(Masonry, { columns: { xs: 2, sm: 3, md: 4, lg: 5 }, spacing: 1, sequential: true, sx: { width: '100%', overflow: 'hidden' }, children: [sessionState.running && (_jsx(Skeleton, { className: "photo-wall-item", variant: "rectangular", sx: {
|
|
83
|
-
// FIXME: default using history height
|
|
84
|
-
height: (_c = (_b = document.getElementsByClassName('photo-wall-item')[0]) === null || _b === void 0 ? void 0 : _b.clientHeight) !== null && _c !== void 0 ? _c : 200,
|
|
85
|
-
} })), mapRight((_d = sessionState.messages) !== null && _d !== void 0 ? _d : [], (message) => (_jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(OutputItemView, {}) }) }) }, message.taskId)))] }), _jsx(Box, { my: 4, children: !!((_e = sessionState.messages) === null || _e === void 0 ? void 0 : _e.length) && !sessionState.noMoreMessage && (_jsx(LoadingButton, { variant: "outlined", onClick: sessionState.loadMoreMessages, children: t('loadMore') })) })] }));
|
|
86
|
-
}
|
|
87
|
-
function OutputItemView() {
|
|
88
|
-
const { appearanceOutput } = useCurrentAgent();
|
|
89
|
-
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
90
|
-
return null;
|
|
91
|
-
return (_jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
|
|
92
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Stack, ThemeProvider, Typography, createTheme, useTheme } from '@mui/material';
|
|
3
|
-
import { Suspense, useMemo } from 'react';
|
|
4
|
-
import Balancer, { Provider } from 'react-wrap-balancer';
|
|
5
|
-
import CustomComponentRenderer from '../../../../../../../components/CustomComponentRenderer';
|
|
6
|
-
import CurrentAgentProvider, { useCurrentAgent } from '../../contexts/CurrentAgent';
|
|
7
|
-
import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
8
|
-
import { useRuntimeState } from '../../state/runtime';
|
|
9
|
-
export default function SimplePage({ resultTitle, primaryColor }) {
|
|
10
|
-
const { agent, appearancePage, childAgentId } = useRuntimeState();
|
|
11
|
-
const inheritedTheme = useTheme();
|
|
12
|
-
const theme = useMemo(() => {
|
|
13
|
-
let { primary } = inheritedTheme.palette;
|
|
14
|
-
try {
|
|
15
|
-
if (primaryColor) {
|
|
16
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
console.error('augment primary color error', { error });
|
|
21
|
-
}
|
|
22
|
-
return createTheme(inheritedTheme, {
|
|
23
|
-
palette: { primary },
|
|
24
|
-
shape: {
|
|
25
|
-
borderRadius: 8,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}, [inheritedTheme, primaryColor]);
|
|
29
|
-
const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
|
|
30
|
-
const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
|
|
31
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Stack, { gap: 2, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [_jsx(Stack, { gap: 2, mt: 8, mb: 4, children: _jsxs(Provider, { children: [title && (_jsx(Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: title }) })), description && (_jsx(Typography, { textAlign: "center", children: _jsx(Balancer, { children: description }) }))] }) }), _jsx(Stack, { children: _jsx(CurrentAgentProvider, { agentId: childAgentId, children: _jsx(AgentInputRender, {}) }) }), _jsx(Stack, { children: _jsx(OutputView, { resultTitle: resultTitle }) })] }) }));
|
|
32
|
-
}
|
|
33
|
-
function AgentInputRender() {
|
|
34
|
-
const { appearanceInput } = useCurrentAgent();
|
|
35
|
-
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
36
|
-
return null;
|
|
37
|
-
return (_jsx(Stack, { children: _jsx(CustomComponentRenderer, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
|
|
38
|
-
}
|
|
39
|
-
function OutputView({ resultTitle }) {
|
|
40
|
-
var _a;
|
|
41
|
-
const { sessionState } = useRuntimeState();
|
|
42
|
-
const lastMessage = (_a = sessionState.messages) === null || _a === void 0 ? void 0 : _a.slice(-1)[0];
|
|
43
|
-
return (_jsx(Stack, { gap: 2, children: lastMessage && (_jsxs(_Fragment, { children: [_jsx(Stack, { children: resultTitle && (_jsx(Typography, { component: "h5", fontSize: 36, fontWeight: 700, textAlign: "center", children: _jsx(Balancer, { children: resultTitle }) })) }), _jsx(Stack, { children: _jsx(CurrentAgentProvider, { agentId: lastMessage.assistantId, children: _jsx(CurrentMessageProvider, { message: lastMessage, children: _jsx(Suspense, { children: _jsx(OutputItemView, {}) }) }) }) })] })) }));
|
|
44
|
-
}
|
|
45
|
-
function OutputItemView() {
|
|
46
|
-
const { appearanceOutput } = useCurrentAgent();
|
|
47
|
-
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
48
|
-
return null;
|
|
49
|
-
return (_jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
|
|
50
|
-
}
|
|
@@ -1,209 +0,0 @@
|
|
|
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
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
11
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
-
var m = o[Symbol.asyncIterator], i;
|
|
13
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
14
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
15
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
|
-
};
|
|
17
|
-
import { create } from 'zustand';
|
|
18
|
-
import { immer } from 'zustand/middleware/immer';
|
|
19
|
-
import { getMessages } from '../../../api/message';
|
|
20
|
-
import { createSession, getSessions, runAssistant } from '../../../api/session';
|
|
21
|
-
import { parseIdentity } from '../../../utils';
|
|
22
|
-
const STATES = {};
|
|
23
|
-
const GET_MESSAGES_LIMIT = 100;
|
|
24
|
-
const GET_MESSAGES_ORDER_DIRECTION = 'desc';
|
|
25
|
-
export const createSessionState = ({ aid }) => {
|
|
26
|
-
var _a;
|
|
27
|
-
(_a = STATES[aid]) !== null && _a !== void 0 ? _a : (STATES[aid] = create()(immer((set, get) => ({
|
|
28
|
-
reset: () => {
|
|
29
|
-
set((state) => {
|
|
30
|
-
state.loading = undefined;
|
|
31
|
-
state.loaded = undefined;
|
|
32
|
-
state.running = undefined;
|
|
33
|
-
state.session = undefined;
|
|
34
|
-
state.messages = undefined;
|
|
35
|
-
state.noMoreMessage = undefined;
|
|
36
|
-
state.messageLoading = undefined;
|
|
37
|
-
state.error = undefined;
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
var _b;
|
|
42
|
-
set((state) => {
|
|
43
|
-
state.loading = true;
|
|
44
|
-
});
|
|
45
|
-
try {
|
|
46
|
-
const { sessions } = yield getSessions(parseIdentity(aid, { rejectWhenError: true }));
|
|
47
|
-
const session = (_b = sessions[0]) !== null && _b !== void 0 ? _b : (yield createSession({ assistantId: aid })).created;
|
|
48
|
-
const { messages } = yield getMessages({
|
|
49
|
-
sessionId: session.id,
|
|
50
|
-
orderDirection: GET_MESSAGES_ORDER_DIRECTION,
|
|
51
|
-
limit: GET_MESSAGES_LIMIT,
|
|
52
|
-
});
|
|
53
|
-
set((state) => {
|
|
54
|
-
state.session = session;
|
|
55
|
-
state.messages = messages.toReversed();
|
|
56
|
-
state.noMoreMessage = messages.length < GET_MESSAGES_LIMIT;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
set((state) => {
|
|
61
|
-
state.error = error;
|
|
62
|
-
});
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
set((state) => {
|
|
67
|
-
state.loaded = true;
|
|
68
|
-
state.loading = false;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
loadMoreMessages: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
var _c;
|
|
74
|
-
set((state) => {
|
|
75
|
-
state.messageLoading = true;
|
|
76
|
-
});
|
|
77
|
-
const { session, messages } = get();
|
|
78
|
-
if (!session)
|
|
79
|
-
return;
|
|
80
|
-
try {
|
|
81
|
-
const result = yield getMessages({
|
|
82
|
-
sessionId: session.id,
|
|
83
|
-
before: (_c = messages === null || messages === void 0 ? void 0 : messages.slice(-1)[0]) === null || _c === void 0 ? void 0 : _c.id,
|
|
84
|
-
orderDirection: GET_MESSAGES_ORDER_DIRECTION,
|
|
85
|
-
limit: GET_MESSAGES_LIMIT,
|
|
86
|
-
});
|
|
87
|
-
set((state) => {
|
|
88
|
-
var _a;
|
|
89
|
-
state.messages = ((_a = state.messages) !== null && _a !== void 0 ? _a : []).concat(result.messages.toReversed());
|
|
90
|
-
state.noMoreMessage = result.messages.length < GET_MESSAGES_LIMIT;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
finally {
|
|
94
|
-
set((state) => {
|
|
95
|
-
state.messageLoading = false;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
execute: (_d) => __awaiter(void 0, [_d], void 0, function* ({ aid, working, parameters, onResponseStart, }) {
|
|
100
|
-
var _e, e_1, _f, _g;
|
|
101
|
-
let { session } = get();
|
|
102
|
-
if (!session) {
|
|
103
|
-
yield get().load();
|
|
104
|
-
session = get().session;
|
|
105
|
-
}
|
|
106
|
-
if (!session)
|
|
107
|
-
throw new Error('This session is not initialized');
|
|
108
|
-
const { id: sessionId } = session;
|
|
109
|
-
const identity = parseIdentity(aid, { rejectWhenError: true });
|
|
110
|
-
let message;
|
|
111
|
-
set((state) => {
|
|
112
|
-
state.running = true;
|
|
113
|
-
state.error = undefined;
|
|
114
|
-
});
|
|
115
|
-
try {
|
|
116
|
-
const stream = runAssistant({
|
|
117
|
-
sessionId,
|
|
118
|
-
identity,
|
|
119
|
-
working,
|
|
120
|
-
parameters: Object.assign(Object.assign({}, parameters), { $clientTime: new Date().toISOString() }),
|
|
121
|
-
});
|
|
122
|
-
let responseStarted = false;
|
|
123
|
-
try {
|
|
124
|
-
for (var _h = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _e = stream_1_1.done, !_e; _h = true) {
|
|
125
|
-
_g = stream_1_1.value;
|
|
126
|
-
_h = false;
|
|
127
|
-
const value = _g;
|
|
128
|
-
if (!responseStarted) {
|
|
129
|
-
responseStarted = true;
|
|
130
|
-
onResponseStart === null || onResponseStart === void 0 ? void 0 : onResponseStart();
|
|
131
|
-
}
|
|
132
|
-
if ((value === null || value === void 0 ? void 0 : value.type) === 'CHUNK') {
|
|
133
|
-
if (!message) {
|
|
134
|
-
message = {
|
|
135
|
-
taskId: value.taskId,
|
|
136
|
-
assistantId: identity.assistantId,
|
|
137
|
-
sessionId,
|
|
138
|
-
parameters,
|
|
139
|
-
createdAt: new Date().toISOString(),
|
|
140
|
-
updatedAt: new Date().toISOString(),
|
|
141
|
-
loading: true,
|
|
142
|
-
};
|
|
143
|
-
set((state) => {
|
|
144
|
-
var _a;
|
|
145
|
-
(_a = state.messages) !== null && _a !== void 0 ? _a : (state.messages = []);
|
|
146
|
-
state.messages.push(message);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
if (message.taskId === value.taskId) {
|
|
150
|
-
requestAnimationFrame(() => {
|
|
151
|
-
set((state) => {
|
|
152
|
-
var _a, _b, _c, _d, _e, _f;
|
|
153
|
-
var _g;
|
|
154
|
-
const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
|
|
155
|
-
if (!msg)
|
|
156
|
-
return;
|
|
157
|
-
(_b = msg.result) !== null && _b !== void 0 ? _b : (msg.result = {});
|
|
158
|
-
msg.result.content = (msg.result.content || '') + (value.delta.content || '');
|
|
159
|
-
if ((_d = (_c = value.delta) === null || _c === void 0 ? void 0 : _c.images) === null || _d === void 0 ? void 0 : _d.length) {
|
|
160
|
-
msg.result.images = ((_e = msg.result.images) !== null && _e !== void 0 ? _e : []).concat(value.delta.images);
|
|
161
|
-
}
|
|
162
|
-
if (value.delta.object) {
|
|
163
|
-
(_f = (_g = msg.result).objects) !== null && _f !== void 0 ? _f : (_g.objects = []);
|
|
164
|
-
msg.result.objects.push({ taskId: value.taskId, data: value.delta.object });
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if ((value === null || value === void 0 ? void 0 : value.type) === 'ERROR') {
|
|
171
|
-
set((state) => {
|
|
172
|
-
var _a;
|
|
173
|
-
const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
|
|
174
|
-
if (msg)
|
|
175
|
-
msg.error = value.error;
|
|
176
|
-
else
|
|
177
|
-
throw new Error(value.error.message);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
183
|
-
finally {
|
|
184
|
-
try {
|
|
185
|
-
if (!_h && !_e && (_f = stream_1.return)) yield _f.call(stream_1);
|
|
186
|
-
}
|
|
187
|
-
finally { if (e_1) throw e_1.error; }
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
set((state) => {
|
|
192
|
-
state.error = error;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
finally {
|
|
196
|
-
set((state) => {
|
|
197
|
-
var _a;
|
|
198
|
-
state.running = false;
|
|
199
|
-
if (message) {
|
|
200
|
-
const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
|
|
201
|
-
if (msg)
|
|
202
|
-
msg.loading = false;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}),
|
|
207
|
-
}))));
|
|
208
|
-
return STATES[aid];
|
|
209
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
-
import { Box, Stack, alpha } from '@mui/material';
|
|
23
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
24
|
-
import { useSessionContext } from '../../../../session';
|
|
25
|
-
import { createSession } from '../../api/session';
|
|
26
|
-
import { useAssistantState } from '../../state/assistant';
|
|
27
|
-
import { globalLoadingState } from '../../state/loading';
|
|
28
|
-
import { createSessionState } from '../../state/session';
|
|
29
|
-
import { MessageSuggestedQuestion } from '../common/MessageSuggestedQuestions';
|
|
30
|
-
import ParameterForm from '../form/ParameterForm';
|
|
31
|
-
import MessageErrorView from '../message/MessageErrorView';
|
|
32
|
-
import MessageItemView, { MessageItemWrapper } from '../message/MessageItemView';
|
|
33
|
-
import PoweredBy from '../PoweredBy';
|
|
34
|
-
export default function InitialForm({ page }) {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
const { assistantId } = page;
|
|
37
|
-
const { session: authSession } = useSessionContext();
|
|
38
|
-
const [assistant] = useAssistantState({ assistantId: page.assistantId });
|
|
39
|
-
const [error, setError] = useState();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
var _a;
|
|
42
|
-
if (error && authSession.user && ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
43
|
-
onSubmit(error.parameters);
|
|
44
|
-
setError(undefined);
|
|
45
|
-
}
|
|
46
|
-
}, [authSession.user]);
|
|
47
|
-
const opener = useMemo(() => {
|
|
48
|
-
var _a;
|
|
49
|
-
const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
|
|
50
|
-
if (openerMessage) {
|
|
51
|
-
return {
|
|
52
|
-
taskId: '',
|
|
53
|
-
sessionId: '',
|
|
54
|
-
assistantId: '',
|
|
55
|
-
createdAt: new Date().toISOString(),
|
|
56
|
-
updatedAt: new Date().toISOString(),
|
|
57
|
-
result: { content: openerMessage },
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
}, [assistant.release]);
|
|
62
|
-
const [creating, setCreating] = useState(false);
|
|
63
|
-
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
if (creating)
|
|
65
|
-
return;
|
|
66
|
-
setCreating(true);
|
|
67
|
-
try {
|
|
68
|
-
yield globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const { created: session } = yield createSession({
|
|
70
|
-
assistantId,
|
|
71
|
-
name: typeof (parameters === null || parameters === void 0 ? void 0 : parameters.question) === 'string' ? parameters.question : undefined,
|
|
72
|
-
parameters,
|
|
73
|
-
});
|
|
74
|
-
createSessionState({ sessionId: session.id, session }).getState().execute({
|
|
75
|
-
assistantId,
|
|
76
|
-
parameters,
|
|
77
|
-
});
|
|
78
|
-
page.navigate({ page: 'session', assistantId, sessionId: session.id });
|
|
79
|
-
}));
|
|
80
|
-
setError(undefined);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
setError({ error, parameters });
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
setCreating(false);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
if (authSession.loading)
|
|
91
|
-
return null;
|
|
92
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { mt: 5, mb: 5, px: 2 }, children: [opener && (_jsx(Box, { mb: 2, children: _jsx(MessageItemView, { page: page, message: opener }) })), ((_a = assistant.entries) === null || _a === void 0 ? void 0 : _a.length) && (_jsx(EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(entry.parameters), sx: { pl: 6.5, pr: 2.5 } })), error && (_jsx(MessageItemWrapper, { assistant: assistant, agentMessage: _jsx(MessageErrorView, { error: error.error, page: page }), sx: { mt: 2 } }))] }), _jsx(Box, { flex: 1 }), _jsxs(Box, { className: "ai-runtime-form-container", sx: {
|
|
93
|
-
position: 'sticky',
|
|
94
|
-
bottom: 0,
|
|
95
|
-
background: (theme) => `linear-gradient(180deg, ${alpha(theme.palette.background.default, 0.1)}, ${alpha(theme.palette.background.default, 1)} 16px)`,
|
|
96
|
-
}, children: [_jsx(ParameterForm, { disabled: ((_b = error === null || error === void 0 ? void 0 : error.error) === null || _b === void 0 ? void 0 : _b.status) === 401, page: page, assistant: assistant, onSubmit: onSubmit }), _jsx(PoweredBy, { assistantId: page.assistantId, sx: { my: 1, px: 2 } })] })] }));
|
|
97
|
-
}
|
|
98
|
-
export function EntryListView(_a) {
|
|
99
|
-
var _b;
|
|
100
|
-
var { assistant, onEntryClick } = _a, props = __rest(_a, ["assistant", "onEntryClick"]);
|
|
101
|
-
return (_jsx(Stack, Object.assign({ gap: 1, alignItems: "flex-start" }, props, { children: (_b = assistant.entries) === null || _b === void 0 ? void 0 : _b.map((entry) => entry.title && (_jsx(MessageSuggestedQuestion, { onClick: () => onEntryClick === null || onEntryClick === void 0 ? void 0 : onEntryClick(entry), children: entry.title }, entry.title))) })));
|
|
102
|
-
}
|