Skip to content

Commit

Permalink
fix: restart chat
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Sep 6, 2024
1 parent 5446ae7 commit 0401136
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -864,12 +856,6 @@ const ChatBox = (
abortRequest();
setValue('chatStarted', false);
scrollToBottom('smooth', 500);
},
scrollToBottom,
sendPrompt: (question: string) => {
sendPrompt({
text: question
});
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ export type SendPromptFnType = (

export type ComponentRef = {
restartChat: () => void;
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
sendPrompt: (question: string) => void;
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const useChat = () => {

ChatBoxRef.current?.restartChat?.();
}, [variablesForm]);

return {
ChatBoxRef,
chatRecords,
Expand Down
10 changes: 6 additions & 4 deletions projects/app/src/pages/app/detail/components/useChatTest.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0401136

Please sign in to comment.