Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.8.10 perf #2630

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: restart chat
  • Loading branch information
c121914yu committed Sep 6, 2024
commit 0401136f22587ddba809998d3b6353c6edf9a1d9
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
Loading