@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,109 @@
|
|
|
1
|
+
import katex, { type KatexOptions } from 'katex';
|
|
2
|
+
import { TokenizerAndRendererExtension } from 'marked';
|
|
3
|
+
|
|
4
|
+
import 'katex/dist/katex.min.css';
|
|
5
|
+
|
|
6
|
+
const inlineRuleNonStandard =
|
|
7
|
+
/^(?:\${1,2}([^$]{1,10000}?)\${1,2}|\\\(([\s\S]{1,10000}?)\\\)|\\\[((?:\\.|[^\\]){1,10000}?)\\\])/;
|
|
8
|
+
const blockRule = /^(\${1,2})\n([\s\S]{1,10000}?)\n\1(?:\n|$)|^\\\[((?:\\.|[^\\]){1,10000}?)\\\]/;
|
|
9
|
+
|
|
10
|
+
type LatexOption = {
|
|
11
|
+
katexOptions?: KatexOptions;
|
|
12
|
+
replaceAlignStart?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Token = {
|
|
16
|
+
text: string;
|
|
17
|
+
displayMode: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Render = (token: Token) => string;
|
|
21
|
+
|
|
22
|
+
type ILevel = 'inline' | 'block';
|
|
23
|
+
|
|
24
|
+
// fix katex not support align*: https://github.com/KaTeX/KaTeX/issues/1007
|
|
25
|
+
function replaceAlign(text: string) {
|
|
26
|
+
return text ? text.replace(/\{align\*\}/g, '{aligned}') : text;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function createRenderer(options: KatexOptions, newlineAfter: boolean) {
|
|
30
|
+
return (token: Token) =>
|
|
31
|
+
katex.renderToString(token.text, {
|
|
32
|
+
...options,
|
|
33
|
+
displayMode: token.displayMode,
|
|
34
|
+
}) + (newlineAfter ? '\n' : '');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function inlineKatex(renderer: Render, replaceAlignStart: boolean) {
|
|
38
|
+
const ruleReg = inlineRuleNonStandard;
|
|
39
|
+
return {
|
|
40
|
+
name: 'inlineKatex',
|
|
41
|
+
level: 'inline' as ILevel,
|
|
42
|
+
start(src: string) {
|
|
43
|
+
if (!src.includes('$') && !src.includes('\\(')) return;
|
|
44
|
+
|
|
45
|
+
const indices = [src.indexOf('$'), src.indexOf('\\(')].filter((idx) => idx !== -1);
|
|
46
|
+
|
|
47
|
+
if (indices.length === 0) return;
|
|
48
|
+
|
|
49
|
+
const katexIndex = Math.min(...indices);
|
|
50
|
+
const possibleKatex = src.slice(katexIndex);
|
|
51
|
+
|
|
52
|
+
if (possibleKatex.match(ruleReg)) {
|
|
53
|
+
return katexIndex;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
tokenizer(src: string) {
|
|
57
|
+
const match = src.match(inlineRuleNonStandard);
|
|
58
|
+
if (match) {
|
|
59
|
+
let text = (match[1] || match[2]).trim();
|
|
60
|
+
if (replaceAlignStart) {
|
|
61
|
+
text = replaceAlign(text);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
type: 'inlineKatex',
|
|
65
|
+
raw: match[0],
|
|
66
|
+
text,
|
|
67
|
+
displayMode: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
renderer,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function blockKatex(renderer: Render, replaceAlignStart: boolean) {
|
|
76
|
+
return {
|
|
77
|
+
name: 'blockKatex',
|
|
78
|
+
level: 'block' as ILevel,
|
|
79
|
+
tokenizer(src: string) {
|
|
80
|
+
const match = src.match(blockRule);
|
|
81
|
+
if (match) {
|
|
82
|
+
let text = replaceAlign(match[2] || match[3].trim());
|
|
83
|
+
if (replaceAlignStart) {
|
|
84
|
+
text = replaceAlign(text);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
type: 'blockKatex',
|
|
88
|
+
raw: match[0],
|
|
89
|
+
text,
|
|
90
|
+
displayMode: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
renderer,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const Latex = (options?: LatexOption): TokenizerAndRendererExtension[] => {
|
|
99
|
+
const { replaceAlignStart = true, katexOptions = { output: 'html' } } = options || {};
|
|
100
|
+
|
|
101
|
+
const inlineRenderer = createRenderer(katexOptions, false);
|
|
102
|
+
const blockRenderer = createRenderer(katexOptions, true);
|
|
103
|
+
return [
|
|
104
|
+
inlineKatex(inlineRenderer, replaceAlignStart),
|
|
105
|
+
blockKatex(blockRenderer, replaceAlignStart),
|
|
106
|
+
];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default Latex;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { KatexOptions } from 'katex';
|
|
2
|
+
import type { TokenizerAndRendererExtension } from 'marked';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import type { SyntaxHighlighterProps } from 'react-syntax-highlighter';
|
|
5
|
+
|
|
6
|
+
export type LatexOption = {
|
|
7
|
+
katexOptions?: KatexOptions;
|
|
8
|
+
replaceAlignStart?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type HighlightCodeType = 'root' | 'header' | 'headerTitle' | 'code';
|
|
12
|
+
export type HighlightCodeProps = {
|
|
13
|
+
lang?: string;
|
|
14
|
+
children: string;
|
|
15
|
+
header?: ReactNode | null;
|
|
16
|
+
prefixCls?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
className?: string;
|
|
19
|
+
highlightProps?: Partial<SyntaxHighlighterProps>;
|
|
20
|
+
// Semantic
|
|
21
|
+
classNames?: Partial<Record<HighlightCodeType, string>>;
|
|
22
|
+
styles?: Partial<Record<HighlightCodeType, React.CSSProperties>>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type MermaidType = 'root' | 'header' | 'graph' | 'code';
|
|
26
|
+
export type MermaidProps = {
|
|
27
|
+
children: string;
|
|
28
|
+
header?: ReactNode | null;
|
|
29
|
+
prefixCls?: string;
|
|
30
|
+
style?: React.CSSProperties;
|
|
31
|
+
className?: string;
|
|
32
|
+
highlightProps?: Partial<SyntaxHighlighterProps>;
|
|
33
|
+
// Semantic
|
|
34
|
+
classNames?: Partial<Record<MermaidType, string>>;
|
|
35
|
+
styles?: Partial<Record<MermaidType, React.CSSProperties>>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
interface BaseComponentConfig {
|
|
39
|
+
style: React.CSSProperties;
|
|
40
|
+
styles: Record<string, React.CSSProperties>;
|
|
41
|
+
className: string;
|
|
42
|
+
classNames: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type ComponentConfig<
|
|
46
|
+
CompProps extends Record<PropertyKey, any>,
|
|
47
|
+
PickType extends keyof CompProps = keyof BaseComponentConfig,
|
|
48
|
+
> = Pick<CompProps, PickType>;
|
|
49
|
+
|
|
50
|
+
export interface MarkdownComponentsConfig {
|
|
51
|
+
highlightCode?: ComponentConfig<HighlightCodeProps>;
|
|
52
|
+
mermaid?: ComponentConfig<MermaidProps>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type PluginsType = {
|
|
56
|
+
/**
|
|
57
|
+
* @desc 渲染数学公式Latex语法。
|
|
58
|
+
* @descEN Rendering mathematical formulas using Latex syntax.
|
|
59
|
+
*/
|
|
60
|
+
Latex: (options?: LatexOption) => TokenizerAndRendererExtension[];
|
|
61
|
+
/**
|
|
62
|
+
* @desc 渲染代码高亮。
|
|
63
|
+
* @descEN Highlight the rendering code.
|
|
64
|
+
*/
|
|
65
|
+
HighlightCode: (props: HighlightCodeProps) => React.ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* @desc 渲染 Mermaid 图表。
|
|
68
|
+
* @descEN Rendering the Mermaid Chart.
|
|
69
|
+
*/
|
|
70
|
+
Mermaid: (props: MermaidProps) => React.ReactNode;
|
|
71
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const content = `sequenceDiagram
|
|
5
|
+
Alice->>John: Hello John, how are you?
|
|
6
|
+
John-->>Alice: Great!
|
|
7
|
+
Alice-)John: See you later!
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
export default function () {
|
|
11
|
+
return <Mermaid content={content} height={300} />;
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const classDiagram = `classDiagram
|
|
5
|
+
note "From Duck till Zebra"
|
|
6
|
+
Animal <|-- Duck
|
|
7
|
+
note for Duck "can fly\\ncan swim\\ncan dive\\ncan help in debugging"
|
|
8
|
+
Animal <|-- Fish
|
|
9
|
+
Animal <|-- Zebra
|
|
10
|
+
Animal : +int age
|
|
11
|
+
Animal : +String gender
|
|
12
|
+
Animal: +isMammal()
|
|
13
|
+
Animal: +mate()
|
|
14
|
+
class Duck{
|
|
15
|
+
+String beakColor
|
|
16
|
+
+swim()
|
|
17
|
+
+quack()
|
|
18
|
+
}
|
|
19
|
+
class Fish{
|
|
20
|
+
-int sizeInFeet
|
|
21
|
+
-canEat()
|
|
22
|
+
}
|
|
23
|
+
class Zebra{
|
|
24
|
+
+bool is_wild
|
|
25
|
+
+run()
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export default () => {
|
|
30
|
+
return <Mermaid content={classDiagram} height={400} />;
|
|
31
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const content = `flowchart LR
|
|
5
|
+
A[Hard edge] -->|Link text| B(Round edge)
|
|
6
|
+
B --> C{Decision}
|
|
7
|
+
C -->|One| D[Result one]
|
|
8
|
+
C -->|Two| E[Result two]
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export default () => {
|
|
12
|
+
return <Mermaid content={content} height={200} />;
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const content = `sequenceDiagram
|
|
5
|
+
autonumber
|
|
6
|
+
Alice->>John: Hello John, how are you?
|
|
7
|
+
loop HealthCheck
|
|
8
|
+
John->>John: Fight against hypochondria
|
|
9
|
+
end
|
|
10
|
+
Note right of John: Rational thoughts!
|
|
11
|
+
John-->>Alice: Great!
|
|
12
|
+
John->>Bob: How about you?
|
|
13
|
+
Bob-->>John: Jolly good!
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export default () => {
|
|
17
|
+
return <Mermaid content={content} height={400} />;
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const content = `stateDiagram-v2
|
|
5
|
+
[*] --> Still
|
|
6
|
+
Still --> [*]
|
|
7
|
+
|
|
8
|
+
Still --> Moving
|
|
9
|
+
Moving --> Still
|
|
10
|
+
Moving --> Crash
|
|
11
|
+
Crash --> [*]
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export default function () {
|
|
15
|
+
return <Mermaid content={content} height={400} />;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Mermaid } from '@agentscope-ai/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const content = `timeline
|
|
5
|
+
title History of Social Media Platform
|
|
6
|
+
2002 : LinkedIn
|
|
7
|
+
2004 : Facebook
|
|
8
|
+
: Google
|
|
9
|
+
2005 : YouTube
|
|
10
|
+
2006 : Twitter
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export default function () {
|
|
14
|
+
return <Mermaid content={content} height={300} />;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: Output
|
|
4
|
+
order: 3
|
|
5
|
+
title: Mermaid
|
|
6
|
+
description: Mermaid Chart
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="Mermaid" desc="Mermaid is a component for rendering Mermaid diagrams in React. It supports various diagram types like flowcharts, sequence diagrams, class diagrams, and more with customizable styling and interactive features."></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" height="auto">Example</code>
|
|
12
|
+
|
|
13
|
+
<Install>import { Mermaid } from '@agentscope-ai/chat'</Install>
|
|
14
|
+
|
|
15
|
+
#### More Mermaid Example
|
|
16
|
+
|
|
17
|
+
<code src="./demo/flowchart.tsx" height="auto">Flowchart</code>
|
|
18
|
+
<code src="./demo/sequence.tsx" height="auto">Sequence Diagram</code>
|
|
19
|
+
<code src="./demo/class.tsx" height="auto">Class Diagram</code>
|
|
20
|
+
<code src="./demo/state.tsx" height="auto">State Diagram</code>
|
|
21
|
+
<code src="./demo/timeline.tsx" height="auto">Timeline</code>
|
|
22
|
+
|
|
23
|
+
For more examples, please refer to [Mermaid Docs](https://mermaid.js.org/intro/)
|
|
24
|
+
|
|
25
|
+
#### API
|
|
26
|
+
|
|
27
|
+
<ApiParser source="./index.tsx" id="IMermaidProps"></ApiParser>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Image } from '@agentscope-ai/design';
|
|
2
|
+
import { useAsyncEffect } from 'ahooks';
|
|
3
|
+
import { theme as AntdTheme } from 'antd';
|
|
4
|
+
import { kebabCase } from 'lodash';
|
|
5
|
+
import { MermaidConfig, Mermaid as MermaidInstance } from 'mermaid';
|
|
6
|
+
import React, { useEffect, useId, useMemo, useState } from 'react';
|
|
7
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
8
|
+
import { createGlobalStyle } from 'antd-style';
|
|
9
|
+
|
|
10
|
+
const Style = createGlobalStyle`
|
|
11
|
+
.${p => p.theme.prefixCls}-mermaid {
|
|
12
|
+
&-preview img {
|
|
13
|
+
background: ${(p) => p.theme.colorBgBase};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
// 懒加载 Mermaid 实例
|
|
19
|
+
let mermaidPromise: Promise<MermaidInstance | undefined>;
|
|
20
|
+
const genMermaidPromise = async () => {
|
|
21
|
+
if (mermaidPromise) return mermaidPromise;
|
|
22
|
+
mermaidPromise = import('mermaid').then(module => module.default);
|
|
23
|
+
return mermaidPromise;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export interface IMermaidProps {
|
|
28
|
+
/**
|
|
29
|
+
* @description Mermaid 图表的源代码,包含图表定义和配置
|
|
30
|
+
* @descriptionEn Mermaid chart source code containing chart definition and configuration
|
|
31
|
+
*/
|
|
32
|
+
content: string;
|
|
33
|
+
/**
|
|
34
|
+
* @description 图表的宽度,支持数字(像素)或字符串(CSS单位)
|
|
35
|
+
* @descriptionEn Width of the chart, supports number (pixels) or string (CSS units)
|
|
36
|
+
*/
|
|
37
|
+
width?: number | string;
|
|
38
|
+
/**
|
|
39
|
+
* @description 图表的高度,支持数字(像素)或字符串(CSS单位)
|
|
40
|
+
* @descriptionEn Height of the chart, supports number (pixels) or string (CSS units)
|
|
41
|
+
*/
|
|
42
|
+
height?: number | string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default function Mermaid(props: IMermaidProps) {
|
|
46
|
+
const { content, width, height } = props;
|
|
47
|
+
const { theme, getPrefixCls } = useProviderContext();
|
|
48
|
+
const prefixCls = getPrefixCls('mermaid');
|
|
49
|
+
|
|
50
|
+
const mermaidConfig: MermaidConfig = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
theme: theme?.algorithm === AntdTheme.darkAlgorithm ? 'dark' : 'default',
|
|
53
|
+
securityLevel: 'loose',
|
|
54
|
+
|
|
55
|
+
startOnLoad: false,
|
|
56
|
+
}),
|
|
57
|
+
[theme?.algorithm, theme?.token.fontFamily],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const [renderedContent, setRenderedContent] = useState('');
|
|
61
|
+
const [blobUrl, setBlobUrl] = useState<string>();
|
|
62
|
+
|
|
63
|
+
const id = useId();
|
|
64
|
+
const mermaidId = kebabCase(`mermaid-${id}`);
|
|
65
|
+
|
|
66
|
+
useAsyncEffect(async () => {
|
|
67
|
+
try {
|
|
68
|
+
const mermaidInstance = await genMermaidPromise();
|
|
69
|
+
if (!mermaidInstance) {
|
|
70
|
+
setRenderedContent(content);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const isValid = await mermaidInstance.parse(content);
|
|
74
|
+
if (isValid) {
|
|
75
|
+
mermaidInstance.initialize(mermaidConfig);
|
|
76
|
+
const { svg } = await mermaidInstance.render(mermaidId, content);
|
|
77
|
+
setRenderedContent(svg);
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error('Invalid Mermaid syntax');
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (!renderedContent) console.error('Mermaid parse error: ', error);
|
|
83
|
+
setRenderedContent(renderedContent || '');
|
|
84
|
+
}
|
|
85
|
+
}, [content, mermaidConfig]);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (renderedContent) {
|
|
90
|
+
const blob = new Blob([renderedContent], { type: 'image/svg+xml' });
|
|
91
|
+
const url = URL.createObjectURL(blob);
|
|
92
|
+
setBlobUrl(url);
|
|
93
|
+
return () => {
|
|
94
|
+
URL.revokeObjectURL(url);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
}, [renderedContent]);
|
|
99
|
+
|
|
100
|
+
if (!blobUrl) return null;
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
<Style />
|
|
106
|
+
<Image
|
|
107
|
+
className={prefixCls}
|
|
108
|
+
src={blobUrl}
|
|
109
|
+
alt={'mermaid'}
|
|
110
|
+
width={width}
|
|
111
|
+
height={height}
|
|
112
|
+
preview={{
|
|
113
|
+
rootClassName: `${prefixCls}-preview`
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: 输出
|
|
4
|
+
order: 3
|
|
5
|
+
title: Mermaid
|
|
6
|
+
description: Mermaid 图表
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="Mermaid" desc="Mermaid 是 React 中用于渲染 Mermaid 图表的组件。它支持多种图表类型,如流程图、序列图、类图等,具有可定制的样式和交互功能。"></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" height="auto">示例</code>
|
|
12
|
+
|
|
13
|
+
<Install>import { Mermaid } from '@agentscope-ai/chat'</Install>
|
|
14
|
+
|
|
15
|
+
#### Mermaid 更多示例
|
|
16
|
+
|
|
17
|
+
<code src="./demo/flowchart.tsx" height="auto">Flowchart</code>
|
|
18
|
+
<code src="./demo/sequence.tsx" height="auto">Sequence Diagram</code>
|
|
19
|
+
<code src="./demo/class.tsx" height="auto">Class Diagram</code>
|
|
20
|
+
<code src="./demo/state.tsx" height="auto">State Diagram</code>
|
|
21
|
+
<code src="./demo/timeline.tsx" height="auto">Timeline</code>
|
|
22
|
+
|
|
23
|
+
更多示例请参考 [Mermaid Docs](https://mermaid.js.org/intro/)
|
|
24
|
+
|
|
25
|
+
#### API
|
|
26
|
+
|
|
27
|
+
<ApiParser source="./index.tsx" id="IMermaidProps"></ApiParser>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useProviderContext } from '../Provider';
|
|
3
|
+
import Style from './style';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { SparkDownLine, SparkUpLine } from '@agentscope-ai/icons';
|
|
6
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export interface IOperateCardProps {
|
|
10
|
+
/**
|
|
11
|
+
* @description 头部配置
|
|
12
|
+
* @descriptionEn Header Config
|
|
13
|
+
* @default {}
|
|
14
|
+
*/
|
|
15
|
+
header: {
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
icon: React.ReactNode;
|
|
19
|
+
title: React.ReactNode | string;
|
|
20
|
+
description?: React.ReactNode | string;
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* @description 内容配置
|
|
24
|
+
* @descriptionEn Body Config
|
|
25
|
+
* @default {}
|
|
26
|
+
*/
|
|
27
|
+
body?: {
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
defaultOpen?: boolean;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function LineBody(props: {
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}) {
|
|
36
|
+
const { getPrefixCls } = useProviderContext();
|
|
37
|
+
const prefixCls = getPrefixCls('operate-card');
|
|
38
|
+
return <>
|
|
39
|
+
<div className={`${prefixCls}-line-body`}>
|
|
40
|
+
{props.children}
|
|
41
|
+
</div>
|
|
42
|
+
</>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function OperateCard(props: IOperateCardProps) {
|
|
47
|
+
const { getPrefixCls } = useProviderContext();
|
|
48
|
+
const prefixCls = getPrefixCls('operate-card');
|
|
49
|
+
const [open, setOpen] = useState(props.body?.defaultOpen || false);
|
|
50
|
+
|
|
51
|
+
return <>
|
|
52
|
+
<Style />
|
|
53
|
+
<div className={prefixCls}>
|
|
54
|
+
<div className={classNames(`${prefixCls}-header`, props.header.className, {
|
|
55
|
+
[`${prefixCls}-header-has-body`]: props.body
|
|
56
|
+
})} onClick={() => {
|
|
57
|
+
if (props.body) {
|
|
58
|
+
setOpen(!open)
|
|
59
|
+
}
|
|
60
|
+
}}>
|
|
61
|
+
<div className={`${prefixCls}-header-icon`}>
|
|
62
|
+
{props.header.icon}
|
|
63
|
+
</div>
|
|
64
|
+
{
|
|
65
|
+
typeof props.header.title === 'string' ? <div className={`${prefixCls}-header-title`}>{props.header.title}</div> : props.header.title
|
|
66
|
+
}
|
|
67
|
+
{
|
|
68
|
+
props.header.description && <div className={`${prefixCls}-header-description`}>
|
|
69
|
+
{props.header.description}
|
|
70
|
+
</div>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
props.body && <IconButton
|
|
75
|
+
size="small"
|
|
76
|
+
bordered={false}
|
|
77
|
+
className={`${prefixCls}-header-arrow`}
|
|
78
|
+
icon={open ? <SparkUpLine /> : <SparkDownLine />}
|
|
79
|
+
/>
|
|
80
|
+
}
|
|
81
|
+
</div>
|
|
82
|
+
{
|
|
83
|
+
props.body && open && <div className={`${prefixCls}-body`}>
|
|
84
|
+
{props.body.children}
|
|
85
|
+
</div>
|
|
86
|
+
}
|
|
87
|
+
</div >
|
|
88
|
+
</>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
OperateCard.LineBody = LineBody;
|
|
92
|
+
|
|
93
|
+
export default OperateCard;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OperateCard } from '@agentscope-ai/chat';
|
|
2
|
+
import { SparkBookLine } from '@agentscope-ai/icons';
|
|
3
|
+
import { Flex } from 'antd';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default function () {
|
|
7
|
+
|
|
8
|
+
return <Flex vertical gap={16}>
|
|
9
|
+
<OperateCard header={{
|
|
10
|
+
icon: <SparkBookLine />,
|
|
11
|
+
title: 'OperateCard',
|
|
12
|
+
description: 'OperateCard Description',
|
|
13
|
+
}} />
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<OperateCard header={{
|
|
18
|
+
icon: <SparkBookLine />,
|
|
19
|
+
title: 'OperateCard',
|
|
20
|
+
description: 'OperateCard Description',
|
|
21
|
+
}} body={{
|
|
22
|
+
children: <OperateCard.LineBody>
|
|
23
|
+
<div style={{ marginLeft: 16 }}>
|
|
24
|
+
<div>
|
|
25
|
+
OperateCard Body
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
OperateCard Body
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</OperateCard.LineBody>,
|
|
32
|
+
defaultOpen: true,
|
|
33
|
+
}} />
|
|
34
|
+
</Flex>
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Rag } from '@agentscope-ai/chat';
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
return <Rag
|
|
5
|
+
subTitle="GPT-5技术博客、行业分析、技术特性"
|
|
6
|
+
list={[
|
|
7
|
+
{
|
|
8
|
+
title: '【文档库】GPT-5 技术博客', content: 'Aliyun Bailianis a product offered by Alibaba Cloud, which is the cloud computing arm of Alibaba Group. Bailian is a high-performance AI development platform designed to help users build, deploy, and manage machine learning models and AI applications more efficiently.', footer: '来源文档:(真)拟定稿。GPT 的制度研究',
|
|
9
|
+
images: [
|
|
10
|
+
'https://gw.alicdn.com/imgextra/i1/O1CN01n7R7cy1MkE5OYeXV9_!!6000000001472-55-tps-24-24.svg',
|
|
11
|
+
'https://gw.alicdn.com/imgextra/i1/O1CN01n7R7cy1MkE5OYeXV9_!!6000000001472-55-tps-24-24.svg',
|
|
12
|
+
'https://gw.alicdn.com/imgextra/i1/O1CN01n7R7cy1MkE5OYeXV9_!!6000000001472-55-tps-24-24.svg',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{ title: '【文档库】GPT-5 行业分析', content: 'Aliyun Bailianis a product offered by Alibaba Cloud, which is the cloud computing arm of Alibaba Group. Bailian is a high-performance AI development platform designed to help users build, deploy, and manage machine learning models and AI applications more efficiently.', footer: '来源文档:(真)拟定稿。GPT 的制度研究' },
|
|
16
|
+
{ title: '【文档库】GPT-5 技术特性', content: 'Aliyun Bailianis a product offered by Alibaba Cloud, which is the cloud computing arm of Alibaba Group. Bailian is a high-performance AI development platform designed to help users build, deploy, and manage machine learning models and AI applications more efficiently.', footer: '来源文档:(真)拟定稿。GPT 的制度研究' },
|
|
17
|
+
]}
|
|
18
|
+
/>
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Thinking } from "@agentscope-ai/chat";
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
return <Thinking
|
|
5
|
+
title="Deep thinking"
|
|
6
|
+
subTitle="I am the name of a concept that is being thought about"
|
|
7
|
+
content={`Okay, the user is asking about "citypop." Let me start by recalling what I know about that term. I remember that City Pop is a genre of music, but I need to make sure I'm accurate.
|
|
8
|
+
|
|
9
|
+
First, when did City Pop originate? I think it was in Japan during the late 1970s and 1980s. That makes sense because Japan's economy was booming then, leading to a vibrant urban culture. The genre probably blends Western styles like funk, jazz, and disco with Japanese pop elements. Artists like Tatsuro Yamashita and Mariya Takeuchi come to mind. Oh, and there's that song "Plastic Love" by Mariya Takeuchi that went viral online recently, which might have sparked renewed interest.
|
|
10
|
+
|
|
11
|
+
I should also mention the themes of City Pop songs—they often reflect city life, romance, and leisure, fitting the upbeat and cosmopolitan vibe of the time. The visual style associated with it includes retro anime and vibrant cityscapes, which adds to its aesthetic appeal. It's interesting how the internet, especially platforms like YouTube and Spotify, helped revive this genre internationally. Maybe I should note that connection between modern digital culture and the resurgence of City Pop.
|
|
12
|
+
|
|
13
|
+
Wait, are there any subgenres or key characteristics I should highlight? The use of synthesizers, smooth vocals, and lush production are typical. Also, City Pop was influenced by yacht rock and soft rock from the West. It's important to link it to Japan's economic bubble era, as that context explains the music's optimistic and luxurious feel.
|
|
14
|
+
|
|
15
|
+
I need to ensure I don't confuse it with other Japanese genres like J-pop or Enka. City Pop is distinct in its fusion with Western sounds. Including notable albums, like Tatsuro Yamashita's "For You" or Anri's "Timely!!", could be helpful. Oh, and the connection to future funk and vaporwave genres that sample City Pop tracks is a good point for its modern influence.`}
|
|
16
|
+
/>
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Flex } from 'antd';
|
|
2
|
+
import { TodoList } from "@agentscope-ai/chat";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default function () {
|
|
6
|
+
return <Flex vertical gap={16}>
|
|
7
|
+
|
|
8
|
+
<TodoList
|
|
9
|
+
title="Task List"
|
|
10
|
+
defaultOpen={true}
|
|
11
|
+
list={[
|
|
12
|
+
{ title: '1、搜索GPT-5的官方发布信息,确认新特性', status: 'todo' },
|
|
13
|
+
{ title: '2、找技术博客和行业分析,获取GPT-5详细技术特性', status: 'todo' },
|
|
14
|
+
{ title: '3、交叉验证多个来源信息,确保准确性', status: 'todo' },
|
|
15
|
+
{ title: '4、整理信息并生成结构化文本报告', status: 'todo' },
|
|
16
|
+
]}
|
|
17
|
+
/>
|
|
18
|
+
<TodoList
|
|
19
|
+
title="Task List"
|
|
20
|
+
defaultOpen={false}
|
|
21
|
+
list={[
|
|
22
|
+
{ title: '1、搜索GPT-5的官方发布信息,确认新特性', status: 'done' },
|
|
23
|
+
{ title: '2、找技术博客和行业分析,获取GPT-5详细技术特性', status: 'running' },
|
|
24
|
+
{ title: '3、交叉验证多个来源信息,确保准确性', status: 'todo' },
|
|
25
|
+
{ title: '4、整理信息并生成结构化文本报告', status: 'todo' },
|
|
26
|
+
]}
|
|
27
|
+
/></Flex>
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToolCall } from "@agentscope-ai/chat";
|
|
2
|
+
export default function () {
|
|
3
|
+
return <ToolCall
|
|
4
|
+
title="Call Tool"
|
|
5
|
+
subTitle="I am the name of a tool that is being called"
|
|
6
|
+
input={{
|
|
7
|
+
foo: 'bar',
|
|
8
|
+
baz: 'qux',
|
|
9
|
+
}}
|
|
10
|
+
output={{
|
|
11
|
+
result: 'result',
|
|
12
|
+
}}
|
|
13
|
+
/>
|
|
14
|
+
}
|