@agentscope-ai/chat 1.1.20 → 1.1.22
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/bin/client.js +1 -1
- package/components/AGUI/components/HelpModal/icons.tsx +68 -0
- package/components/AGUI/components/HelpModal/index.tsx +1 -0
- package/components/AGUI/components/HelpModal/modal.tsx +101 -0
- package/components/AGUI/components/chat/Button.tsx +18 -0
- package/components/AGUI/components/chat/Chat.tsx +780 -0
- package/components/AGUI/components/chat/ChatContext.tsx +248 -0
- package/components/AGUI/components/chat/CodeBlock.tsx +406 -0
- package/components/AGUI/components/chat/Header.tsx +22 -0
- package/components/AGUI/components/chat/Icons.tsx +237 -0
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +77 -0
- package/components/AGUI/components/chat/Input.tsx +24 -0
- package/components/AGUI/components/chat/Markdown.tsx +134 -0
- package/components/AGUI/components/chat/Messages.tsx +259 -0
- package/components/AGUI/components/chat/Modal.tsx +133 -0
- package/components/AGUI/components/chat/Popup.tsx +57 -0
- package/components/AGUI/components/chat/PoweredByTag.tsx +29 -0
- package/components/AGUI/components/chat/Sidebar.tsx +74 -0
- package/components/AGUI/components/chat/Suggestion.tsx +132 -0
- package/components/AGUI/components/chat/Suggestions.tsx +20 -0
- package/components/AGUI/components/chat/Textarea.tsx +61 -0
- package/components/AGUI/components/chat/Window.tsx +152 -0
- package/components/AGUI/components/chat/index.tsx +11 -0
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +69 -0
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +129 -0
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +116 -0
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +26 -0
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +51 -0
- package/components/AGUI/components/chat/messages/UserMessage.tsx +10 -0
- package/components/AGUI/components/chat/props.ts +186 -0
- package/components/AGUI/components/index.ts +1 -0
- package/components/AGUI/context/index.ts +1 -0
- package/components/AGUI/hooks/index.ts +1 -0
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +122 -0
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +29 -0
- package/components/AGUI/hooks/use-dark-mode.ts +10 -0
- package/components/AGUI/hooks/use-push-to-talk.tsx +166 -0
- package/components/AGUI/index.tsx +4 -0
- package/components/AGUI/lib/utils.test.ts +7 -0
- package/components/AGUI/lib/utils.ts +27 -0
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +1 -0
- package/components/AGUI/types/suggestions.ts +6 -0
- package/components/Accordion/Accordion.tsx +203 -0
- package/components/Accordion/BodyContent.tsx +28 -0
- package/components/Accordion/DeepThinking.tsx +91 -0
- package/components/Accordion/SoftLightTitle.tsx +13 -0
- package/components/Accordion/demo/search.tsx +39 -0
- package/components/Accordion/demo/steps.tsx +135 -0
- package/components/Accordion/demo/thinking.tsx +62 -0
- package/components/Accordion/index.en-US.md +34 -0
- package/components/Accordion/index.tsx +3 -0
- package/components/Accordion/index.zh-CN.md +34 -0
- package/components/Accordion/style.ts +208 -0
- package/components/AgentScopeRuntimeWebUI/demo/index.tsx +4 -0
- package/components/AgentScopeRuntimeWebUI/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.tsx +39 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.tsx +205 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.tsx +44 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.tsx +7 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.tsx +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.tsx +16 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.tsx +19 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.tsx +100 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/index.tsx +77 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.tsx +53 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.tsx +66 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.tsx +5 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.tsx +130 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.tsx +87 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.tsx +50 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/index.tsx +18 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/styles.tsx +59 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.tsx +76 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.tsx +111 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/styles.ts +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/styles.tsx +104 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/index.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/styles.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/sessionApi/index.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.ts +358 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IMessages.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/ISessions.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/starter/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/starter/sessionApi/index.ts +51 -0
- package/components/Attachments/DropArea.tsx +97 -0
- package/components/Attachments/FileList/AudioIcon.tsx +20 -0
- package/components/Attachments/FileList/FileListCard.tsx +270 -0
- package/components/Attachments/FileList/Progress.tsx +30 -0
- package/components/Attachments/FileList/VideoIcon.tsx +20 -0
- package/components/Attachments/FileList/index.tsx +201 -0
- package/components/Attachments/PlaceholderUploader.tsx +124 -0
- package/components/Attachments/SilentUploader.tsx +39 -0
- package/components/Attachments/context.tsx +11 -0
- package/components/Attachments/demo/basic.tsx +71 -0
- package/components/Attachments/index.en-US.md.bk +10 -0
- package/components/Attachments/index.tsx +274 -0
- package/components/Attachments/index.zh-CN.md.bk +10 -0
- package/components/Attachments/style/fileCard.ts +163 -0
- package/components/Attachments/style/index.ts +232 -0
- package/components/Attachments/util.ts +56 -0
- package/components/Bubble/Avatar.tsx +39 -0
- package/components/Bubble/Bubble.tsx +131 -0
- package/components/Bubble/BubbleList.tsx +105 -0
- package/components/Bubble/Cards.tsx +61 -0
- package/components/Bubble/Footer.tsx +55 -0
- package/components/Bubble/Interrupted.tsx +82 -0
- package/components/Bubble/ScrollToBottom.tsx +42 -0
- package/components/Bubble/Spin.tsx +13 -0
- package/components/Bubble/demo/assistantWithCode.tsx +60 -0
- package/components/Bubble/demo/assistantWithErrorStatus.tsx +102 -0
- package/components/Bubble/demo/assistantWithImage.tsx +46 -0
- package/components/Bubble/demo/assistantWithProcess.tsx +103 -0
- package/components/Bubble/demo/assistantWithSearch.tsx +69 -0
- package/components/Bubble/demo/assistantWithThinking.tsx +54 -0
- package/components/Bubble/demo/basic.tsx +55 -0
- package/components/Bubble/demo/userWithFile.tsx +27 -0
- package/components/Bubble/demo/userWithImage.tsx +26 -0
- package/components/Bubble/hooks/useDisplayData.ts +0 -0
- package/components/Bubble/hooks/useListData.ts +0 -0
- package/components/Bubble/index.en-US.md +33 -0
- package/components/Bubble/index.tsx +21 -0
- package/components/Bubble/index.zh-CN.md +33 -0
- package/components/Bubble/interface.ts +71 -0
- package/components/Bubble/loading.tsx +15 -0
- package/components/Bubble/style/avatar.ts +43 -0
- package/components/Bubble/style/footer.ts +45 -0
- package/components/Bubble/style/index.ts +192 -0
- package/components/Bubble/style/list.ts +51 -0
- package/components/ChatAnywhere/Chat/Ref.tsx +20 -0
- package/components/ChatAnywhere/Chat/index.tsx +56 -0
- package/components/ChatAnywhere/Chat/style.ts +59 -0
- package/components/ChatAnywhere/Header/index.tsx +37 -0
- package/components/ChatAnywhere/Header/style.ts +27 -0
- package/components/ChatAnywhere/Input/index.tsx +158 -0
- package/components/ChatAnywhere/Input/style.ts +14 -0
- package/components/ChatAnywhere/Layout/index.tsx +70 -0
- package/components/ChatAnywhere/Layout/style.ts +51 -0
- package/components/ChatAnywhere/SessionList/index.tsx +122 -0
- package/components/ChatAnywhere/SessionList/style.ts +53 -0
- package/components/ChatAnywhere/hooks/ChatAnywhereProvider.tsx +219 -0
- package/components/ChatAnywhere/hooks/types.ts +333 -0
- package/components/ChatAnywhere/hooks/useInput.tsx +22 -0
- package/components/ChatAnywhere/hooks/useMessages.tsx +63 -0
- package/components/ChatAnywhere/hooks/useSessionList.tsx +123 -0
- package/components/ChatAnywhere/index.tsx +49 -0
- package/components/Conversations/GroupTitle.tsx +28 -0
- package/components/Conversations/Item.tsx +189 -0
- package/components/Conversations/demo/basic.tsx +107 -0
- package/components/Conversations/demo/timeline.tsx +111 -0
- package/components/Conversations/demo/timestamp.tsx +110 -0
- package/components/Conversations/hooks/useGroupable.ts +81 -0
- package/components/Conversations/index.en-US.md +32 -0
- package/components/Conversations/index.tsx +176 -0
- package/components/Conversations/index.zh-CN.md +31 -0
- package/components/Conversations/interface.ts +69 -0
- package/components/Conversations/style.ts +153 -0
- package/components/DefaultCards/DeepThinking/index.tsx +33 -0
- package/components/DefaultCards/Files/index.tsx +69 -0
- package/components/DefaultCards/Footer/index.tsx +16 -0
- package/components/DefaultCards/Images/index.tsx +53 -0
- package/components/DefaultCards/Interrupted/index.tsx +13 -0
- package/components/DefaultCards/Text/index.tsx +13 -0
- package/components/DefaultCards/index.tsx +6 -0
- package/components/DeviceAction/actionMap.tsx +100 -0
- package/components/DeviceAction/demo/index.tsx +132 -0
- package/components/DeviceAction/index.en-US.md +19 -0
- package/components/DeviceAction/index.tsx +75 -0
- package/components/DeviceAction/index.zh-CN.md +19 -0
- package/components/Disclaimer/demo/index.tsx +4 -0
- package/components/Disclaimer/demo/withLink.tsx +4 -0
- package/components/Disclaimer/index.en-US.md +23 -0
- package/components/Disclaimer/index.tsx +42 -0
- package/components/Disclaimer/index.zh-CN.md +24 -0
- package/components/Disclaimer/style.ts +17 -0
- package/components/ImageGenerator/demo/basic.tsx +23 -0
- package/components/ImageGenerator/demo/custom.tsx +56 -0
- package/components/ImageGenerator/demo/size.tsx +15 -0
- package/components/ImageGenerator/index.en-US.md +23 -0
- package/components/ImageGenerator/index.tsx +124 -0
- package/components/ImageGenerator/index.zh-CN.md +23 -0
- package/components/ImageGenerator/style.ts +99 -0
- package/components/Markdown/Markdown/AnimationNode.tsx +89 -0
- package/components/Markdown/Markdown/Markdown.tsx +61 -0
- package/components/Markdown/Markdown/core/Parser.ts +52 -0
- package/components/Markdown/Markdown/core/Renderer.ts +121 -0
- package/components/Markdown/Markdown/core/index.ts +4 -0
- package/components/Markdown/Markdown/defaultComponents/CodeBlock.tsx +113 -0
- package/components/Markdown/Markdown/defaultComponents/DisabledImage.tsx +3 -0
- package/components/Markdown/Markdown/defaultComponents/Media.tsx +71 -0
- package/components/Markdown/Markdown/hooks/index.ts +4 -0
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +27 -0
- package/components/Markdown/Markdown/hooks/useCitationsData.tsx +36 -0
- package/components/Markdown/Markdown/hooks/useStreaming.ts +503 -0
- package/components/Markdown/Markdown/hooks/useTyping.ts +22 -0
- package/components/Markdown/Markdown/index.tsx +198 -0
- package/components/Markdown/Markdown/interface.ts +217 -0
- package/components/Markdown/Markdown/style.ts +152 -0
- package/components/Markdown/demo/basic.tsx +107 -0
- package/components/Markdown/demo/citations.tsx +47 -0
- package/components/Markdown/demo/cursor.tsx +9 -0
- package/components/Markdown/demo/latex.tsx +77 -0
- package/components/Markdown/demo/typing.tsx +82 -0
- package/components/Markdown/index.en-US.md +27 -0
- package/components/Markdown/index.ts +1 -0
- package/components/Markdown/index.zh-CN.md +28 -0
- package/components/Markdown/plugins/citations/CitationComponent.tsx +72 -0
- package/components/Markdown/plugins/citations/index.tsx +37 -0
- package/components/Markdown/plugins/cursor/Dot.tsx +106 -0
- package/components/Markdown/plugins/cursor/Underline.tsx +38 -0
- package/components/Markdown/plugins/cursor/index.tsx +59 -0
- package/components/Markdown/plugins/latex/index.ts +109 -0
- package/components/Markdown/plugins/type.ts +71 -0
- package/components/Mermaid/demo/basic.tsx +12 -0
- package/components/Mermaid/demo/class.tsx +31 -0
- package/components/Mermaid/demo/flowchart.tsx +13 -0
- package/components/Mermaid/demo/sequence.tsx +18 -0
- package/components/Mermaid/demo/state.tsx +16 -0
- package/components/Mermaid/demo/timeline.tsx +15 -0
- package/components/Mermaid/index.en-US.md +27 -0
- package/components/Mermaid/index.tsx +118 -0
- package/components/Mermaid/index.zh-CN.md +27 -0
- package/components/OperateCard/OperateCard.tsx +93 -0
- package/components/OperateCard/demo/index.tsx +35 -0
- package/components/OperateCard/demo/rag.tsx +19 -0
- package/components/OperateCard/demo/thinking.tsx +17 -0
- package/components/OperateCard/demo/todo.tsx +28 -0
- package/components/OperateCard/demo/toolCall.tsx +14 -0
- package/components/OperateCard/demo/webSearch.tsx +12 -0
- package/components/OperateCard/index.en-US.md +51 -0
- package/components/OperateCard/index.tsx +1 -0
- package/components/OperateCard/index.zh-CN.md +51 -0
- package/components/OperateCard/preset/Rag.tsx +90 -0
- package/components/OperateCard/preset/Thinking.tsx +45 -0
- package/components/OperateCard/preset/TodoList.tsx +73 -0
- package/components/OperateCard/preset/ToolCall.tsx +67 -0
- package/components/OperateCard/preset/WebSearch.tsx +65 -0
- package/components/OperateCard/preset/index.tsx +5 -0
- package/components/OperateCard/style.ts +268 -0
- package/components/Provider/CustomCardsProvider.tsx +17 -0
- package/components/Provider/GlobalProvider.tsx +17 -0
- package/components/Provider/index.tsx +33 -0
- package/components/Provider/types.ts +23 -0
- package/components/ResponsesAPI/index.tsx +0 -0
- package/components/Sender/ModeSelect/index.tsx +160 -0
- package/components/Sender/ModeSelect/styles.ts +0 -0
- package/components/Sender/SenderHeader.tsx +164 -0
- package/components/Sender/StopLoading.tsx +48 -0
- package/components/Sender/components/ActionButton.tsx +106 -0
- package/components/Sender/components/ClearButton.tsx +10 -0
- package/components/Sender/components/LoadingButton.tsx +26 -0
- package/components/Sender/components/SendButton.tsx +22 -0
- package/components/Sender/components/SpeechButton/RecordingIcon.tsx +68 -0
- package/components/Sender/components/SpeechButton/index.tsx +30 -0
- package/components/Sender/demo/asr.tsx +7 -0
- package/components/Sender/demo/basic.tsx +7 -0
- package/components/Sender/demo/loading.tsx +5 -0
- package/components/Sender/demo/moreMode.tsx +45 -0
- package/components/Sender/demo/morePrefixAction.tsx +40 -0
- package/components/Sender/demo/withFile.tsx +54 -0
- package/components/Sender/demo/withImage.tsx +52 -0
- package/components/Sender/index.en-US.md +29 -0
- package/components/Sender/index.tsx +491 -0
- package/components/Sender/index.zh-CN.md +30 -0
- package/components/Sender/style/index.ts +150 -0
- package/components/Sender/useSpeech.ts +133 -0
- package/components/StatusCard/demo/index.tsx +32 -0
- package/components/StatusCard/index.en-US.md +30 -0
- package/components/StatusCard/index.tsx +162 -0
- package/components/StatusCard/index.zh-CN.md +27 -0
- package/components/StatusCard/style.ts +119 -0
- package/components/Stream/index.ts +203 -0
- package/components/Util/hooks/use-proxy-imperative-handle.ts +25 -0
- package/components/Util/sleep.ts +3 -0
- package/components/Util/type.ts +1 -0
- package/components/Util/warning.ts +118 -0
- package/components/Version/index.ts +3 -0
- package/components/Voice/Recorder.tsx +3 -0
- package/components/Voice/demo/index.tsx +0 -0
- package/components/Voice/index.en-US.md +8 -0
- package/components/Voice/index.tsx +0 -0
- package/components/Voice/index.zh-CN.md +9 -0
- package/components/Welcome/demo/EyeFollower.tsx +161 -0
- package/components/Welcome/demo/demo0.tsx +14 -0
- package/components/Welcome/demo/demo1.tsx +16 -0
- package/components/Welcome/demo/demo2.tsx +30 -0
- package/components/Welcome/demo/demo3.tsx +16 -0
- package/components/Welcome/index.en-US.md +28 -0
- package/components/Welcome/index.tsx +72 -0
- package/components/Welcome/index.zh-CN.md +28 -0
- package/components/index.ts +88 -0
- package/components/overview.en-US.md +10 -0
- package/components/overview.zh-CN.md +10 -0
- package/lib/AgentScopeRuntimeWebUI/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/index.js +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.d.ts +9 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.js +33 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.d.ts +7 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.js +188 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.d.ts +29 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.js +35 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.d.ts +6 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.js +49 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.js +70 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.d.ts +14 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.js +143 -0
- package/package.json +3 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Follow code is copy from `antd/components/upload/utils.ts`:
|
|
2
|
+
|
|
3
|
+
export const isImageFileType = (type: string): boolean => type.indexOf('image/') === 0;
|
|
4
|
+
|
|
5
|
+
const MEASURE_SIZE = 200;
|
|
6
|
+
|
|
7
|
+
export function previewImage(file: File | Blob): Promise<string> {
|
|
8
|
+
return new Promise<string>((resolve) => {
|
|
9
|
+
if (!file || !file.type || !isImageFileType(file.type)) {
|
|
10
|
+
resolve('');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const img = new Image();
|
|
15
|
+
img.onload = () => {
|
|
16
|
+
const { width, height } = img;
|
|
17
|
+
|
|
18
|
+
const ratio = width / height;
|
|
19
|
+
const MEASURE_SIZE_WIDTH = ratio > 1 ? MEASURE_SIZE : MEASURE_SIZE * ratio;
|
|
20
|
+
const MEASURE_SIZE_HEIGHT = ratio > 1 ? MEASURE_SIZE / ratio : MEASURE_SIZE;
|
|
21
|
+
|
|
22
|
+
const canvas = document.createElement('canvas');
|
|
23
|
+
canvas.width = MEASURE_SIZE_WIDTH;
|
|
24
|
+
canvas.height = MEASURE_SIZE_HEIGHT;
|
|
25
|
+
canvas.style.cssText = `position: fixed; left: 0; top: 0; width: ${MEASURE_SIZE_WIDTH}px; height: ${MEASURE_SIZE_HEIGHT}px; z-index: 9999; display: none;`;
|
|
26
|
+
document.body.appendChild<HTMLCanvasElement>(canvas);
|
|
27
|
+
const ctx = canvas.getContext('2d');
|
|
28
|
+
|
|
29
|
+
ctx!.drawImage(img, 0, 0, MEASURE_SIZE_WIDTH, MEASURE_SIZE_HEIGHT);
|
|
30
|
+
const dataURL = canvas.toDataURL();
|
|
31
|
+
document.body.removeChild(canvas);
|
|
32
|
+
window.URL.revokeObjectURL(img.src);
|
|
33
|
+
resolve(dataURL);
|
|
34
|
+
};
|
|
35
|
+
img.crossOrigin = 'anonymous';
|
|
36
|
+
if (file.type.startsWith('image/svg+xml')) {
|
|
37
|
+
const reader = new FileReader();
|
|
38
|
+
reader.onload = () => {
|
|
39
|
+
if (reader.result && typeof reader.result === 'string') {
|
|
40
|
+
img.src = reader.result;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
reader.readAsDataURL(file);
|
|
44
|
+
} else if (file.type.startsWith('image/gif')) {
|
|
45
|
+
const reader = new FileReader();
|
|
46
|
+
reader.onload = () => {
|
|
47
|
+
if (reader.result) {
|
|
48
|
+
resolve(reader.result as string);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
reader.readAsDataURL(file);
|
|
52
|
+
} else {
|
|
53
|
+
img.src = window.URL.createObjectURL(file);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Avatar as AAvatar } from 'antd';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { BubbleProps } from './interface';
|
|
5
|
+
|
|
6
|
+
interface AvatarProps
|
|
7
|
+
extends Pick<BubbleProps, 'avatar' | 'msgStatus' | 'prefixCls'> {
|
|
8
|
+
isAssistant?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Avatar: React.FC<AvatarProps> = (props) => {
|
|
14
|
+
const { avatar, msgStatus, isAssistant, prefixCls, className, style } = props;
|
|
15
|
+
|
|
16
|
+
const avatarNode = React.isValidElement(avatar) ? (
|
|
17
|
+
avatar
|
|
18
|
+
) : (
|
|
19
|
+
<AAvatar {...avatar} />
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
className={classnames(
|
|
25
|
+
`${prefixCls}-avatar`,
|
|
26
|
+
{
|
|
27
|
+
[`${prefixCls}-avatar-loading`]:
|
|
28
|
+
isAssistant && msgStatus === 'generating',
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
style={style}
|
|
33
|
+
>
|
|
34
|
+
{avatarNode}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Avatar;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import classnames from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BubbleProps } from './interface';
|
|
4
|
+
import Style from './style/index';
|
|
5
|
+
import { Markdown, useProviderContext } from '@agentscope-ai/chat';
|
|
6
|
+
import Cards from './Cards';
|
|
7
|
+
import Spin from './Spin';
|
|
8
|
+
import Avatar from './Avatar';
|
|
9
|
+
|
|
10
|
+
export interface BubbleRef {
|
|
11
|
+
/**
|
|
12
|
+
* @description 气泡组件的原生DOM元素引用,用于直接操作DOM
|
|
13
|
+
* @descriptionEn Native DOM element reference of the bubble component for direct DOM manipulation
|
|
14
|
+
*/
|
|
15
|
+
nativeElement: HTMLElement;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BubbleContextProps {
|
|
19
|
+
/**
|
|
20
|
+
* @description 气泡内容更新时的回调函数,用于触发重新渲染
|
|
21
|
+
* @descriptionEn Callback function when bubble content updates for triggering re-render
|
|
22
|
+
*/
|
|
23
|
+
onUpdate?: VoidFunction;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const BubbleContext = React.createContext<BubbleContextProps>({});
|
|
27
|
+
|
|
28
|
+
const Bubble: React.FC<BubbleProps> = (props) => {
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
isLast,
|
|
32
|
+
className,
|
|
33
|
+
rootClassName,
|
|
34
|
+
style,
|
|
35
|
+
classNames = {},
|
|
36
|
+
styles = {},
|
|
37
|
+
avatar,
|
|
38
|
+
content = '',
|
|
39
|
+
cards,
|
|
40
|
+
msgStatus,
|
|
41
|
+
id,
|
|
42
|
+
role,
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
variant,
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
const placement = {
|
|
48
|
+
'assistant': 'start',
|
|
49
|
+
'user': 'end',
|
|
50
|
+
}[role] || 'start'
|
|
51
|
+
const { getPrefixCls } = useProviderContext();
|
|
52
|
+
const prefixCls = getPrefixCls('bubble');
|
|
53
|
+
|
|
54
|
+
const mergedCls = classnames(
|
|
55
|
+
prefixCls,
|
|
56
|
+
rootClassName,
|
|
57
|
+
className,
|
|
58
|
+
`${prefixCls}-${placement}`,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
let contentNode;
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const isEmpty = !content?.length && !cards?.length;
|
|
64
|
+
if (props.msgStatus === 'generating' && (isEmpty)) {
|
|
65
|
+
contentNode = <Spin />
|
|
66
|
+
} else {
|
|
67
|
+
contentNode = content ? (
|
|
68
|
+
<Markdown
|
|
69
|
+
content={content as string}
|
|
70
|
+
cursor={props.msgStatus === 'generating'}
|
|
71
|
+
/>
|
|
72
|
+
) : null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const isAssistant = placement === 'assistant' || placement === 'start';
|
|
76
|
+
const variantClassname = `${prefixCls}-content-${variant || (isAssistant ? 'borderless' : 'filled')}`;
|
|
77
|
+
let fullContent: React.ReactNode = (
|
|
78
|
+
<div
|
|
79
|
+
style={!isAssistant && contentNode ? { flexDirection: 'column-reverse' } : {}}
|
|
80
|
+
className={`${prefixCls}-content-wrapper`}
|
|
81
|
+
>
|
|
82
|
+
<Cards cards={cards} id={id} isLast={isLast} className={classnames(
|
|
83
|
+
`${prefixCls}-content`,
|
|
84
|
+
`${prefixCls}-content-wrapper-card`,
|
|
85
|
+
variantClassname,
|
|
86
|
+
classNames.content,
|
|
87
|
+
)} />
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
contentNode && <div
|
|
91
|
+
style={{
|
|
92
|
+
...styles.content,
|
|
93
|
+
}}
|
|
94
|
+
className={classnames(
|
|
95
|
+
`${prefixCls}-content`,
|
|
96
|
+
`${prefixCls}-content-wrapper-card`,
|
|
97
|
+
variantClassname,
|
|
98
|
+
classNames.content,
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
{contentNode}
|
|
102
|
+
</div>
|
|
103
|
+
}
|
|
104
|
+
</div>);
|
|
105
|
+
|
|
106
|
+
return <>
|
|
107
|
+
<Style />
|
|
108
|
+
<div
|
|
109
|
+
style={style}
|
|
110
|
+
className={mergedCls}
|
|
111
|
+
id={id}
|
|
112
|
+
data-role={role}
|
|
113
|
+
>
|
|
114
|
+
{
|
|
115
|
+
avatar && <Avatar
|
|
116
|
+
avatar={avatar}
|
|
117
|
+
msgStatus={msgStatus}
|
|
118
|
+
isAssistant={isAssistant}
|
|
119
|
+
prefixCls={prefixCls}
|
|
120
|
+
className={classNames.avatar}
|
|
121
|
+
style={styles.avatar}
|
|
122
|
+
/>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
{fullContent}
|
|
126
|
+
</div>
|
|
127
|
+
</>
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
export default React.memo(Bubble);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import Bubble from './Bubble';
|
|
2
|
+
import type { BubbleProps } from './interface';
|
|
3
|
+
import ScrollToBottom from './ScrollToBottom';
|
|
4
|
+
import { StickToBottom } from 'use-stick-to-bottom';
|
|
5
|
+
import Style from './style/list';
|
|
6
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
7
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import cls from 'classnames';
|
|
9
|
+
import { useMount } from 'ahooks';
|
|
10
|
+
|
|
11
|
+
export interface BubbleListRef {
|
|
12
|
+
/**
|
|
13
|
+
* @description 滚动到列表底部的方法,用于自动滚动到最新消息
|
|
14
|
+
* @descriptionEn Method to scroll to the bottom of the list for auto-scrolling to latest messages
|
|
15
|
+
*/
|
|
16
|
+
scrollToBottom(): void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type BubbleDataType = BubbleProps & {
|
|
20
|
+
key?: string | number;
|
|
21
|
+
role?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export interface BubbleListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
27
|
+
/**
|
|
28
|
+
* @description 气泡消息数据数组,用于渲染消息列表
|
|
29
|
+
* @descriptionEn Bubble message data array for rendering message list
|
|
30
|
+
*/
|
|
31
|
+
items?: BubbleDataType[];
|
|
32
|
+
/**
|
|
33
|
+
* @description 自定义子元素,用于扩展组件功能或自定义渲染
|
|
34
|
+
* @descriptionEn Custom child elements for extending component functionality or custom rendering
|
|
35
|
+
*/
|
|
36
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
37
|
+
/**
|
|
38
|
+
* @description 是否启用平滑滚动效果,影响滚动动画的流畅度
|
|
39
|
+
* @descriptionEn Whether to enable smooth scrolling effect, affects scrolling animation smoothness
|
|
40
|
+
*/
|
|
41
|
+
smooth?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @description 语义化CSS类名,用于为不同区域添加自定义类名
|
|
44
|
+
* @descriptionEn Semantic CSS class names for adding custom classes to different areas
|
|
45
|
+
*/
|
|
46
|
+
classNames?: {
|
|
47
|
+
wrapper?: string;
|
|
48
|
+
list?: string;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const BubbleList: React.ForwardRefRenderFunction<BubbleListRef, BubbleListProps> = (props, ref) => {
|
|
54
|
+
const {
|
|
55
|
+
items = [],
|
|
56
|
+
smooth = true,
|
|
57
|
+
} = props;
|
|
58
|
+
|
|
59
|
+
const [initial, setInitial] = useState(false);
|
|
60
|
+
const scrollToBottomRef = React.useRef();
|
|
61
|
+
const { getPrefixCls } = useProviderContext();
|
|
62
|
+
const prefixCls = getPrefixCls('bubble-list');
|
|
63
|
+
|
|
64
|
+
React.useImperativeHandle(ref, () => ({
|
|
65
|
+
scrollToBottom: () => {
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
scrollToBottomRef.current.scrollToBottom()
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
useMount(() => {
|
|
72
|
+
setInitial(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const resize = initial ? (smooth ? 'smooth' : 'instant') : 'instant';
|
|
76
|
+
|
|
77
|
+
return <>
|
|
78
|
+
<Style />
|
|
79
|
+
<StickToBottom
|
|
80
|
+
id={props.id}
|
|
81
|
+
className={cls(`${prefixCls}-wrapper`, props.classNames?.wrapper)}
|
|
82
|
+
resize={resize}
|
|
83
|
+
initial="instant"
|
|
84
|
+
style={props.style}
|
|
85
|
+
>
|
|
86
|
+
<StickToBottom.Content className={cls(`${prefixCls}`, props.classNames?.list)}>
|
|
87
|
+
{props.children ? props.children : items.map(({ key, ...bubble }, index) => {
|
|
88
|
+
const isLast = index === items.length - 1;
|
|
89
|
+
return (
|
|
90
|
+
<Bubble
|
|
91
|
+
{...bubble}
|
|
92
|
+
isLast={isLast}
|
|
93
|
+
key={bubble.id || key}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
})}
|
|
97
|
+
</StickToBottom.Content>
|
|
98
|
+
<ScrollToBottom ref={scrollToBottomRef}></ScrollToBottom>
|
|
99
|
+
</StickToBottom>
|
|
100
|
+
</>;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const ForwardBubbleList = React.forwardRef(BubbleList);
|
|
104
|
+
|
|
105
|
+
export default ForwardBubbleList;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { useChatAnywhere, useCustomCardsContext } from '@agentscope-ai/chat';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
interface ICardProps {
|
|
6
|
+
code: string,
|
|
7
|
+
component?: React.FC,
|
|
8
|
+
data?: string | any,
|
|
9
|
+
index?: number,
|
|
10
|
+
id?: string,
|
|
11
|
+
isLast?: boolean,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Card = React.memo(function (props: ICardProps) {
|
|
15
|
+
const cardConfig = useCustomCardsContext();
|
|
16
|
+
const onInput = useChatAnywhere(v => v.onInput);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const Component = useMemo(() => {
|
|
20
|
+
if (props.component) return props.component;
|
|
21
|
+
const cardConfigMap = cardConfig;
|
|
22
|
+
|
|
23
|
+
return cardConfigMap?.[props.code] || (() => `${props.code} not found`);
|
|
24
|
+
}, [])
|
|
25
|
+
|
|
26
|
+
if (typeof Component === 'function') {
|
|
27
|
+
const { component, ...rest } = props;
|
|
28
|
+
return <Component {...rest} context={{ onInput }} />
|
|
29
|
+
} else {
|
|
30
|
+
return Component;
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export default function Cards(props: {
|
|
35
|
+
cards: ICardProps[],
|
|
36
|
+
id: string,
|
|
37
|
+
className?: string,
|
|
38
|
+
isLast?: boolean,
|
|
39
|
+
}) {
|
|
40
|
+
const { cards } = props;
|
|
41
|
+
if (!cards?.length) return null;
|
|
42
|
+
return cards.map((card, index) => {
|
|
43
|
+
const cardComp = <Card
|
|
44
|
+
key={card?.id || index + card.code}
|
|
45
|
+
index={index}
|
|
46
|
+
id={props.id}
|
|
47
|
+
isLast={props.isLast}
|
|
48
|
+
{...card}
|
|
49
|
+
/>;
|
|
50
|
+
|
|
51
|
+
if (card.code === 'Text') return <div className={props.className} key={index}>{cardComp}</div>
|
|
52
|
+
return cardComp;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createCard(code: string, data: any) {
|
|
57
|
+
return {
|
|
58
|
+
code,
|
|
59
|
+
data
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
3
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
4
|
+
import Style from './style/footer';
|
|
5
|
+
|
|
6
|
+
export default function Footer(props: {
|
|
7
|
+
left?: React.ReactElement;
|
|
8
|
+
right?: React.ReactElement;
|
|
9
|
+
|
|
10
|
+
}) {
|
|
11
|
+
const { getPrefixCls } = useProviderContext();
|
|
12
|
+
const prefixCls = getPrefixCls('bubble-footer');
|
|
13
|
+
const { left, right } = props;
|
|
14
|
+
if ((left && !left.type) || (right && !right.type)) return null;
|
|
15
|
+
|
|
16
|
+
return <>
|
|
17
|
+
<Style />
|
|
18
|
+
<div className={prefixCls}>
|
|
19
|
+
<div className={`${prefixCls}-left`}>{props.left}</div>
|
|
20
|
+
<div className={`${prefixCls}-right`}>{props.right}</div>
|
|
21
|
+
</div>
|
|
22
|
+
</>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export function FooterActions(props: {
|
|
27
|
+
data: { icon: string | ReactElement, label?: string, onClick: () => void }[]
|
|
28
|
+
}) {
|
|
29
|
+
const { getPrefixCls } = useProviderContext();
|
|
30
|
+
const prefixCls = getPrefixCls('bubble-footer-actions');
|
|
31
|
+
|
|
32
|
+
return <div className={prefixCls}>
|
|
33
|
+
{props.data.map((item, index) => {
|
|
34
|
+
return <IconButton bordered={false} key={index} icon={item.icon} size='small' onClick={item.onClick}></IconButton>
|
|
35
|
+
})}
|
|
36
|
+
</div>;
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export function FooterCount(props: {
|
|
42
|
+
data: [string | number, string | number][]
|
|
43
|
+
}) {
|
|
44
|
+
const { getPrefixCls } = useProviderContext();
|
|
45
|
+
const prefixCls = getPrefixCls('bubble-footer-count');
|
|
46
|
+
|
|
47
|
+
return <div className={prefixCls}>
|
|
48
|
+
{props.data.map(item => {
|
|
49
|
+
return <div className={`${prefixCls}-item`} key={item[0]}>{item[0]}:{item[1]}</div>
|
|
50
|
+
})}
|
|
51
|
+
</div>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Footer.Actions = FooterActions;
|
|
55
|
+
Footer.Count = FooterCount;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
3
|
+
import { SparkErrorCircleFill, SparkStopCircleLine } from '@agentscope-ai/icons';
|
|
4
|
+
|
|
5
|
+
const Style = createGlobalStyle`
|
|
6
|
+
.${p => p.theme.prefixCls}-interrupted {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
font-weight: 500;
|
|
11
|
+
line-height: 18px;
|
|
12
|
+
letter-spacing: 0px;
|
|
13
|
+
background-color: ${p => p.theme.colorFillSecondary};
|
|
14
|
+
padding: 10px 12px;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
.${p => p.theme.prefixCls}-interrupted-desc {
|
|
20
|
+
font-weight: normal;
|
|
21
|
+
word-break: break-word;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.${p => p.theme.prefixCls}-interrupted-header {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 4px;
|
|
28
|
+
color: ${p => p.theme.colorText};
|
|
29
|
+
|
|
30
|
+
&-icon-wrapper {
|
|
31
|
+
width: 16px;
|
|
32
|
+
height: 16px;
|
|
33
|
+
flex: 0 0 16px;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-error {
|
|
40
|
+
color: ${p => p.theme.colorError};
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&-interrupted {
|
|
45
|
+
font-size: 16px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
interface IProps {
|
|
53
|
+
|
|
54
|
+
title?: string;
|
|
55
|
+
type?: 'error' | 'interrupted';
|
|
56
|
+
desc?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export default function Interrupted(props: IProps) {
|
|
61
|
+
const { title = 'Answers have stopped', type = 'interrupted', desc } = props;
|
|
62
|
+
const { getPrefixCls } = useProviderContext();
|
|
63
|
+
const prefixCls = getPrefixCls('interrupted');
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
return <>
|
|
67
|
+
<Style />
|
|
68
|
+
<div className={`${prefixCls}`}>
|
|
69
|
+
<div className={`${prefixCls}-header`}>
|
|
70
|
+
<div className={`${prefixCls}-icon-wrapper`}>
|
|
71
|
+
{
|
|
72
|
+
type === 'interrupted' ? <SparkStopCircleLine className={`${prefixCls}-header-interrupted`} /> : <SparkErrorCircleFill className={`${prefixCls}-header-error`} />
|
|
73
|
+
}
|
|
74
|
+
</div>
|
|
75
|
+
<span>{title}</span>
|
|
76
|
+
</div>
|
|
77
|
+
{
|
|
78
|
+
desc && <div className={`${prefixCls}-desc`}>{desc}</div>
|
|
79
|
+
}
|
|
80
|
+
</div>
|
|
81
|
+
</>
|
|
82
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
import { ScrollToBottomOptions, useStickToBottomContext } from 'use-stick-to-bottom';
|
|
5
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
6
|
+
import { SparkDownArrowLine } from '@agentscope-ai/icons';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const ScrollToBottomButton: React.ForwardRefRenderFunction<{
|
|
10
|
+
scrollToBottom(options?: ScrollToBottomOptions): void
|
|
11
|
+
}> = (_, ref) => {
|
|
12
|
+
const { getPrefixCls } = useProviderContext();
|
|
13
|
+
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
14
|
+
|
|
15
|
+
React.useImperativeHandle(ref, () => ({
|
|
16
|
+
scrollToBottom: (options?: ScrollToBottomOptions) => {
|
|
17
|
+
options = options || {
|
|
18
|
+
animation: 'instant'
|
|
19
|
+
}
|
|
20
|
+
scrollToBottom(options)
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const prefixCls = getPrefixCls('bubble-list-scroll-to-bottom');
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={cls(prefixCls, `${prefixCls}-${!isAtBottom ? 'show' : 'hide'}`)}>
|
|
29
|
+
|
|
30
|
+
<IconButton
|
|
31
|
+
icon={<SparkDownArrowLine />}
|
|
32
|
+
shape='circle'
|
|
33
|
+
onClick={() => scrollToBottom({
|
|
34
|
+
animation: 'instant'
|
|
35
|
+
})}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default React.forwardRef(ScrollToBottomButton);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useProviderContext } from "@agentscope-ai/chat";
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
const { getPrefixCls } = useProviderContext();
|
|
5
|
+
const prefixCls = getPrefixCls('bubble-loading');
|
|
6
|
+
|
|
7
|
+
return <div className={prefixCls} >
|
|
8
|
+
<div className={`${prefixCls}-dot1`} />
|
|
9
|
+
<div className={`${prefixCls}-dot2`} />
|
|
10
|
+
<div className={`${prefixCls}-dot3`} />
|
|
11
|
+
<div className={`${prefixCls}-text`}>-</div>
|
|
12
|
+
</div>
|
|
13
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Bubble, DefaultCards } from "@agentscope-ai/chat";
|
|
2
|
+
import { SparkCopyLine, SparkThumbsUpLine, SparkThumbsDownLine, SparkReplaceLine } from '@agentscope-ai/icons';
|
|
3
|
+
|
|
4
|
+
export default function () {
|
|
5
|
+
return <Bubble cards={[
|
|
6
|
+
{
|
|
7
|
+
code: 'Text',
|
|
8
|
+
data: {
|
|
9
|
+
content: `City Pop, short for City Pop, is a genre of music that originated in Japan during the late 1970s and early 1980s. It blends elements of jazz, folk, easy listening, and AOR (Adult Oriented Rock) with a distinctly urban feel. The term "City Pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of Tokyo and other major Japanese cities during this period.
|
|
10
|
+
City Pop is characterized by its smooth melodies, mellow rhythms, and often dreamy or introspective lyrics. Common themes include city life, summer vibes, nature, and romantic encounters. The music is frequently associated with a particular aesthetic that reflects the fashion, design, and cultural trends of urban Japan in the 1980s.
|
|
11
|
+
Some notable City Pop artists include Mariya Takeuchi, known for her iconic song " Plastic Love," and Joe Hisaishi, a composer famous for his work on Studio Ghibli films, though he is not strictly considered a City Pop artist.
|
|
12
|
+
Today, City Pop has experienced a resurgence in popularity, particularly among younger generations who appreciate its unique sound and the nostalgic value it holds.
|
|
13
|
+
|
|
14
|
+
\`\`\`javascript
|
|
15
|
+
function bubbleSort(arr) {
|
|
16
|
+
const n = arr.length;
|
|
17
|
+
for (let i = 0; i < n - 1; i++) {
|
|
18
|
+
for (let j = 0; j < n - i - 1; j++) {
|
|
19
|
+
if (arr[j] > arr[j + 1]) {
|
|
20
|
+
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return arr;
|
|
25
|
+
}
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
City Pop, short for City Pop, is a genre of music that originated in Japan during the late 1970s and early 1980s. It blends elements of jazz, folk, easy listening, and AOR (Adult Oriented Rock) with a distinctly urban feel. The term "City Pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of Tokyo and other major Japanese cities during this period.`
|
|
29
|
+
},
|
|
30
|
+
}, {
|
|
31
|
+
code: 'Footer',
|
|
32
|
+
data: {
|
|
33
|
+
left: <DefaultCards.FooterActions data={[
|
|
34
|
+
{
|
|
35
|
+
icon: <SparkCopyLine />, onClick: () => {
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
icon: <SparkThumbsUpLine />, onClick: () => {
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
icon: <SparkThumbsDownLine />, onClick: () => {
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
icon: <SparkReplaceLine />, onClick: () => {
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
]} />,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
]}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
role="assistant"></Bubble>
|
|
60
|
+
}
|