diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx index a1d68bbb5f3b..873c9b5f9528 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx @@ -97,14 +97,6 @@ type Props = OutLinkChatAuthProps & onDelMessage?: (e: { contentId: string }) => void; }; -/* - The input is divided into sections - 1. text - 2. img - 3. file - 4. .... -*/ - const ChatBox = ( { feedbackType = FeedbackTypeEnum.hidden, @@ -864,12 +856,6 @@ const ChatBox = ( abortRequest(); setValue('chatStarted', false); scrollToBottom('smooth', 500); - }, - scrollToBottom, - sendPrompt: (question: string) => { - sendPrompt({ - text: question - }); } })); diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/type.d.ts b/projects/app/src/components/core/chat/ChatContainer/ChatBox/type.d.ts index 2fdb28e9633c..3f7398c5f328 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/type.d.ts +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/type.d.ts @@ -39,6 +39,4 @@ export type SendPromptFnType = ( export type ComponentRef = { restartChat: () => void; - scrollToBottom: (behavior?: 'smooth' | 'auto') => void; - sendPrompt: (question: string) => void; }; diff --git a/projects/app/src/components/core/chat/ChatContainer/useChat.ts b/projects/app/src/components/core/chat/ChatContainer/useChat.ts index a7631937355a..124aebc56153 100644 --- a/projects/app/src/components/core/chat/ChatContainer/useChat.ts +++ b/projects/app/src/components/core/chat/ChatContainer/useChat.ts @@ -49,6 +49,7 @@ export const useChat = () => { ChatBoxRef.current?.restartChat?.(); }, [variablesForm]); + return { ChatBoxRef, chatRecords, diff --git a/projects/app/src/pages/app/detail/components/useChatTest.tsx b/projects/app/src/pages/app/detail/components/useChatTest.tsx index 7506ceeb2829..d7ca47d5bcab 100644 --- a/projects/app/src/pages/app/detail/components/useChatTest.tsx +++ b/projects/app/src/pages/app/detail/components/useChatTest.tsx @@ -1,5 +1,5 @@ import { useUserStore } from '@/web/support/user/useUserStore'; -import React from 'react'; +import React, { useMemo } from 'react'; import type { StartChatFnProps } from '@/components/core/chat/ChatContainer/type'; import { streamFetch } from '@/web/common/api/fetch'; import { getMaxHistoryLimitFromNodes } from '@fastgpt/global/core/workflow/runtime/utils'; @@ -14,9 +14,9 @@ import dynamic from 'next/dynamic'; import { useChat } from '@/components/core/chat/ChatContainer/useChat'; import { Box } from '@chakra-ui/react'; import { AppChatConfigType } from '@fastgpt/global/core/app/type'; +import ChatBox from '@/components/core/chat/ChatContainer/ChatBox'; const PluginRunBox = dynamic(() => import('@/components/core/chat/ChatContainer/PluginRunBox')); -const ChatBox = dynamic(() => import('@/components/core/chat/ChatContainer/ChatBox')); export const useChatTest = ({ nodes, @@ -56,8 +56,10 @@ export const useChatTest = ({ } ); - const pluginInputs = - nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || []; + const pluginInputs = useMemo(() => { + return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || []; + }, [nodes]); + const { ChatBoxRef, chatRecords,