From ded0383ac4e4d0c1031eee25ac1c77961eab7f84 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 30 May 2025 17:02:49 +0800 Subject: [PATCH] perf: gate --- packages/global/core/app/utils.ts | 6 ++- .../ChatContainer/ChatBox/Input/ChatInput.tsx | 5 +- .../ChatBox/Input/GateChatInput.tsx | 49 ++++--------------- .../ChatBox/Input/VoiceInput.tsx | 4 +- .../account/gateway/ConfigButtons.tsx | 45 ++++++++++++++++- .../account/gateway/GateAppInfoModal.tsx | 3 ++ .../pageComponents/app/detail/useChatGate.tsx | 2 +- projects/app/src/pages/api/core/chat/init.ts | 9 +++- projects/app/src/pages/chat/gate/index.tsx | 16 +++--- 9 files changed, 80 insertions(+), 59 deletions(-) diff --git a/packages/global/core/app/utils.ts b/packages/global/core/app/utils.ts index e841941c4..7dbfc146d 100644 --- a/packages/global/core/app/utils.ts +++ b/packages/global/core/app/utils.ts @@ -46,7 +46,7 @@ export const appWorkflow2Form = ({ chatConfig }: { nodes: StoreNodeItemType[]; - chatConfig: AppChatConfigType; + chatConfig?: AppChatConfigType; }) => { const defaultAppForm = getDefaultAppForm(); const findInputValueByKey = (inputs: FlowNodeInputItemType[], key: string) => { @@ -172,6 +172,10 @@ export const appWorkflow2Form = ({ } }); + if (chatConfig) { + defaultAppForm.chatConfig = chatConfig; + } + return defaultAppForm; }; diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx index 5bdd38225..ec606930d 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx @@ -281,7 +281,7 @@ const ChatInput = ({ [ File, TextareaDom, - fileList, + fileList.length, handleSend, hasFileUploading, havInput, @@ -296,7 +296,8 @@ const ChatInput = ({ setValue, showSelectFile, showSelectImg, - t + t, + whisperConfig?.open ] ); diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/GateChatInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/GateChatInput.tsx index a81e2c6a3..c17af2895 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/GateChatInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/GateChatInput.tsx @@ -83,7 +83,6 @@ const GateChatInput = ({ const selectedTools = externalSelectedToolIds ?? []; const setSelectedToolIds = onSelectTools!; - const { appDetail } = useContextSelector(AppContext, (v) => v); const { llmModelList } = useSystemStore(); const modelList = useMemo( () => llmModelList.map((item) => ({ label: item.name, value: item.model })), @@ -101,36 +100,6 @@ const GateChatInput = ({ return router.pathname === '/chat/gate'; }, [router.pathname]); - // 初始化加载appForm - 从Gate应用获取配置 - useEffect(() => { - if (!appId || !showTools) return; - - const fetchAppForm = async () => { - try { - // 加载Gate应用列表 - // 获取当前应用或第一个可用的Gate应用 - const currentApp = appDetail; - - if (currentApp && currentApp.modules) { - // 将模块转换为appForm格式 - const form = appWorkflow2Form({ - nodes: currentApp.modules, - chatConfig: currentApp.chatConfig || {} - }); - setAppForm(form); - // 如果选择了模型,设置为默认模型 - if (form.aiSettings.model) { - setSelectedModel(form.aiSettings.model); - } - } - } catch (error) { - console.error('加载Gate应用信息失败:', error); - } - }; - - fetchAppForm(); - }, [appId, showTools, appDetail, setAppForm]); - // 当模型选择变化时更新appForm useEffect(() => { if (!showTools) return; @@ -230,15 +199,6 @@ const GateChatInput = ({ - {/* voice input and loading container */} - {!inputValue && ( - - )} -