@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,48 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
const StopLoadingIcon = memo((props: { className?: string }) => {
|
|
4
|
+
const { className } = props;
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<svg
|
|
8
|
+
color="currentColor"
|
|
9
|
+
viewBox="0 0 1000 1000"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
12
|
+
className={className}
|
|
13
|
+
>
|
|
14
|
+
<title>Stop Loading</title>
|
|
15
|
+
<rect fill="currentColor" height="250" rx="24" ry="24" width="250" x="375" y="375" />
|
|
16
|
+
|
|
17
|
+
{/* <circle
|
|
18
|
+
cx="500"
|
|
19
|
+
cy="500"
|
|
20
|
+
fill="none"
|
|
21
|
+
r="450"
|
|
22
|
+
stroke="currentColor"
|
|
23
|
+
strokeWidth="100"
|
|
24
|
+
opacity="0.45"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<circle
|
|
28
|
+
cx="500"
|
|
29
|
+
cy="500"
|
|
30
|
+
fill="none"
|
|
31
|
+
r="450"
|
|
32
|
+
stroke="currentColor"
|
|
33
|
+
strokeWidth="100"
|
|
34
|
+
strokeDasharray="600 9999999"
|
|
35
|
+
>
|
|
36
|
+
<animateTransform
|
|
37
|
+
attributeName="transform"
|
|
38
|
+
dur="1s"
|
|
39
|
+
from="0 500 500"
|
|
40
|
+
repeatCount="indefinite"
|
|
41
|
+
to="360 500 500"
|
|
42
|
+
type="rotate"
|
|
43
|
+
/>
|
|
44
|
+
</circle> */}
|
|
45
|
+
</svg>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
export default StopLoadingIcon;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Button, IconButton, type ButtonProps } from '@agentscope-ai/design';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
export interface ActionButtonContextProps {
|
|
6
|
+
/**
|
|
7
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
8
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
9
|
+
*/
|
|
10
|
+
prefixCls: string;
|
|
11
|
+
/**
|
|
12
|
+
* @description 发送消息的回调函数
|
|
13
|
+
* @descriptionEn Callback function for sending messages
|
|
14
|
+
*/
|
|
15
|
+
onSend?: VoidFunction;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否禁用发送按钮
|
|
18
|
+
* @descriptionEn Whether to disable the send button
|
|
19
|
+
*/
|
|
20
|
+
onSendDisabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @description 清空输入的回调函数
|
|
23
|
+
* @descriptionEn Callback function for clearing input
|
|
24
|
+
*/
|
|
25
|
+
onClear?: VoidFunction;
|
|
26
|
+
/**
|
|
27
|
+
* @description 是否禁用清空按钮
|
|
28
|
+
* @descriptionEn Whether to disable the clear button
|
|
29
|
+
*/
|
|
30
|
+
onClearDisabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* @description 取消操作的回调函数
|
|
33
|
+
* @descriptionEn Callback function for canceling operations
|
|
34
|
+
*/
|
|
35
|
+
onCancel?: VoidFunction;
|
|
36
|
+
/**
|
|
37
|
+
* @description 是否禁用取消按钮
|
|
38
|
+
* @descriptionEn Whether to disable the cancel button
|
|
39
|
+
*/
|
|
40
|
+
onCancelDisabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @description 语音输入的回调函数
|
|
43
|
+
* @descriptionEn Callback function for voice input
|
|
44
|
+
*/
|
|
45
|
+
onSpeech?: VoidFunction;
|
|
46
|
+
/**
|
|
47
|
+
* @description 是否禁用语音按钮
|
|
48
|
+
* @descriptionEn Whether to disable the speech button
|
|
49
|
+
*/
|
|
50
|
+
onSpeechDisabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* @description 是否正在录音,影响语音按钮的显示状态
|
|
53
|
+
* @descriptionEn Whether currently recording, affects the display state of the speech button
|
|
54
|
+
*/
|
|
55
|
+
speechRecording?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* @description 是否禁用所有操作按钮
|
|
58
|
+
* @descriptionEn Whether to disable all action buttons
|
|
59
|
+
*/
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const ActionButtonContext = React.createContext<ActionButtonContextProps>(null!);
|
|
64
|
+
|
|
65
|
+
export interface ActionButtonProps {
|
|
66
|
+
/**
|
|
67
|
+
* @description 按钮的操作类型,决定按钮的行为和样式
|
|
68
|
+
* @descriptionEn Action type of the button, determines button behavior and style
|
|
69
|
+
*/
|
|
70
|
+
action: 'onSend' | 'onClear' | 'onCancel' | 'onSpeech';
|
|
71
|
+
onClick?: (e) => void;
|
|
72
|
+
className?: string;
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function ActionButton(props: ActionButtonProps) {
|
|
77
|
+
const { className, action, onClick: outClick, ...restProps } = props;
|
|
78
|
+
const context = React.useContext(ActionButtonContext);
|
|
79
|
+
const { prefixCls, disabled: rootDisabled } = context;
|
|
80
|
+
|
|
81
|
+
const onClick = context[action];
|
|
82
|
+
const mergedDisabled = rootDisabled ?? restProps.disabled ?? context[`${action}Disabled`];
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<IconButton
|
|
86
|
+
bordered={false}
|
|
87
|
+
disabled={mergedDisabled}
|
|
88
|
+
{...restProps}
|
|
89
|
+
onClick={(e) => {
|
|
90
|
+
if (!mergedDisabled) {
|
|
91
|
+
if (onClick) {
|
|
92
|
+
onClick();
|
|
93
|
+
}
|
|
94
|
+
if (outClick) {
|
|
95
|
+
outClick(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}}
|
|
99
|
+
className={classNames(prefixCls, className, {
|
|
100
|
+
[`${prefixCls}-disabled`]: mergedDisabled,
|
|
101
|
+
})}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default React.forwardRef(ActionButton);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClearOutlined } from '@ant-design/icons';
|
|
2
|
+
import type { ButtonProps } from 'antd';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import ActionButton from './ActionButton';
|
|
5
|
+
|
|
6
|
+
function ClearButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
|
|
7
|
+
return <ActionButton icon={<ClearOutlined />} {...props} action="onClear" ref={ref} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default React.forwardRef(ClearButton);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ButtonProps } from 'antd';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import StopLoadingIcon from '../StopLoading';
|
|
5
|
+
import ActionButton, { ActionButtonContext } from './ActionButton';
|
|
6
|
+
|
|
7
|
+
function LoadingButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
|
|
8
|
+
const { prefixCls } = React.useContext(ActionButtonContext);
|
|
9
|
+
const { className } = props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ActionButton
|
|
13
|
+
icon={<StopLoadingIcon className={`${prefixCls}-loading-icon`} />}
|
|
14
|
+
type="primary"
|
|
15
|
+
variant="text"
|
|
16
|
+
{...props}
|
|
17
|
+
className={classNames(className, `${prefixCls}-loading-button`)}
|
|
18
|
+
action="onCancel"
|
|
19
|
+
ref={ref}
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
</ActionButton>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default React.forwardRef(LoadingButton);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ArrowUpOutlined, SendOutlined } from '@ant-design/icons';
|
|
2
|
+
import type { ButtonProps } from 'antd';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import ActionButton from './ActionButton';
|
|
5
|
+
import { createStyles } from 'antd-style';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function SendButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ActionButton
|
|
13
|
+
icon={<ArrowUpOutlined />}
|
|
14
|
+
type="primary"
|
|
15
|
+
{...props}
|
|
16
|
+
action="onSend"
|
|
17
|
+
ref={ref}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default React.forwardRef(SendButton);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface RecordingIconProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 录音图标的CSS类名,用于自定义样式
|
|
6
|
+
* @descriptionEn CSS class name for the recording icon for custom styling
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const SIZE = 1000;
|
|
12
|
+
const COUNT = 4;
|
|
13
|
+
const RECT_WIDTH = 140;
|
|
14
|
+
const RECT_RADIUS = RECT_WIDTH / 2;
|
|
15
|
+
const RECT_HEIGHT_MIN = 250;
|
|
16
|
+
const RECT_HEIGHT_MAX = 500;
|
|
17
|
+
const DURATION = 0.8;
|
|
18
|
+
|
|
19
|
+
export default function RecordingIcon({ className }: RecordingIconProps) {
|
|
20
|
+
return (
|
|
21
|
+
<svg
|
|
22
|
+
color="currentColor"
|
|
23
|
+
viewBox={`0 0 ${SIZE} ${SIZE}`}
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
26
|
+
className={className}
|
|
27
|
+
>
|
|
28
|
+
<title>Speech Recording</title>
|
|
29
|
+
|
|
30
|
+
{Array.from({ length: COUNT }).map((_, index) => {
|
|
31
|
+
const dest = (SIZE - RECT_WIDTH * COUNT) / (COUNT - 1);
|
|
32
|
+
const x = index * (dest + RECT_WIDTH);
|
|
33
|
+
const yMin = SIZE / 2 - RECT_HEIGHT_MIN / 2;
|
|
34
|
+
const yMax = SIZE / 2 - RECT_HEIGHT_MAX / 2;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<rect
|
|
38
|
+
fill="currentColor"
|
|
39
|
+
rx={RECT_RADIUS}
|
|
40
|
+
ry={RECT_RADIUS}
|
|
41
|
+
height={RECT_HEIGHT_MIN}
|
|
42
|
+
width={RECT_WIDTH}
|
|
43
|
+
x={x}
|
|
44
|
+
y={yMin}
|
|
45
|
+
key={index}
|
|
46
|
+
>
|
|
47
|
+
<animate
|
|
48
|
+
attributeName="height"
|
|
49
|
+
values={`${RECT_HEIGHT_MIN}; ${RECT_HEIGHT_MAX}; ${RECT_HEIGHT_MIN}`}
|
|
50
|
+
keyTimes="0; 0.5; 1"
|
|
51
|
+
dur={`${DURATION}s`}
|
|
52
|
+
begin={`${(DURATION / COUNT) * index}s`}
|
|
53
|
+
repeatCount="indefinite"
|
|
54
|
+
/>
|
|
55
|
+
<animate
|
|
56
|
+
attributeName="y"
|
|
57
|
+
values={`${yMin}; ${yMax}; ${yMin}`}
|
|
58
|
+
keyTimes="0; 0.5; 1"
|
|
59
|
+
dur={`${DURATION}s`}
|
|
60
|
+
begin={`${(DURATION / COUNT) * index}s`}
|
|
61
|
+
repeatCount="indefinite"
|
|
62
|
+
/>
|
|
63
|
+
</rect>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</svg>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ButtonProps } from 'antd';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import ActionButton, { ActionButtonContext } from '../ActionButton';
|
|
4
|
+
import { SparkMicLine, SparkMicOffLine, SparkMicOnLine } from '@agentscope-ai/icons';
|
|
5
|
+
import RecordingIcon from './RecordingIcon';
|
|
6
|
+
|
|
7
|
+
function SpeechButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
|
|
8
|
+
const { speechRecording, onSpeechDisabled, prefixCls } = React.useContext(ActionButtonContext);
|
|
9
|
+
|
|
10
|
+
let icon: React.ReactNode = null;
|
|
11
|
+
if (speechRecording) {
|
|
12
|
+
icon = <RecordingIcon className={`${prefixCls}-recording-icon`} />;
|
|
13
|
+
} else if (onSpeechDisabled) {
|
|
14
|
+
icon = <SparkMicOffLine />;
|
|
15
|
+
} else {
|
|
16
|
+
icon = <SparkMicLine />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ActionButton
|
|
21
|
+
icon={icon}
|
|
22
|
+
variant="text"
|
|
23
|
+
{...props}
|
|
24
|
+
action="onSpeech"
|
|
25
|
+
ref={ref}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default React.forwardRef(SpeechButton);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
|
|
4
|
+
export default function () {
|
|
5
|
+
const [value, setValue] = useState('');
|
|
6
|
+
return <ChatInput placeholder='Please type here...' value={value} onChange={setValue} allowSpeech></ChatInput>
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
|
|
4
|
+
export default function () {
|
|
5
|
+
const [value, setValue] = useState('Hello, Alibaba Cloud Spark Chat!');
|
|
6
|
+
return <ChatInput placeholder='Please type here...' value={value} onChange={setValue}></ChatInput>
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
import { SparkMagicNoteLine } from '@agentscope-ai/icons';
|
|
4
|
+
|
|
5
|
+
export default function () {
|
|
6
|
+
const [mode, setMode] = React.useState('');
|
|
7
|
+
return <div style={{ width: '100%' }}>
|
|
8
|
+
<ChatInput.ModeSelect options={[
|
|
9
|
+
{
|
|
10
|
+
icon: <SparkMagicNoteLine style={{ fontSize: 16 }} />,
|
|
11
|
+
label: '文本',
|
|
12
|
+
value: 'text',
|
|
13
|
+
tooltip: '文本 tooltip'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
icon: <SparkMagicNoteLine style={{ fontSize: 16 }} />,
|
|
17
|
+
label: '图片',
|
|
18
|
+
selectedLabel: <div style={{
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
textOverflow: 'ellipsis',
|
|
21
|
+
whiteSpace: 'nowrap',
|
|
22
|
+
}}>图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片图片',
|
|
23
|
+
</div>,
|
|
24
|
+
value: 'image',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
icon: <SparkMagicNoteLine style={{ fontSize: 16 }} />,
|
|
28
|
+
label: '文件',
|
|
29
|
+
value: 'file',
|
|
30
|
+
},
|
|
31
|
+
]}
|
|
32
|
+
value={mode}
|
|
33
|
+
closeTip='close tooltip'
|
|
34
|
+
onChange={setMode}
|
|
35
|
+
desc={<div
|
|
36
|
+
style={{ fontSize: 12 }}
|
|
37
|
+
onClick={() => {
|
|
38
|
+
setMode('')
|
|
39
|
+
}}>
|
|
40
|
+
description of {mode}
|
|
41
|
+
</div>}
|
|
42
|
+
/>
|
|
43
|
+
<ChatInput placeholder='Please type here...' ></ChatInput>
|
|
44
|
+
</div>
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Attachments, ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
import { GetProp, Upload } from 'antd';
|
|
4
|
+
import { IconButton, Button } from '@agentscope-ai/design';
|
|
5
|
+
import { SparkAttachmentLine, SparkDeepSearchLine, SparkKeyboardLine } from '@agentscope-ai/icons';
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
const [search, setSearch] = React.useState(false);
|
|
9
|
+
const [attachedFiles, setAttachedFiles] = React.useState<GetProp<typeof Attachments, 'items'>>([]);
|
|
10
|
+
const handleFileChange: GetProp<typeof Attachments, 'onChange'> = async ({ fileList }) => {
|
|
11
|
+
setAttachedFiles(fileList);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const senderHeader = (
|
|
15
|
+
<ChatInput.Header
|
|
16
|
+
closable={false}
|
|
17
|
+
open={attachedFiles?.length > 0}
|
|
18
|
+
>
|
|
19
|
+
<Attachments
|
|
20
|
+
items={attachedFiles}
|
|
21
|
+
onChange={handleFileChange}
|
|
22
|
+
/>
|
|
23
|
+
</ChatInput.Header>
|
|
24
|
+
);
|
|
25
|
+
const attachmentsNode = (
|
|
26
|
+
<Upload onChange={handleFileChange} fileList={attachedFiles} showUploadList={false} key="upload">
|
|
27
|
+
<IconButton icon={<SparkAttachmentLine />} bordered={false} />
|
|
28
|
+
</Upload>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return <ChatInput
|
|
32
|
+
placeholder='Please type here...'
|
|
33
|
+
zoomable
|
|
34
|
+
header={senderHeader}
|
|
35
|
+
prefix={[
|
|
36
|
+
attachmentsNode,
|
|
37
|
+
<Button type="text" color={search ? 'primary' : 'default'} variant={search ? 'filled' : 'text'} icon={<SparkDeepSearchLine />} style={{ padding: '0 6px', gap: 6 }} onClick={() => setSearch(!search)}>联网搜索</Button>,
|
|
38
|
+
]}>
|
|
39
|
+
</ChatInput>
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Attachments, ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
import { Button, GetProp, Upload } from 'antd';
|
|
4
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
5
|
+
import { SparkAttachmentLine } from '@agentscope-ai/icons';
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
// mock data
|
|
9
|
+
const [attachedFiles, setAttachedFiles] = React.useState<GetProp<typeof Attachments, 'items'>>([
|
|
10
|
+
{
|
|
11
|
+
uid: '-1',
|
|
12
|
+
name: 'file.pdf',
|
|
13
|
+
status: 'done',
|
|
14
|
+
size: 1000,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
uid: '-2',
|
|
18
|
+
name: 'file.pdf',
|
|
19
|
+
status: 'done',
|
|
20
|
+
size: 2000,
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
uid: '-3',
|
|
25
|
+
name: 'file.pdf',
|
|
26
|
+
status: 'done',
|
|
27
|
+
size: 3000,
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const handleFileChange: GetProp<typeof Attachments, 'onChange'> = async ({ fileList }) => {
|
|
32
|
+
setAttachedFiles(fileList);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const senderHeader = (
|
|
36
|
+
<ChatInput.Header
|
|
37
|
+
closable={false}
|
|
38
|
+
open={attachedFiles?.length > 0}
|
|
39
|
+
>
|
|
40
|
+
<Attachments
|
|
41
|
+
items={attachedFiles}
|
|
42
|
+
onChange={handleFileChange}
|
|
43
|
+
/>
|
|
44
|
+
</ChatInput.Header>
|
|
45
|
+
);
|
|
46
|
+
const attachmentsNode = (
|
|
47
|
+
<Upload onChange={handleFileChange} fileList={attachedFiles} showUploadList={false} key="upload">
|
|
48
|
+
<IconButton icon={<SparkAttachmentLine />} bordered={false} />
|
|
49
|
+
</Upload>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return <ChatInput placeholder='Please type here...' header={senderHeader}
|
|
53
|
+
prefix={attachmentsNode}></ChatInput>
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Attachments, ChatInput } from '@agentscope-ai/chat';
|
|
3
|
+
import { Button, GetProp, Upload } from 'antd';
|
|
4
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
5
|
+
import { SparkAttachmentLine } from '@agentscope-ai/icons';
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
// mock data
|
|
9
|
+
const [attachedFiles, setAttachedFiles] = React.useState<GetProp<typeof Attachments, 'items'>>([
|
|
10
|
+
{
|
|
11
|
+
uid: '-1',
|
|
12
|
+
name: 'image.png',
|
|
13
|
+
status: 'done',
|
|
14
|
+
url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
uid: '-2',
|
|
18
|
+
name: 'image.png',
|
|
19
|
+
status: 'done',
|
|
20
|
+
url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
uid: '-3',
|
|
24
|
+
name: 'image.png',
|
|
25
|
+
status: 'done',
|
|
26
|
+
url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png',
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
const handleFileChange: GetProp<typeof Attachments, 'onChange'> = async ({ fileList }) => {
|
|
30
|
+
setAttachedFiles(fileList);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const senderHeader = (
|
|
34
|
+
<ChatInput.Header
|
|
35
|
+
closable={false}
|
|
36
|
+
open={attachedFiles?.length > 0}
|
|
37
|
+
>
|
|
38
|
+
<Attachments
|
|
39
|
+
items={attachedFiles}
|
|
40
|
+
onChange={handleFileChange}
|
|
41
|
+
/>
|
|
42
|
+
</ChatInput.Header>
|
|
43
|
+
);
|
|
44
|
+
const attachmentsNode = (
|
|
45
|
+
<Upload onChange={handleFileChange} fileList={attachedFiles} showUploadList={false} key="upload">
|
|
46
|
+
<IconButton icon={<SparkAttachmentLine />} bordered={false} />
|
|
47
|
+
</Upload>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return <ChatInput placeholder='Please type here...' header={senderHeader}
|
|
51
|
+
prefix={attachmentsNode}></ChatInput>
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: Input
|
|
4
|
+
order: 2
|
|
5
|
+
title: ChatInput
|
|
6
|
+
description: AI Input Box
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="ChatInput" desc="AI Input Box" llmTxtName="Sender"></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" center height="350">Example</code>
|
|
12
|
+
|
|
13
|
+
<Install>import { ChatInput } from '@agentscope-ai/chat'</Install>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#### ChatInput Examples
|
|
17
|
+
|
|
18
|
+
The following are examples and variations of this component
|
|
19
|
+
|
|
20
|
+
<code src="./demo/loading.tsx" center height="350">Pause During Generation</code>
|
|
21
|
+
<code src="./demo/withImage.tsx" center height="350">Upload Image</code>
|
|
22
|
+
<code src="./demo/withFile.tsx" center height="350">Upload File</code>
|
|
23
|
+
<code src="./demo/moreMode.tsx" center height="350">Custom Mode</code>
|
|
24
|
+
<code src="./demo/morePrefixAction.tsx" center height="350">Custom Functionality</code>
|
|
25
|
+
<code src="./demo/asr.tsx" center height="350">Voice Input</code>
|
|
26
|
+
|
|
27
|
+
#### API
|
|
28
|
+
|
|
29
|
+
<ApiParser source="./index.tsx" id="SenderProps"></ApiParser>
|