@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,45 @@
|
|
|
1
|
+
import { useChatAnywhereOptions } from "../Context/ChatAnywhereOptionsContext";
|
|
2
|
+
import { InnerHeader, InnerList, InnerAdder } from '../Sessions';
|
|
3
|
+
import { useProviderContext } from "@agentscope-ai/chat";
|
|
4
|
+
import Style from './styles';
|
|
5
|
+
import { useContext } from "react";
|
|
6
|
+
import { Drawer } from 'antd';
|
|
7
|
+
import { ChatAnyWhereLayoutContext } from "../Context/ChatAnywhereLayoutContext";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export default function Header() {
|
|
11
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere');
|
|
12
|
+
const { narrowMode, rightHeader } = useChatAnywhereOptions(v => v.theme);
|
|
13
|
+
const { toggleCollapsed, collapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
14
|
+
|
|
15
|
+
return <>
|
|
16
|
+
<Style />
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
className={`${prefixCls}-layout-right-header`}
|
|
20
|
+
>
|
|
21
|
+
{
|
|
22
|
+
narrowMode ? <InnerHeader className={`${prefixCls}-default-header-inner`} /> : null
|
|
23
|
+
}
|
|
24
|
+
{
|
|
25
|
+
rightHeader && <div className={`${prefixCls}-default-header-right`}>{rightHeader}</div>
|
|
26
|
+
}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
narrowMode && <Drawer
|
|
31
|
+
width="80vw"
|
|
32
|
+
styles={{ body: { padding: 0 } }}
|
|
33
|
+
open={collapsed}
|
|
34
|
+
onClose={toggleCollapsed}
|
|
35
|
+
title={null}
|
|
36
|
+
closable={false} placement="left">
|
|
37
|
+
|
|
38
|
+
<div className={`${prefixCls}-sessions`}>
|
|
39
|
+
<InnerList narrowMode />
|
|
40
|
+
<InnerAdder narrowMode />
|
|
41
|
+
</div>
|
|
42
|
+
</Drawer>
|
|
43
|
+
}
|
|
44
|
+
</>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
export default createGlobalStyle`
|
|
4
|
+
|
|
5
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-default-header {
|
|
6
|
+
&-inner {
|
|
7
|
+
flex-direction: row-reverse;
|
|
8
|
+
gap: 10px;
|
|
9
|
+
padding: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-right {
|
|
13
|
+
margin: 0 0 0 auto;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-default-header-sessions {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
height: 100%;
|
|
21
|
+
padding: 10px 0 10px 0;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
2
|
+
import Style from './styles';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
import { useChatAnywhereOptions } from '../Context/ChatAnywhereOptionsContext';
|
|
5
|
+
import { useContext } from 'react';
|
|
6
|
+
import Chat from '../Chat';
|
|
7
|
+
import Sessions from '../Sessions';
|
|
8
|
+
import { ChatAnyWhereLayoutContext } from '../Context/ChatAnywhereLayoutContext';
|
|
9
|
+
import Header from '../Header';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
interface IProps {
|
|
13
|
+
className?: string;
|
|
14
|
+
left?: React.ReactNode;
|
|
15
|
+
right?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function (props: IProps) {
|
|
19
|
+
const { className } = props;
|
|
20
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-layout');
|
|
21
|
+
const narrowMode = useChatAnywhereOptions(v => v.theme.narrowMode);
|
|
22
|
+
const { session } = useChatAnywhereOptions(v => ({ session: v.session }));
|
|
23
|
+
const { collapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
24
|
+
const showLeft = !narrowMode && session && session.multiple;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
return <>
|
|
28
|
+
<Style />
|
|
29
|
+
<div className={cls(`${prefixCls}`, className)}>
|
|
30
|
+
{
|
|
31
|
+
showLeft && <div className={cls(`${prefixCls}-left`, {
|
|
32
|
+
[`${prefixCls}-left-collapsed`]: collapsed,
|
|
33
|
+
})}>
|
|
34
|
+
<Sessions />
|
|
35
|
+
</div>
|
|
36
|
+
}
|
|
37
|
+
<div className={cls(`${prefixCls}-right`, {
|
|
38
|
+
[`${prefixCls}-right-has-header`]: true,
|
|
39
|
+
})}>
|
|
40
|
+
<Header />
|
|
41
|
+
<Chat />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default createGlobalStyle`
|
|
5
|
+
* {
|
|
6
|
+
-webkit-tap-highlight-color: transparent !important;
|
|
7
|
+
tap-highlight-color: transparent !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-layout {
|
|
11
|
+
height: 100%;
|
|
12
|
+
background: ${(p) => p.theme.colorBgBase};
|
|
13
|
+
display: flex;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-layout-left {
|
|
17
|
+
width: 240px;
|
|
18
|
+
background-color: ${(p) => p.theme.colorBgBase};
|
|
19
|
+
transition: all 0.2s;
|
|
20
|
+
|
|
21
|
+
&-collapsed {
|
|
22
|
+
margin-left: -168px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-layout-right {
|
|
27
|
+
position: relative;
|
|
28
|
+
width: 0;
|
|
29
|
+
flex: 1;
|
|
30
|
+
background: ${(p) => p.theme.colorFillTertiary};
|
|
31
|
+
|
|
32
|
+
&-header {
|
|
33
|
+
height: 54px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
left: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
top: 0;
|
|
38
|
+
z-index: 1;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
padding: 0 20px;
|
|
42
|
+
backdrop-filter: blur(10px);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-layout-right-has-header {
|
|
47
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-message-list > div::before {
|
|
48
|
+
content: ' ';
|
|
49
|
+
display: block;
|
|
50
|
+
height: 54px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.${(p) => p.theme.prefixCls}-chat-anywhere-sessions {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
height: 100%;
|
|
58
|
+
|
|
59
|
+
&-list {
|
|
60
|
+
padding: 10px 20px;
|
|
61
|
+
height: 0;
|
|
62
|
+
flex: 1;
|
|
63
|
+
overflow-y: scroll;
|
|
64
|
+
|
|
65
|
+
/* 隐藏滚动条 */
|
|
66
|
+
scrollbar-width: none; /* Firefox */
|
|
67
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
68
|
+
&::-webkit-scrollbar {
|
|
69
|
+
display: none; /* Chrome, Safari, Opera */
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&-header {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
padding: 0 20px;
|
|
78
|
+
height: 54px;
|
|
79
|
+
|
|
80
|
+
&-collapse {
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&-left {
|
|
84
|
+
flex: 1;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: 4px;
|
|
88
|
+
flex: 1;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&-adder {
|
|
94
|
+
padding: 0 20px 8px 20px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&-content {
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
flex: 1;
|
|
101
|
+
height: 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useContextSelector } from "use-context-selector";
|
|
2
|
+
import { ChatAnywhereSessionsContext, useChatAnywhereSessions } from "../Context/ChatAnywhereSessionsContext";
|
|
3
|
+
import { Button, IconButton } from "@agentscope-ai/design";
|
|
4
|
+
import { ChatAnywhereInputContext } from "../Context/ChatAnywhereInputContext";
|
|
5
|
+
import { useProviderContext } from "@agentscope-ai/chat";
|
|
6
|
+
import { useChatAnywhereOptions } from "../Context/ChatAnywhereOptionsContext";
|
|
7
|
+
import React, { useContext, useMemo } from "react";
|
|
8
|
+
import { SparkDeleteLine, SparkOperateLeftLine, SparkOperateRightLine, SparkPlusLine } from "@agentscope-ai/icons";
|
|
9
|
+
import { HistoryPanel } from '@agentscope-ai/chat';
|
|
10
|
+
import { ChatAnyWhereLayoutContext } from "../Context/ChatAnywhereLayoutContext";
|
|
11
|
+
import cls from 'classnames';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default function Sessions() {
|
|
15
|
+
const { collapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
16
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-sessions');
|
|
17
|
+
const leftHeader = useChatAnywhereOptions(v => v.theme?.leftHeader) || {};
|
|
18
|
+
|
|
19
|
+
return <>
|
|
20
|
+
<div className={`${prefixCls}`}>
|
|
21
|
+
{
|
|
22
|
+
React.isValidElement(leftHeader) ? leftHeader : <InnerHeader />
|
|
23
|
+
}
|
|
24
|
+
<div className={`${prefixCls}-content`} style={{ display: collapsed ? 'none' : 'flex' }}>
|
|
25
|
+
<InnerAdder />
|
|
26
|
+
<InnerList />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export function InnerHeader({ className }: { className?: string }) {
|
|
34
|
+
const leftHeader = useChatAnywhereOptions(v => v.theme?.leftHeader) || {};
|
|
35
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-sessions');
|
|
36
|
+
const { toggleCollapsed, collapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
37
|
+
const multiple = useChatAnywhereOptions(v => v.session.multiple);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
logo = 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
|
|
42
|
+
title = 'Runtime WebUI'
|
|
43
|
+
} = leftHeader as { logo?: string; title?: string };
|
|
44
|
+
|
|
45
|
+
return <>
|
|
46
|
+
<div className={cls(`${prefixCls}-header`, className)}>
|
|
47
|
+
<div className={`${prefixCls}-header-left`}>
|
|
48
|
+
<img src={logo} alt="logo" height={32} />
|
|
49
|
+
<span>{title}</span>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
multiple && <IconButton
|
|
54
|
+
className={`${prefixCls}-header-collapse`}
|
|
55
|
+
bordered={false}
|
|
56
|
+
icon={!collapsed ? <SparkOperateLeftLine /> : <SparkOperateRightLine />}
|
|
57
|
+
onClick={toggleCollapsed}
|
|
58
|
+
/>
|
|
59
|
+
}
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function InnerAdder(props: { style?: React.CSSProperties; narrowMode?: boolean }) {
|
|
65
|
+
const loading = useContextSelector(ChatAnywhereInputContext, v => v.loading);
|
|
66
|
+
const { createSession } = useChatAnywhereSessions();
|
|
67
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-sessions');
|
|
68
|
+
const { toggleCollapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
69
|
+
|
|
70
|
+
return <div className={`${prefixCls}-adder`} style={props.style}>
|
|
71
|
+
<Button block type="primary" icon={<SparkPlusLine />} disabled={loading} onClick={async() => {
|
|
72
|
+
await createSession();
|
|
73
|
+
if (props.narrowMode) {
|
|
74
|
+
toggleCollapsed();
|
|
75
|
+
}
|
|
76
|
+
}}>
|
|
77
|
+
New Chat
|
|
78
|
+
</Button>
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function InnerList(props: { style?: React.CSSProperties, narrowMode?: boolean }) {
|
|
83
|
+
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-sessions');
|
|
84
|
+
const sessions = useContextSelector(ChatAnywhereSessionsContext, v => v.sessions);
|
|
85
|
+
const { changeCurrentSessionId, removeSession } = useChatAnywhereSessions();
|
|
86
|
+
const currentSessionId = useContextSelector(ChatAnywhereSessionsContext, v => v.currentSessionId);
|
|
87
|
+
const { toggleCollapsed } = useContext(ChatAnyWhereLayoutContext);
|
|
88
|
+
|
|
89
|
+
const items = useMemo(() => sessions.map(session => ({
|
|
90
|
+
key: session.id,
|
|
91
|
+
label: session.name || 'New Chat',
|
|
92
|
+
})), [sessions]);
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
return <div className={`${prefixCls}-list`} style={props.style}>
|
|
96
|
+
<HistoryPanel items={items}
|
|
97
|
+
menu={[
|
|
98
|
+
{
|
|
99
|
+
key: 'delete',
|
|
100
|
+
icon: <SparkDeleteLine />,
|
|
101
|
+
danger: true,
|
|
102
|
+
onClick: async (session) => await removeSession({ id: session.key }),
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
105
|
+
activeKey={currentSessionId}
|
|
106
|
+
onActiveChange={(key) => {
|
|
107
|
+
changeCurrentSessionId(key);
|
|
108
|
+
if (props.narrowMode) {
|
|
109
|
+
toggleCollapsed();
|
|
110
|
+
}
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
</div>;
|
|
114
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Form, Input, InputNumber, Space, ColorPicker, Flex } from 'antd';
|
|
2
|
+
import { createStyles } from 'antd-style';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
interface FormItemProps {
|
|
6
|
+
name: string | string[];
|
|
7
|
+
label: string;
|
|
8
|
+
isList?: boolean;
|
|
9
|
+
children: any;
|
|
10
|
+
normalize?: (value: any) => any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const useStyles = createStyles(({ token, css }) => ({
|
|
15
|
+
label: {
|
|
16
|
+
marginBottom: 6,
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
color: token.colorTextSecondary,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
export default function FormItem(props: FormItemProps) {
|
|
24
|
+
const { styles } = useStyles();
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const node = props.isList ?
|
|
28
|
+
<Form.List name={props.name}>{props.children}</Form.List> :
|
|
29
|
+
<Form.Item name={props.name} normalize={props.normalize}>{props.children}</Form.Item>;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
return <div>
|
|
33
|
+
{props.label && <div className={styles.label}>{props.label}</div>}
|
|
34
|
+
{node}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Form, Input, ColorPicker, Flex, Splitter, Divider, InputNumber } from 'antd';
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
import { Button, IconButton, Switch } from '@agentscope-ai/design'
|
|
5
|
+
import { SparkDeleteLine, SparkPlusLine } from '@agentscope-ai/icons';
|
|
6
|
+
import FormItem from './FormItem';
|
|
7
|
+
import defaultConfig from './defaultConfig';
|
|
8
|
+
|
|
9
|
+
const useStyles = createStyles(({ token, css }) => ({
|
|
10
|
+
container: {
|
|
11
|
+
height: '100%',
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
form: {
|
|
17
|
+
height: 0,
|
|
18
|
+
flex: 1,
|
|
19
|
+
padding: '8px 16px 16px 16px',
|
|
20
|
+
overflow: 'auto',
|
|
21
|
+
},
|
|
22
|
+
actions: {
|
|
23
|
+
padding: 16,
|
|
24
|
+
display: 'flex',
|
|
25
|
+
borderTop: `1px solid ${token.colorBorderSecondary}`,
|
|
26
|
+
justifyContent: 'flex-end',
|
|
27
|
+
gap: 16,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
interface OptionsEditorProps {
|
|
33
|
+
value?: any;
|
|
34
|
+
onChange?: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const OptionsEditor: React.FC<OptionsEditorProps> = ({
|
|
38
|
+
value,
|
|
39
|
+
onChange,
|
|
40
|
+
}) => {
|
|
41
|
+
const { styles } = useStyles();
|
|
42
|
+
const [form] = Form.useForm();
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const handleSave = () => {
|
|
46
|
+
form.validateFields().then((values) => {
|
|
47
|
+
onChange(values);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleReset = () => {
|
|
52
|
+
form.setFieldsValue(defaultConfig);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className={styles.container}>
|
|
57
|
+
<Form
|
|
58
|
+
className={styles.form}
|
|
59
|
+
form={form}
|
|
60
|
+
layout="vertical"
|
|
61
|
+
initialValues={value}
|
|
62
|
+
>
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
<Divider orientation="left">Theme</Divider>
|
|
66
|
+
|
|
67
|
+
<FormItem name={['theme', 'colorPrimary']} label="colorPrimary" normalize={value => value.toHexString()}>
|
|
68
|
+
<ColorPicker />
|
|
69
|
+
</FormItem>
|
|
70
|
+
|
|
71
|
+
<FormItem name={['theme', 'colorBgBase']} label="colorBgBase" normalize={value => value.toHexString()}>
|
|
72
|
+
<ColorPicker />
|
|
73
|
+
</FormItem>
|
|
74
|
+
|
|
75
|
+
<FormItem name={['theme', 'colorTextBase']} label="colorTextBase" normalize={value => value.toHexString()}>
|
|
76
|
+
<ColorPicker />
|
|
77
|
+
</FormItem>
|
|
78
|
+
|
|
79
|
+
<FormItem name={['theme', 'darkMode']} label="darkMode" >
|
|
80
|
+
<Switch />
|
|
81
|
+
</FormItem>
|
|
82
|
+
|
|
83
|
+
<FormItem name={['theme', 'leftHeader', 'logo']} label="leftHeader.logo" >
|
|
84
|
+
<Input />
|
|
85
|
+
</FormItem>
|
|
86
|
+
|
|
87
|
+
<FormItem name={['theme', 'leftHeader', 'title']} label="leftHeader.title" >
|
|
88
|
+
<Input />
|
|
89
|
+
</FormItem>
|
|
90
|
+
|
|
91
|
+
<Divider orientation="left">Sender</Divider>
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
<FormItem name={['sender', 'disclaimer']} label="disclaimer" >
|
|
95
|
+
<Input />
|
|
96
|
+
</FormItem>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
<FormItem name={['sender', 'attachments']} label="attachments" >
|
|
100
|
+
<Switch />
|
|
101
|
+
</FormItem>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
<FormItem name={['sender', 'maxLength']} label="maxLength" >
|
|
105
|
+
<InputNumber min={1000} />
|
|
106
|
+
</FormItem>
|
|
107
|
+
|
|
108
|
+
<Divider orientation="left">Welcome</Divider>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<FormItem name={['welcome', 'greeting']} label="greeting" >
|
|
112
|
+
<Input />
|
|
113
|
+
</FormItem>
|
|
114
|
+
|
|
115
|
+
<FormItem name={['welcome', 'description']} label="description" >
|
|
116
|
+
<Input />
|
|
117
|
+
</FormItem>
|
|
118
|
+
|
|
119
|
+
<FormItem name={['welcome', 'avatar']} label="avatar" >
|
|
120
|
+
<Input />
|
|
121
|
+
</FormItem>
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
<FormItem name={['welcome', 'prompts']} isList label="prompts" >
|
|
125
|
+
{(fields, { add, remove }) => {
|
|
126
|
+
return <div>
|
|
127
|
+
{fields.map(field => {
|
|
128
|
+
return <Flex key={field.key} gap={6}>
|
|
129
|
+
<Form.Item style={{ flex: 1 }} key={field.key} name={[field.name, 'value']}>
|
|
130
|
+
<Input />
|
|
131
|
+
</Form.Item>
|
|
132
|
+
<IconButton icon={<SparkPlusLine />} onClick={() => add({})}></IconButton>
|
|
133
|
+
<IconButton icon={<SparkDeleteLine />} onClick={() => remove(field.name)}></IconButton>
|
|
134
|
+
</Flex>
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
}}
|
|
138
|
+
</FormItem>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
<Divider orientation="left">API</Divider>
|
|
142
|
+
|
|
143
|
+
<FormItem name={['api', 'baseURL']} label="baseURL" >
|
|
144
|
+
<Input />
|
|
145
|
+
</FormItem>
|
|
146
|
+
|
|
147
|
+
<FormItem name={['api', 'token']} label="token" >
|
|
148
|
+
<Input />
|
|
149
|
+
</FormItem>
|
|
150
|
+
</Form>
|
|
151
|
+
|
|
152
|
+
<div className={styles.actions}>
|
|
153
|
+
<Button onClick={handleReset}>Reset</Button>
|
|
154
|
+
<Button type="primary" onClick={handleSave}>
|
|
155
|
+
Save & Copy
|
|
156
|
+
</Button>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export default OptionsEditor;
|
|
163
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return {
|
|
3
|
+
theme: {
|
|
4
|
+
colorPrimary: '#615CED',
|
|
5
|
+
darkMode: true,
|
|
6
|
+
prefix: 'agentscope-runtime-webui',
|
|
7
|
+
leftHeader: {
|
|
8
|
+
logo: 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
|
|
9
|
+
title: 'Runtime WebUI',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
sender: {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
attachments: true,
|
|
15
|
+
maxLength: 10000,
|
|
16
|
+
disclaimer:
|
|
17
|
+
'AI can also make mistakes, so please check carefully and use it with caution',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
welcome: {
|
|
21
|
+
greeting: 'Hello, how can I help you today?',
|
|
22
|
+
description:
|
|
23
|
+
'I am a helpful assistant that can help you with your questions.',
|
|
24
|
+
avatar:
|
|
25
|
+
'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
|
|
26
|
+
prompts: [
|
|
27
|
+
{
|
|
28
|
+
value: 'Hello',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: 'How are you?',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'What can you do?',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
api: {
|
|
39
|
+
baseURL: '',
|
|
40
|
+
token: '',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SparkSettingLine } from "@agentscope-ai/icons";
|
|
2
|
+
import { IconButton, Drawer } from "@agentscope-ai/design";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import OptionsEditor from "./OptionsEditor";
|
|
5
|
+
|
|
6
|
+
interface OptionsPanelProps {
|
|
7
|
+
value?: any;
|
|
8
|
+
onChange?: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function OptionsPanel(props: OptionsPanelProps) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
|
|
14
|
+
return <>
|
|
15
|
+
<IconButton onClick={() => setOpen(true)} icon={<SparkSettingLine />} bordered={false} />
|
|
16
|
+
<Drawer
|
|
17
|
+
destroyOnHidden
|
|
18
|
+
open={open}
|
|
19
|
+
onClose={() => setOpen(false)}
|
|
20
|
+
styles={{ body: { padding: 0 }, header: { padding: 8 } }}>
|
|
21
|
+
<OptionsEditor value={props.value} onChange={v => {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
props.onChange(v);
|
|
24
|
+
}} />
|
|
25
|
+
</Drawer>
|
|
26
|
+
</>
|
|
27
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AgentScopeRuntimeWebUI } from '@agentscope-ai/chat';
|
|
2
|
+
import OptionsPanel from './OptionsPanel';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import sessionApi from './sessionApi';
|
|
5
|
+
import defaultConfig from './OptionsPanel/defaultConfig';
|
|
6
|
+
import { useLocalStorageState } from 'ahooks';
|
|
7
|
+
|
|
8
|
+
export default function () {
|
|
9
|
+
|
|
10
|
+
const [optionsConfig, setOptionsConfig] = useLocalStorageState('agent-scope-runtime-webui-options', {
|
|
11
|
+
defaultValue: defaultConfig(),
|
|
12
|
+
listenStorageChange: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const options = useMemo(() => {
|
|
16
|
+
const rightHeader = <OptionsPanel value={optionsConfig} onChange={v => {
|
|
17
|
+
setOptionsConfig(prev => ({
|
|
18
|
+
...prev,
|
|
19
|
+
...v,
|
|
20
|
+
}));
|
|
21
|
+
}} />;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
...optionsConfig,
|
|
25
|
+
session: {
|
|
26
|
+
multiple: true,
|
|
27
|
+
api: sessionApi,
|
|
28
|
+
},
|
|
29
|
+
sender: {
|
|
30
|
+
...optionsConfig.sender,
|
|
31
|
+
attachments: optionsConfig.sender.attachments ? {
|
|
32
|
+
customRequest(options) {
|
|
33
|
+
// 模拟上传进度
|
|
34
|
+
options.onProgress({
|
|
35
|
+
percent: 100,
|
|
36
|
+
});
|
|
37
|
+
// 当前是一个 mock 的上传行为
|
|
38
|
+
// 实际情况需要具体实现一个文件上传服务,将文件转化为 url
|
|
39
|
+
options.onSuccess({
|
|
40
|
+
url: URL.createObjectURL(options.file as Blob)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} : undefined,
|
|
44
|
+
},
|
|
45
|
+
theme: {
|
|
46
|
+
...optionsConfig.theme,
|
|
47
|
+
rightHeader,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}, [optionsConfig]);
|
|
51
|
+
|
|
52
|
+
return <div style={{ height: '100dvh' }}>
|
|
53
|
+
<AgentScopeRuntimeWebUI
|
|
54
|
+
options={options}
|
|
55
|
+
/>
|
|
56
|
+
</div>;
|
|
57
|
+
}
|