@baishuyun/chat-sdk 0.0.18 → 0.1.1
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/.turbo/turbo-build.log +175 -178
- package/CHANGELOG.md +25 -0
- package/dist/chat-sdk.js +11116 -11004
- package/dist/chat-sdk.js.map +1 -1
- package/dist/chat-sdk.umd.cjs +129 -127
- package/dist/chat-sdk.umd.cjs.map +1 -1
- package/dist/chat.d.ts +5 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/components/biz-comp/FakeBotMsg.d.ts +8 -0
- package/dist/components/biz-comp/FakeBotMsg.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldChecker.d.ts +19 -0
- package/dist/components/biz-comp/FieldChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldCheckerListMsg.d.ts +19 -0
- package/dist/components/biz-comp/FieldCheckerListMsg.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldValueChecker.d.ts +16 -0
- package/dist/components/biz-comp/FieldValueChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts +22 -0
- package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/chat-client.d.ts +13 -0
- package/dist/components/biz-comp/chat-client.d.ts.map +1 -0
- package/dist/components/biz-comp/chat-frame.d.ts +6 -0
- package/dist/components/biz-comp/chat-frame.d.ts.map +1 -0
- package/dist/components/biz-comp/conversation.d.ts +10 -0
- package/dist/components/biz-comp/conversation.d.ts.map +1 -0
- package/dist/components/biz-comp/dash-widget-icon.d.ts +7 -0
- package/dist/components/biz-comp/dash-widget-icon.d.ts.map +1 -0
- package/dist/components/biz-comp/dock-btn.d.ts +2 -0
- package/dist/components/biz-comp/dock-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/error-boundary.d.ts +15 -0
- package/dist/components/biz-comp/error-boundary.d.ts.map +1 -0
- package/dist/components/biz-comp/error-msg.d.ts +4 -0
- package/dist/components/biz-comp/error-msg.d.ts.map +1 -0
- package/dist/components/biz-comp/field-icon.d.ts +5 -0
- package/dist/components/biz-comp/field-icon.d.ts.map +1 -0
- package/dist/components/biz-comp/highlight-msg.d.ts +4 -0
- package/dist/components/biz-comp/highlight-msg.d.ts.map +1 -0
- package/dist/components/biz-comp/markdown-part.d.ts +7 -0
- package/dist/components/biz-comp/markdown-part.d.ts.map +1 -0
- package/dist/components/biz-comp/markdown.d.ts +5 -0
- package/dist/components/biz-comp/markdown.d.ts.map +1 -0
- package/dist/components/biz-comp/message-content.d.ts +6 -0
- package/dist/components/biz-comp/message-content.d.ts.map +1 -0
- package/dist/components/biz-comp/messages.d.ts +3 -0
- package/dist/components/biz-comp/messages.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts +9 -0
- package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts +8 -0
- package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/index.d.ts +21 -0
- package/dist/components/biz-comp/multi-modal-input/index.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts +12 -0
- package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts +36 -0
- package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts.map +1 -0
- package/dist/components/biz-comp/opening-lines.d.ts +3 -0
- package/dist/components/biz-comp/opening-lines.d.ts.map +1 -0
- package/dist/components/biz-comp/preview-message-wrapper.d.ts +12 -0
- package/dist/components/biz-comp/preview-message-wrapper.d.ts.map +1 -0
- package/dist/components/biz-comp/preview-message.d.ts +13 -0
- package/dist/components/biz-comp/preview-message.d.ts.map +1 -0
- package/dist/components/biz-comp/response.d.ts +6 -0
- package/dist/components/biz-comp/response.d.ts.map +1 -0
- package/dist/components/biz-comp/suggestions.d.ts +8 -0
- package/dist/components/biz-comp/suggestions.d.ts.map +1 -0
- package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts +10 -0
- package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts.map +1 -0
- package/dist/components/bs-ui/attachment-part-group.d.ts +16 -0
- package/dist/components/bs-ui/attachment-part-group.d.ts.map +1 -0
- package/dist/components/bs-ui/attachment-part.d.ts +19 -0
- package/dist/components/bs-ui/attachment-part.d.ts.map +1 -0
- package/dist/components/bs-ui/attachments-previewer.d.ts +18 -0
- package/dist/components/bs-ui/attachments-previewer.d.ts.map +1 -0
- package/dist/components/bs-ui/base-button.d.ts +8 -0
- package/dist/components/bs-ui/base-button.d.ts.map +1 -0
- package/dist/components/bs-ui/border-animation.d.ts +23 -0
- package/dist/components/bs-ui/border-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/border-color-animation.d.ts +11 -0
- package/dist/components/bs-ui/border-color-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/bot-avatar-name.d.ts +6 -0
- package/dist/components/bs-ui/bot-avatar-name.d.ts.map +1 -0
- package/dist/components/bs-ui/bot-icon.d.ts +5 -0
- package/dist/components/bs-ui/bot-icon.d.ts.map +1 -0
- package/dist/components/bs-ui/bs-icons.d.ts +65 -0
- package/dist/components/bs-ui/bs-icons.d.ts.map +1 -0
- package/dist/components/bs-ui/card-field.d.ts +11 -0
- package/dist/components/bs-ui/card-field.d.ts.map +1 -0
- package/dist/components/bs-ui/card.d.ts +11 -0
- package/dist/components/bs-ui/card.d.ts.map +1 -0
- package/dist/components/bs-ui/chat-area-header.d.ts +13 -0
- package/dist/components/bs-ui/chat-area-header.d.ts.map +1 -0
- package/dist/components/bs-ui/circle-checker.d.ts +10 -0
- package/dist/components/bs-ui/circle-checker.d.ts.map +1 -0
- package/dist/components/bs-ui/collapsible-txt-msg.d.ts +11 -0
- package/dist/components/bs-ui/collapsible-txt-msg.d.ts.map +1 -0
- package/dist/components/bs-ui/confirm-dialog.d.ts +26 -0
- package/dist/components/bs-ui/confirm-dialog.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-design-info-table.d.ts +7 -0
- package/dist/components/bs-ui/fields-design-info-table.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-generating-indicator.d.ts +6 -0
- package/dist/components/bs-ui/fields-generating-indicator.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-portal.d.ts +8 -0
- package/dist/components/bs-ui/fields-portal.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-previewer.d.ts +18 -0
- package/dist/components/bs-ui/fields-previewer.d.ts.map +1 -0
- package/dist/components/bs-ui/font-icon.d.ts +6 -0
- package/dist/components/bs-ui/font-icon.d.ts.map +1 -0
- package/dist/components/bs-ui/form-info-editor.d.ts +37 -0
- package/dist/components/bs-ui/form-info-editor.d.ts.map +1 -0
- package/dist/components/bs-ui/formula-tag.d.ts +8 -0
- package/dist/components/bs-ui/formula-tag.d.ts.map +1 -0
- package/dist/components/bs-ui/generate-animation.d.ts +5 -0
- package/dist/components/bs-ui/generate-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/icon-btn.d.ts +9 -0
- package/dist/components/bs-ui/icon-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/img-part.d.ts +10 -0
- package/dist/components/bs-ui/img-part.d.ts.map +1 -0
- package/dist/components/bs-ui/line-checker.d.ts +19 -0
- package/dist/components/bs-ui/line-checker.d.ts.map +1 -0
- package/dist/components/bs-ui/linear-gradient-border-btn.d.ts +10 -0
- package/dist/components/bs-ui/linear-gradient-border-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts +8 -0
- package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/number-part.d.ts +9 -0
- package/dist/components/bs-ui/number-part.d.ts.map +1 -0
- package/dist/components/bs-ui/option-item.d.ts +9 -0
- package/dist/components/bs-ui/option-item.d.ts.map +1 -0
- package/dist/components/bs-ui/previewer-header.d.ts +20 -0
- package/dist/components/bs-ui/previewer-header.d.ts.map +1 -0
- package/dist/components/bs-ui/primary-confirm-btn.d.ts +10 -0
- package/dist/components/bs-ui/primary-confirm-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/primary-entry-btn.d.ts +9 -0
- package/dist/components/bs-ui/primary-entry-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/scroll-to-bottom-btn.d.ts +6 -0
- package/dist/components/bs-ui/scroll-to-bottom-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/split-line.d.ts +5 -0
- package/dist/components/bs-ui/split-line.d.ts.map +1 -0
- package/dist/components/bs-ui/square-checker.d.ts +15 -0
- package/dist/components/bs-ui/square-checker.d.ts.map +1 -0
- package/dist/components/bs-ui/tab-radio-group.d.ts +19 -0
- package/dist/components/bs-ui/tab-radio-group.d.ts.map +1 -0
- package/dist/components/bs-ui/tooltip.d.ts +6 -0
- package/dist/components/bs-ui/tooltip.d.ts.map +1 -0
- package/dist/components/bs-ui/user-txt-msg-bubble.d.ts +6 -0
- package/dist/components/bs-ui/user-txt-msg-bubble.d.ts.map +1 -0
- package/dist/components/bs-ui/warning-msg.d.ts +6 -0
- package/dist/components/bs-ui/warning-msg.d.ts.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/dialog.d.ts +24 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/icons.d.ts +176 -0
- package/dist/components/ui/icons.d.ts.map +1 -0
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/one-time-click-btn.d.ts +4 -0
- package/dist/components/ui/one-time-click-btn.d.ts.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/spinner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/tooltip.d.ts +13 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/web-comp/fields-previewer-web-component.d.ts +60 -0
- package/dist/components/web-comp/fields-previewer-web-component.d.ts.map +1 -0
- package/dist/const/index.d.ts +5 -0
- package/dist/const/index.d.ts.map +1 -0
- package/dist/const/ui.d.ts +7 -0
- package/dist/const/ui.d.ts.map +1 -0
- package/dist/hooks/use-chat-preference.d.ts +3 -0
- package/dist/hooks/use-chat-preference.d.ts.map +1 -0
- package/dist/hooks/use-draggable.d.ts +24 -0
- package/dist/hooks/use-draggable.d.ts.map +1 -0
- package/dist/hooks/use-evt-bus.d.ts +2 -0
- package/dist/hooks/use-evt-bus.d.ts.map +1 -0
- package/dist/hooks/use-evt.d.ts +3 -0
- package/dist/hooks/use-evt.d.ts.map +1 -0
- package/dist/hooks/use-frame-mode.d.ts +20 -0
- package/dist/hooks/use-frame-mode.d.ts.map +1 -0
- package/dist/hooks/use-merged-chat.d.ts +7 -0
- package/dist/hooks/use-merged-chat.d.ts.map +1 -0
- package/dist/hooks/use-msg-status-broadcast.d.ts +3 -0
- package/dist/hooks/use-msg-status-broadcast.d.ts.map +1 -0
- package/dist/hooks/use-plugin-component.d.ts +5 -0
- package/dist/hooks/use-plugin-component.d.ts.map +1 -0
- package/dist/hooks/use-plugin-ctx.d.ts +3 -0
- package/dist/hooks/use-plugin-ctx.d.ts.map +1 -0
- package/dist/hooks/use-plugin-custom-components.d.ts +5 -0
- package/dist/hooks/use-plugin-custom-components.d.ts.map +1 -0
- package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts +5 -0
- package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts.map +1 -0
- package/dist/hooks/use-plugin-list.d.ts +2 -0
- package/dist/hooks/use-plugin-list.d.ts.map +1 -0
- package/dist/hooks/use-plugin.d.ts +2 -0
- package/dist/hooks/use-plugin.d.ts.map +1 -0
- package/dist/hooks/use-scroll-to-bottom.d.ts +9 -0
- package/dist/hooks/use-scroll-to-bottom.d.ts.map +1 -0
- package/dist/hooks/use-shadow.d.ts +25 -0
- package/dist/hooks/use-shadow.d.ts.map +1 -0
- package/dist/hooks/use-toast.d.ts +3 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/clone.d.ts +32 -0
- package/dist/lib/clone.d.ts.map +1 -0
- package/dist/lib/event-emitter.d.ts +39 -0
- package/dist/lib/event-emitter.d.ts.map +1 -0
- package/dist/lib/parse-design-doc.d.ts +16 -0
- package/dist/lib/parse-design-doc.d.ts.map +1 -0
- package/dist/lib/readonly.d.ts +14 -0
- package/dist/lib/readonly.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +55 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/const.d.ts +3 -0
- package/dist/plugins/form-builder-base-plugin/const.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/index.d.ts +7 -0
- package/dist/plugins/form-builder-base-plugin/index.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/types.d.ts +12 -0
- package/dist/plugins/form-builder-base-plugin/types.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/create-form-confirm.d.ts +7 -0
- package/dist/plugins/form-builder-plugin/components/create-form-confirm.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/design-doc-part.d.ts +4 -0
- package/dist/plugins/form-builder-plugin/components/design-doc-part.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/design-info.d.ts +6 -0
- package/dist/plugins/form-builder-plugin/components/design-info.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/entry-btn.d.ts +3 -0
- package/dist/plugins/form-builder-plugin/components/entry-btn.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/fields-part.d.ts +4 -0
- package/dist/plugins/form-builder-plugin/components/fields-part.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/follow-up.d.ts +3 -0
- package/dist/plugins/form-builder-plugin/components/follow-up.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/msg-part.d.ts +3 -0
- package/dist/plugins/form-builder-plugin/components/msg-part.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/opening-lines.d.ts +3 -0
- package/dist/plugins/form-builder-plugin/components/opening-lines.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/components/suggestion-part.d.ts +5 -0
- package/dist/plugins/form-builder-plugin/components/suggestion-part.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/const/index.d.ts +12 -0
- package/dist/plugins/form-builder-plugin/const/index.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/hooks/index.d.ts +4 -0
- package/dist/plugins/form-builder-plugin/hooks/index.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/hooks/use-fields-confirmed.d.ts +2 -0
- package/dist/plugins/form-builder-plugin/hooks/use-fields-confirmed.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/index.d.ts +30 -0
- package/dist/plugins/form-builder-plugin/index.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/types.d.ts +28 -0
- package/dist/plugins/form-builder-plugin/types.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/utils/get-render-strategy.d.ts +3 -0
- package/dist/plugins/form-builder-plugin/utils/get-render-strategy.d.ts.map +1 -0
- package/dist/plugins/form-builder-plugin/utils/index.d.ts +57 -0
- package/dist/plugins/form-builder-plugin/utils/index.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/batch-filling-data-manager.d.ts +26 -0
- package/dist/plugins/form-filling-plugin/batch-filling-data-manager.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/avatar.d.ts +5 -0
- package/dist/plugins/form-filling-plugin/components/avatar.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/batch-fill-part.d.ts +4 -0
- package/dist/plugins/form-filling-plugin/components/batch-fill-part.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/batch-generator-action.d.ts +14 -0
- package/dist/plugins/form-filling-plugin/components/batch-generator-action.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/first-batch-generating-animation.d.ts +2 -0
- package/dist/plugins/form-filling-plugin/components/first-batch-generating-animation.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/generated-data-counter.d.ts +5 -0
- package/dist/plugins/form-filling-plugin/components/generated-data-counter.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/mode-select.d.ts +2 -0
- package/dist/plugins/form-filling-plugin/components/mode-select.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/msg-part.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/components/msg-part.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/non-first-batch-generating-animation.d.ts +2 -0
- package/dist/plugins/form-filling-plugin/components/non-first-batch-generating-animation.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/single-fill-part.d.ts +4 -0
- package/dist/plugins/form-filling-plugin/components/single-fill-part.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/const.d.ts +615 -0
- package/dist/plugins/form-filling-plugin/const.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/hooks/use-conversation-id-in-ctx.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/hooks/use-conversation-id-in-ctx.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/hooks/use-fields-data.d.ts +4 -0
- package/dist/plugins/form-filling-plugin/hooks/use-fields-data.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/index.d.ts +22 -0
- package/dist/plugins/form-filling-plugin/index.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/types.d.ts +22 -0
- package/dist/plugins/form-filling-plugin/types.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/utils.d.ts +6 -0
- package/dist/plugins/form-filling-plugin/utils.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/avatar.d.ts +5 -0
- package/dist/plugins/report-query-plugin/components/avatar.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/query-entry-btn.d.ts +3 -0
- package/dist/plugins/report-query-plugin/components/query-entry-btn.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/query-msg-part.d.ts +3 -0
- package/dist/plugins/report-query-plugin/components/query-msg-part.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/query-opening-lines.d.ts +2 -0
- package/dist/plugins/report-query-plugin/components/query-opening-lines.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/result-cards/CreatedSourceMsg.d.ts +7 -0
- package/dist/plugins/report-query-plugin/components/result-cards/CreatedSourceMsg.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/result-cards/DataTableCard.d.ts +5 -0
- package/dist/plugins/report-query-plugin/components/result-cards/DataTableCard.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/result-cards/DataTableFields.d.ts +18 -0
- package/dist/plugins/report-query-plugin/components/result-cards/DataTableFields.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/result-cards/FilterCondition.d.ts +4 -0
- package/dist/plugins/report-query-plugin/components/result-cards/FilterCondition.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/components/result-cards/FormulaField.d.ts +8 -0
- package/dist/plugins/report-query-plugin/components/result-cards/FormulaField.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/const.d.ts +5 -0
- package/dist/plugins/report-query-plugin/const.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/index.d.ts +19 -0
- package/dist/plugins/report-query-plugin/index.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/types.d.ts +18 -0
- package/dist/plugins/report-query-plugin/types.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/build-dash-component.d.ts +17 -0
- package/dist/plugins/report-query-plugin/utils/build-dash-component.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/create-default-dash-styles.d.ts +30 -0
- package/dist/plugins/report-query-plugin/utils/create-default-dash-styles.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/create-default-widget-attr-list.d.ts +60 -0
- package/dist/plugins/report-query-plugin/utils/create-default-widget-attr-list.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/field-enhance.d.ts +31 -0
- package/dist/plugins/report-query-plugin/utils/field-enhance.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/get-field-group.d.ts +208 -0
- package/dist/plugins/report-query-plugin/utils/get-field-group.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/get-field-icon.d.ts +4 -0
- package/dist/plugins/report-query-plugin/utils/get-field-icon.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/get-group-rule.d.ts +4 -0
- package/dist/plugins/report-query-plugin/utils/get-group-rule.d.ts.map +1 -0
- package/dist/plugins/report-query-plugin/utils/index.d.ts +5 -0
- package/dist/plugins/report-query-plugin/utils/index.d.ts.map +1 -0
- package/dist/sdk.impl.d.ts +42 -0
- package/dist/sdk.impl.d.ts.map +1 -0
- package/dist/store/context.d.ts +12 -0
- package/dist/store/context.d.ts.map +1 -0
- package/dist/store/index.d.ts +14 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/stories/AbsFullscreenGradientBg.stories.d.ts +17 -0
- package/dist/stories/AbsFullscreenGradientBg.stories.d.ts.map +1 -0
- package/dist/stories/AttachmentPart.stories.d.ts +23 -0
- package/dist/stories/AttachmentPart.stories.d.ts.map +1 -0
- package/dist/stories/AttachmentPartGroup.stories.d.ts +21 -0
- package/dist/stories/AttachmentPartGroup.stories.d.ts.map +1 -0
- package/dist/stories/AttachmentsPreviewer.stories.d.ts +20 -0
- package/dist/stories/AttachmentsPreviewer.stories.d.ts.map +1 -0
- package/dist/stories/BaseButton.stories.d.ts +18 -0
- package/dist/stories/BaseButton.stories.d.ts.map +1 -0
- package/dist/stories/BorderAnimation.stories.d.ts +21 -0
- package/dist/stories/BorderAnimation.stories.d.ts.map +1 -0
- package/dist/stories/BorderColorAnimation.stories.d.ts +26 -0
- package/dist/stories/BorderColorAnimation.stories.d.ts.map +1 -0
- package/dist/stories/BotAvatarAndName.stories.d.ts +18 -0
- package/dist/stories/BotAvatarAndName.stories.d.ts.map +1 -0
- package/dist/stories/BotIcon.stories.d.ts +17 -0
- package/dist/stories/BotIcon.stories.d.ts.map +1 -0
- package/dist/stories/BsTooltip.stories.d.ts +7 -0
- package/dist/stories/BsTooltip.stories.d.ts.map +1 -0
- package/dist/stories/Card.stories.d.ts +14 -0
- package/dist/stories/Card.stories.d.ts.map +1 -0
- package/dist/stories/CardField.stories.d.ts +13 -0
- package/dist/stories/CardField.stories.d.ts.map +1 -0
- package/dist/stories/ChatAreaHeader.stories.d.ts +14 -0
- package/dist/stories/ChatAreaHeader.stories.d.ts.map +1 -0
- package/dist/stories/CircleChecker.stories.d.ts +21 -0
- package/dist/stories/CircleChecker.stories.d.ts.map +1 -0
- package/dist/stories/CollapsibleTextMsg.stories.d.ts +16 -0
- package/dist/stories/CollapsibleTextMsg.stories.d.ts.map +1 -0
- package/dist/stories/ConfirmDialog.stories.d.ts +61 -0
- package/dist/stories/ConfirmDialog.stories.d.ts.map +1 -0
- package/dist/stories/DashWidgetIcon.stories.d.ts +13 -0
- package/dist/stories/DashWidgetIcon.stories.d.ts.map +1 -0
- package/dist/stories/FormInfoEditor.stories.d.ts +15 -0
- package/dist/stories/FormInfoEditor.stories.d.ts.map +1 -0
- package/dist/stories/FormulaField.stories.d.ts +24 -0
- package/dist/stories/FormulaField.stories.d.ts.map +1 -0
- package/dist/stories/FormulaTag.stories.d.ts +37 -0
- package/dist/stories/FormulaTag.stories.d.ts.map +1 -0
- package/dist/stories/GenerateAnimation.stories.d.ts +17 -0
- package/dist/stories/GenerateAnimation.stories.d.ts.map +1 -0
- package/dist/stories/IconBtn.stories.d.ts +15 -0
- package/dist/stories/IconBtn.stories.d.ts.map +1 -0
- package/dist/stories/IconLib.d.ts +12 -0
- package/dist/stories/IconLib.d.ts.map +1 -0
- package/dist/stories/Icons.stories.d.ts +24 -0
- package/dist/stories/Icons.stories.d.ts.map +1 -0
- package/dist/stories/ImgMsgPart.stories.d.ts +20 -0
- package/dist/stories/ImgMsgPart.stories.d.ts.map +1 -0
- package/dist/stories/LineChecker.stories.d.ts +23 -0
- package/dist/stories/LineChecker.stories.d.ts.map +1 -0
- package/dist/stories/LinearGradientBorderBtn.stories.d.ts +22 -0
- package/dist/stories/LinearGradientBorderBtn.stories.d.ts.map +1 -0
- package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts +23 -0
- package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts.map +1 -0
- package/dist/stories/NumbersMsgPart.stories.d.ts +19 -0
- package/dist/stories/NumbersMsgPart.stories.d.ts.map +1 -0
- package/dist/stories/OptionItem.stories.d.ts +20 -0
- package/dist/stories/OptionItem.stories.d.ts.map +1 -0
- package/dist/stories/PreviewerHeader.stories.d.ts +12 -0
- package/dist/stories/PreviewerHeader.stories.d.ts.map +1 -0
- package/dist/stories/PrimaryConfirmBtn.stories.d.ts +19 -0
- package/dist/stories/PrimaryConfirmBtn.stories.d.ts.map +1 -0
- package/dist/stories/PrimaryEntryBtn.stories.d.ts +26 -0
- package/dist/stories/PrimaryEntryBtn.stories.d.ts.map +1 -0
- package/dist/stories/ScrollToBottom.stories.d.ts +15 -0
- package/dist/stories/ScrollToBottom.stories.d.ts.map +1 -0
- package/dist/stories/SplitLine.stories.d.ts +9 -0
- package/dist/stories/SplitLine.stories.d.ts.map +1 -0
- package/dist/stories/SquareChecker.stories.d.ts +26 -0
- package/dist/stories/SquareChecker.stories.d.ts.map +1 -0
- package/dist/stories/TabRadioGroup.stories.d.ts +18 -0
- package/dist/stories/TabRadioGroup.stories.d.ts.map +1 -0
- package/dist/stories/UserTextMsgBubble.stories.d.ts +14 -0
- package/dist/stories/UserTextMsgBubble.stories.d.ts.map +1 -0
- package/dist/stories/WarningMessage.stories.d.ts +16 -0
- package/dist/stories/WarningMessage.stories.d.ts.map +1 -0
- package/dist/stories/fields-design-info-table.stories.d.ts +14 -0
- package/dist/stories/fields-design-info-table.stories.d.ts.map +1 -0
- package/dist/stories/fields-generating.stories.d.ts +20 -0
- package/dist/stories/fields-generating.stories.d.ts.map +1 -0
- package/dist/stories/fields-previewer.stories.d.ts +19 -0
- package/dist/stories/fields-previewer.stories.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/chat.tsx +59 -1
- package/src/components/biz-comp/FakeBotMsg.tsx +4 -1
- package/src/components/biz-comp/chat-client.tsx +1 -1
- package/src/components/biz-comp/markdown-part.tsx +17 -4
- package/src/components/biz-comp/multi-modal-input/index.tsx +7 -5
- package/src/components/biz-comp/preview-message-wrapper.tsx +3 -1
- package/src/components/biz-comp/preview-message.tsx +15 -0
- package/src/components/bs-ui/fields-design-info-table.tsx +9 -9
- package/src/lib/utils.ts +34 -0
- package/src/plugins/report-query-plugin/index.ts +1 -1
- package/src/sdk.impl.tsx +54 -7
- package/src/store/index.ts +8 -0
|
@@ -6,6 +6,7 @@ import { UserTextMsgBubble } from '../bs-ui/user-txt-msg-bubble';
|
|
|
6
6
|
import { CollapsibleTxtMsg } from '../bs-ui/collapsible-txt-msg';
|
|
7
7
|
import { AnalysisIcon } from '../bs-ui/bs-icons';
|
|
8
8
|
import { UIDataTypes, UIMessagePart, UITools } from 'ai';
|
|
9
|
+
import { formatJSONIfValid } from '@/lib/utils';
|
|
9
10
|
|
|
10
11
|
export const MarkdownMsgpart = (
|
|
11
12
|
props: MsgPartCompProps & {
|
|
@@ -14,7 +15,7 @@ export const MarkdownMsgpart = (
|
|
|
14
15
|
collapsibleTitle?: string;
|
|
15
16
|
}
|
|
16
17
|
) => {
|
|
17
|
-
const { part: p, role, id, collapsible = true, collapsibleTitle
|
|
18
|
+
const { part: p, role, id, collapsible = true, collapsibleTitle, title, status } = props;
|
|
18
19
|
|
|
19
20
|
const part = p as UIMessagePart<UIDataTypes, UITools>;
|
|
20
21
|
|
|
@@ -30,6 +31,18 @@ export const MarkdownMsgpart = (
|
|
|
30
31
|
return <UserTextMsgBubble>{part.text}</UserTextMsgBubble>;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
const rawContent = sanitizeText(part.text);
|
|
35
|
+
let displayContent = rawContent;
|
|
36
|
+
|
|
37
|
+
if (status === 'ready') {
|
|
38
|
+
|
|
39
|
+
// 如果是合法 JSON,包装为代码块格式
|
|
40
|
+
const formattedJSON = formatJSONIfValid(rawContent);
|
|
41
|
+
if (formattedJSON) {
|
|
42
|
+
displayContent = `\`\`\`json\n${formattedJSON}\n\`\`\``;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
if (!collapsible) {
|
|
34
47
|
return (
|
|
35
48
|
<div>
|
|
@@ -42,7 +55,7 @@ export const MarkdownMsgpart = (
|
|
|
42
55
|
data-testid="message-content"
|
|
43
56
|
>
|
|
44
57
|
<article className={typoCls} style={{ fontSize: 14 }}>
|
|
45
|
-
<MemoizedMarkdown id={id} content={
|
|
58
|
+
<MemoizedMarkdown id={id} content={displayContent} />
|
|
46
59
|
</article>
|
|
47
60
|
{props.children}
|
|
48
61
|
</MessageContent>
|
|
@@ -60,9 +73,9 @@ export const MarkdownMsgpart = (
|
|
|
60
73
|
})}
|
|
61
74
|
data-testid="message-content"
|
|
62
75
|
>
|
|
63
|
-
<CollapsibleTxtMsg title={collapsibleTitle} icon={<AnalysisIcon />} defaultOpen>
|
|
76
|
+
<CollapsibleTxtMsg title={collapsibleTitle || title || '表单设计'} icon={<AnalysisIcon />} defaultOpen>
|
|
64
77
|
<article className={typoCls} style={{ fontSize: 14 }}>
|
|
65
|
-
<MemoizedMarkdown id={id} content={
|
|
78
|
+
<MemoizedMarkdown id={id} content={displayContent} />
|
|
66
79
|
</article>
|
|
67
80
|
</CollapsibleTxtMsg>
|
|
68
81
|
{props.children}
|
|
@@ -108,7 +108,7 @@ function PureMultimodalInput({
|
|
|
108
108
|
|
|
109
109
|
const placeholder = useChatPreference()?.placeholder || 'Send a message...';
|
|
110
110
|
const maxCount = useChatPreference()?.acceptAttachmentMaxCount || 5;
|
|
111
|
-
const maxSizeMb = useChatPreference()?.acceptAttachmentMaxSizeMb ||
|
|
111
|
+
const maxSizeMb = useChatPreference()?.acceptAttachmentMaxSizeMb || 50;
|
|
112
112
|
const tooltip = `上传附件(仅识别文字),最多${maxCount}个,单个文件最大${maxSizeMb}MB`;
|
|
113
113
|
|
|
114
114
|
const clearAttachmentsAndUploadQueue = useCallback(() => {
|
|
@@ -303,12 +303,14 @@ function PureMultimodalInput({
|
|
|
303
303
|
className="border border-[#e0e0e0] bg-background p-[10px] shadow-xs transition-all duration-200 focus-within:border-border hover:border-[#0265ff]"
|
|
304
304
|
onSubmit={(event) => {
|
|
305
305
|
event.preventDefault();
|
|
306
|
-
if (status !== 'ready') {
|
|
307
|
-
|
|
308
|
-
} else {
|
|
306
|
+
// if (status !== 'ready') {
|
|
307
|
+
// console.error("Please wait for the model to finish its response!");
|
|
308
|
+
// } else {
|
|
309
|
+
// submitForm();
|
|
310
|
+
// }
|
|
311
|
+
if (status === 'ready' || status === 'error') {
|
|
309
312
|
submitForm();
|
|
310
313
|
}
|
|
311
|
-
// submitForm();
|
|
312
314
|
}}
|
|
313
315
|
>
|
|
314
316
|
{(attachments.length > 0 || uploadQueue.length > 0) && (
|
|
@@ -8,6 +8,7 @@ import { IconBtn } from '../bs-ui/icon-btn';
|
|
|
8
8
|
import { CopyIcon, RefreshIcon } from '../bs-ui/bs-icons';
|
|
9
9
|
import { useChatPreference } from '@/hooks/use-chat-preference';
|
|
10
10
|
import { GenerateAnimation } from '../bs-ui/generate-animation';
|
|
11
|
+
import { useChatStore } from '@/store/context';
|
|
11
12
|
|
|
12
13
|
export const PreviewMessageWrapper = ({
|
|
13
14
|
role,
|
|
@@ -32,11 +33,12 @@ export const PreviewMessageWrapper = ({
|
|
|
32
33
|
const isUser = role === 'user';
|
|
33
34
|
|
|
34
35
|
const chatPref = useChatPreference();
|
|
36
|
+
const botInfo = useChatStore((state) => state.botInfo);
|
|
35
37
|
|
|
36
38
|
const avatarComInfo = useDefaultPluginCustomComponent('AvatarAndName');
|
|
37
39
|
const Avatar: ComponentType<{ variant?: 'default' | 'active' }> | undefined =
|
|
38
40
|
avatarComInfo?.Component;
|
|
39
|
-
const avatarJsx = Avatar ? <Avatar /> : <BotAvatarAndName name={'AI表单搭建'} />;
|
|
41
|
+
const avatarJsx = Avatar ? <Avatar /> : <BotAvatarAndName name={botInfo?.name || 'AI表单搭建'} />;
|
|
40
42
|
|
|
41
43
|
// const [isHovered, setIsHovered] = useState(false);
|
|
42
44
|
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
IsLoadingPart,
|
|
16
16
|
mergeFileParts,
|
|
17
17
|
imageUrlToBase64,
|
|
18
|
+
IsFakeMsgPart,
|
|
19
|
+
getMetaErrorMsg,
|
|
18
20
|
} from '@/lib/utils';
|
|
19
21
|
import { FakeBotMessage } from './FakeBotMsg';
|
|
20
22
|
import { WarningMessage } from '../bs-ui/warning-msg';
|
|
@@ -24,6 +26,7 @@ import { AttachmentPart } from '../bs-ui/attachment-part';
|
|
|
24
26
|
import { useChatStatus } from '@/hooks/use-frame-mode';
|
|
25
27
|
import { useEvtBus } from '@/hooks/use-evt-bus';
|
|
26
28
|
import type { FilePart } from '../bs-ui/attachment-part';
|
|
29
|
+
import { useChatStore } from '@/store/context';
|
|
27
30
|
|
|
28
31
|
const PurePreviewMessage = ({
|
|
29
32
|
message,
|
|
@@ -51,6 +54,8 @@ const PurePreviewMessage = ({
|
|
|
51
54
|
|
|
52
55
|
const chatStatus = useChatStatus();
|
|
53
56
|
|
|
57
|
+
const botInfo = useChatStore((state) => state.botInfo);
|
|
58
|
+
|
|
54
59
|
const hasFileType = message.parts?.some((p: any) => {
|
|
55
60
|
if (Array.isArray(p)) {
|
|
56
61
|
return p.some((subP) => subP?.type === 'file');
|
|
@@ -153,6 +158,15 @@ const PurePreviewMessage = ({
|
|
|
153
158
|
return <WarningMessage key={key} message={errMsg}></WarningMessage>;
|
|
154
159
|
}
|
|
155
160
|
|
|
161
|
+
if (IsFakeMsgPart(part)) {
|
|
162
|
+
const errMsg = getMetaErrorMsg(part);
|
|
163
|
+
return (
|
|
164
|
+
<FakeBotMessage key={key} headless>
|
|
165
|
+
{errMsg}
|
|
166
|
+
</FakeBotMessage>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
156
170
|
if (IsLoadingPart(part)) {
|
|
157
171
|
return (
|
|
158
172
|
<FakeBotMessage key={key} headless>
|
|
@@ -164,6 +178,7 @@ const PurePreviewMessage = ({
|
|
|
164
178
|
return (
|
|
165
179
|
<ErrorBoundary>
|
|
166
180
|
<MsgPartCom
|
|
181
|
+
title={botInfo?.name}
|
|
167
182
|
setMessages={setMessages}
|
|
168
183
|
sendMessage={sendMessage}
|
|
169
184
|
addToolOutput={addToolOutput}
|
|
@@ -50,7 +50,7 @@ function FieldRow({
|
|
|
50
50
|
return (
|
|
51
51
|
<div className="flex items-center w-full">
|
|
52
52
|
{/* 名称 */}
|
|
53
|
-
<div className={cn(cellCls, 'w-20 shrink-0 min-h-[34px]
|
|
53
|
+
<div className={cn(cellCls, 'w-20 shrink-0 min-h-[34px]')}>
|
|
54
54
|
{isSubFormChild && (
|
|
55
55
|
<span className="inline-flex items-center justify-center shrink-0 w-5 h-5 opacity-0">
|
|
56
56
|
<ChevronIcon />
|
|
@@ -59,11 +59,11 @@ function FieldRow({
|
|
|
59
59
|
<span>{field.fieldName}</span>
|
|
60
60
|
</div>
|
|
61
61
|
{/* 类型 */}
|
|
62
|
-
<div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px]
|
|
62
|
+
<div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px]')}>
|
|
63
63
|
{field.type}
|
|
64
64
|
</div>
|
|
65
65
|
{/* 必填 */}
|
|
66
|
-
<div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]
|
|
66
|
+
<div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]')}>
|
|
67
67
|
{field.required ? '是' : '否'}
|
|
68
68
|
</div>
|
|
69
69
|
{/* 说明 */}
|
|
@@ -100,11 +100,11 @@ function SubFormGroup({
|
|
|
100
100
|
<span>{parent.fieldName}</span>
|
|
101
101
|
</div>
|
|
102
102
|
{/* 类型 */}
|
|
103
|
-
<div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px]
|
|
103
|
+
<div className={cn(cellCls, 'w-[72px] shrink-0 min-h-[34px] ')}>
|
|
104
104
|
{parent.type}
|
|
105
105
|
</div>
|
|
106
106
|
{/* 必填 */}
|
|
107
|
-
<div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]
|
|
107
|
+
<div className={cn(cellCls, 'w-9 shrink-0 min-h-[34px]')}>
|
|
108
108
|
{parent.required ? '是' : '否'}
|
|
109
109
|
</div>
|
|
110
110
|
{/* 说明 */}
|
|
@@ -126,21 +126,21 @@ export function FieldsDesignInfoTable({ fields }: FieldsDesignInfoTableProps) {
|
|
|
126
126
|
<div className="flex flex-col items-start w-full bg-white rounded-[10px] overflow-hidden text-black my-[10px] border border-[#E0E0E0]">
|
|
127
127
|
{/* 表头 */}
|
|
128
128
|
<div className="flex items-center w-full shrink-0 bg-[#E5E6EB] rounded-t-[10px] border-b border-[#E0E0E0]">
|
|
129
|
-
<div className={cn(cellCls, 'w-20 shrink-0 h-[34px] font-bold
|
|
129
|
+
<div className={cn(cellCls, 'w-20 shrink-0 h-[34px] font-bold')}>
|
|
130
130
|
名称
|
|
131
131
|
</div>
|
|
132
|
-
<div className={cn(cellCls, 'w-[72px] shrink-0 h-[34px] font-bold
|
|
132
|
+
<div className={cn(cellCls, 'w-[72px] shrink-0 h-[34px] font-bold')}>
|
|
133
133
|
类型
|
|
134
134
|
</div>
|
|
135
135
|
<div
|
|
136
136
|
className={cn(
|
|
137
137
|
cellCls,
|
|
138
|
-
'w-9 shrink-0 h-[34px] font-bold
|
|
138
|
+
'w-9 shrink-0 h-[34px] font-bold justify-center'
|
|
139
139
|
)}
|
|
140
140
|
>
|
|
141
141
|
必填
|
|
142
142
|
</div>
|
|
143
|
-
<div className={cn(cellCls, 'flex-1 min-w-0 h-[34px] font-bold
|
|
143
|
+
<div className={cn(cellCls, 'flex-1 min-w-0 h-[34px] font-bold')}>
|
|
144
144
|
说明
|
|
145
145
|
</div>
|
|
146
146
|
</div>
|
package/src/lib/utils.ts
CHANGED
|
@@ -71,6 +71,11 @@ export const IsErrorPart = (part: any): boolean => {
|
|
|
71
71
|
return payload?.type === 'agent-error';
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
export const IsFakeMsgPart = (part: any): boolean => {
|
|
75
|
+
const payload = extractTextPartMeta(part);
|
|
76
|
+
return payload?.type === 'agent-fake-msg';
|
|
77
|
+
};
|
|
78
|
+
|
|
74
79
|
export const IsFilePart = (part: any): boolean => {
|
|
75
80
|
return part?.type === 'file';
|
|
76
81
|
};
|
|
@@ -117,6 +122,15 @@ export const GetPartErrMsg = (part: any): string => {
|
|
|
117
122
|
return payload?.error || '未知错误';
|
|
118
123
|
};
|
|
119
124
|
|
|
125
|
+
export const getMetaErrorMsg = (part: any): string => {
|
|
126
|
+
if (part?.errorText) {
|
|
127
|
+
return part.errorText;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const payload = extractTextPartMeta(part);
|
|
131
|
+
return payload?.error || '未知错误';
|
|
132
|
+
};
|
|
133
|
+
|
|
120
134
|
export const GetFieldJsonInfo = (part: any): IFilledField | null => {
|
|
121
135
|
const payload = extractTextPartMeta(part);
|
|
122
136
|
if (payload?.type !== 'mcp-fields-json') {
|
|
@@ -384,3 +398,23 @@ export const imageUrlToBase64 = (url: string, mediaType = 'image/png'): Promise<
|
|
|
384
398
|
img.onerror = () => resolve(url);
|
|
385
399
|
img.src = url;
|
|
386
400
|
});
|
|
401
|
+
|
|
402
|
+
export const isValidJSON = (str: string): boolean => {
|
|
403
|
+
if (!str || typeof str !== 'string') return false;
|
|
404
|
+
try {
|
|
405
|
+
JSON.parse(str);
|
|
406
|
+
return true;
|
|
407
|
+
} catch {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export const formatJSONIfValid = (str: string): string | null => {
|
|
413
|
+
try {
|
|
414
|
+
const parsed = JSON.parse(str);
|
|
415
|
+
console.log('try parse JSON: ', str);
|
|
416
|
+
return JSON.stringify(parsed, null, 2);
|
|
417
|
+
} catch {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
@@ -119,7 +119,7 @@ export class ReportQueryPlugin extends ChatAreaPlugin<IReportQueryContext> {
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
await fetch(`${ensureEndSlash(apiEndpoint)}
|
|
122
|
+
await fetch(`${ensureEndSlash(apiEndpoint)}form/conversation/clear`, {
|
|
123
123
|
method: 'POST',
|
|
124
124
|
body: JSON.stringify({ conversationId }),
|
|
125
125
|
});
|
package/src/sdk.impl.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { ChatStore, createStore, setupStoreSubscriptions } from '@/store';
|
|
|
3
3
|
import { ChatClient } from '@/components/biz-comp/chat-client';
|
|
4
4
|
import './style.css';
|
|
5
5
|
import {
|
|
6
|
+
ChatMessage,
|
|
6
7
|
DeepReadonly,
|
|
7
8
|
IChatSDK,
|
|
8
9
|
IChatSDKOption,
|
|
@@ -10,18 +11,25 @@ import {
|
|
|
10
11
|
type PluginRegistryEntry,
|
|
11
12
|
} from '@baishuyun/types';
|
|
12
13
|
import { EvtBus } from './lib/event-emitter';
|
|
14
|
+
import type { UseChatHelpers } from '@ai-sdk/react';
|
|
15
|
+
import { ChatRequestOptions, JSONValue } from 'ai';
|
|
13
16
|
|
|
14
17
|
export class ChatSDK implements IChatSDK {
|
|
15
18
|
static instances: ChatSDK[] = [];
|
|
16
19
|
|
|
17
20
|
private root: ReturnType<typeof createRoot> | undefined;
|
|
18
21
|
private readonly Store: ChatStore;
|
|
22
|
+
private chatComponentReadyResolve!: () => void;
|
|
23
|
+
private chatComponentReadyPromise: Promise<void>;
|
|
19
24
|
|
|
20
25
|
public options: IChatSDKOption;
|
|
21
26
|
|
|
22
27
|
public eventBus = new EvtBus() as IEvtBus;
|
|
23
28
|
|
|
24
29
|
constructor(options: IChatSDKOption) {
|
|
30
|
+
this.chatComponentReadyPromise = new Promise((resolve) => {
|
|
31
|
+
this.chatComponentReadyResolve = resolve;
|
|
32
|
+
});
|
|
25
33
|
this.options = options;
|
|
26
34
|
|
|
27
35
|
const renderEl = document.createElement('div');
|
|
@@ -92,10 +100,56 @@ export class ChatSDK implements IChatSDK {
|
|
|
92
100
|
return undefined;
|
|
93
101
|
}
|
|
94
102
|
|
|
103
|
+
markChatComponentReady() {
|
|
104
|
+
this.chatComponentReadyResolve();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
whenChatComponentReady(): Promise<void> {
|
|
108
|
+
return this.chatComponentReadyPromise;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_sendMessage?: UseChatHelpers<ChatMessage>['sendMessage'];
|
|
112
|
+
_appendFakeBotMessage?: (text: string) => void;
|
|
113
|
+
|
|
114
|
+
public appendBotMessage = async (text: string) => {
|
|
115
|
+
await this.whenChatComponentReady();
|
|
116
|
+
this._appendFakeBotMessage?.(text);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public sendMessage = async (text: string, customVariable: JSONValue, options: ChatRequestOptions) => {
|
|
120
|
+
await this.whenChatComponentReady();
|
|
121
|
+
|
|
122
|
+
// if is streaming, return;
|
|
123
|
+
this._sendMessage?.(
|
|
124
|
+
{ text }, // First arg: message data
|
|
125
|
+
{ // Second arg: options
|
|
126
|
+
...options,
|
|
127
|
+
body: {
|
|
128
|
+
...(options?.body || {}),
|
|
129
|
+
userVar: customVariable,
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
95
135
|
public clearChatHistory() {
|
|
96
136
|
this.Store.getState().clearMessages();
|
|
97
137
|
}
|
|
98
138
|
|
|
139
|
+
public getLastBotMsg(textOnly?: boolean): ChatMessage | string | undefined {
|
|
140
|
+
const lastBotMessage = this.Store.getState().lastBotMessage;
|
|
141
|
+
if (!lastBotMessage) return undefined;
|
|
142
|
+
|
|
143
|
+
if (textOnly) {
|
|
144
|
+
return lastBotMessage.parts
|
|
145
|
+
.filter((part) => part.type === 'text')
|
|
146
|
+
.map((part) => (part as any).text)
|
|
147
|
+
.join('');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return lastBotMessage;
|
|
151
|
+
}
|
|
152
|
+
|
|
99
153
|
public getFullStyle() {
|
|
100
154
|
return this.options.style;
|
|
101
155
|
}
|
|
@@ -121,13 +175,6 @@ export class ChatSDK implements IChatSDK {
|
|
|
121
175
|
};
|
|
122
176
|
}
|
|
123
177
|
|
|
124
|
-
public setUserId(userId: string) {
|
|
125
|
-
this.options.chatApiHeaders = {
|
|
126
|
-
...this.options.chatApiHeaders,
|
|
127
|
-
'X-User-Id': userId,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
178
|
public getChatStatus() {
|
|
132
179
|
return this.Store.getState().chatStatus;
|
|
133
180
|
}
|
package/src/store/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ChatStatus,
|
|
7
7
|
IChatSDKOption,
|
|
8
8
|
IEvtBus,
|
|
9
|
+
ChatMessage,
|
|
9
10
|
} from '@baishuyun/types';
|
|
10
11
|
import { ChatSDK } from '..';
|
|
11
12
|
import { create } from 'zustand';
|
|
@@ -24,6 +25,8 @@ export const createStore = (sdkInst: ChatSDK) => {
|
|
|
24
25
|
|
|
25
26
|
msgClearTimestamp: Date.now(),
|
|
26
27
|
globalFakeLoadingMessage: '',
|
|
28
|
+
lastBotMessage: undefined,
|
|
29
|
+
botInfo: sdkInst.options?.botInfo,
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
return create<ChatContextType>()(
|
|
@@ -104,6 +107,11 @@ export const createStore = (sdkInst: ChatSDK) => {
|
|
|
104
107
|
newButtons.set(id, { ...existing, visible });
|
|
105
108
|
return { chatEntryButtons: newButtons };
|
|
106
109
|
}),
|
|
110
|
+
|
|
111
|
+
setLastBotMessage: (message?: ChatMessage | undefined) =>
|
|
112
|
+
set(() => ({
|
|
113
|
+
lastBotMessage: message,
|
|
114
|
+
})),
|
|
107
115
|
}))
|
|
108
116
|
);
|
|
109
117
|
};
|