mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
frontend filter
This commit is contained in:
parent
2901ad548a
commit
142f00139b
|
|
@ -14,6 +14,7 @@ import { addStatisticalDataToHistoryItem } from '@/global/core/chat/utils';
|
|||
import { useSize } from 'ahooks';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
|
||||
|
||||
export type CitationRenderItem = {
|
||||
type: 'dataset' | 'link';
|
||||
|
|
@ -48,18 +49,31 @@ const ResponseTags = ({
|
|||
|
||||
const chatTime = historyItem.time || new Date();
|
||||
const durationSeconds = historyItem.durationSeconds || 0;
|
||||
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
|
||||
const {
|
||||
totalQuoteList: quoteList = [],
|
||||
llmModuleAccount = 0,
|
||||
historyPreviewLength = 0,
|
||||
toolCiteLinks = []
|
||||
} = useMemo(() => addStatisticalDataToHistoryItem(historyItem), [historyItem]);
|
||||
} = useMemo(() => {
|
||||
if (!isResponseDetail)
|
||||
return {
|
||||
totalQuoteList: [],
|
||||
llmModuleAccount: 0,
|
||||
historyPreviewLength: 0,
|
||||
toolCiteLinks: []
|
||||
};
|
||||
return addStatisticalDataToHistoryItem(historyItem);
|
||||
}, [historyItem, isResponseDetail]);
|
||||
|
||||
const [quoteFolded, setQuoteFolded] = useState<boolean>(true);
|
||||
|
||||
const chatType = useContextSelector(ChatBoxContext, (v) => v.chatType);
|
||||
|
||||
const notSharePage = useMemo(() => chatType !== 'share', [chatType]);
|
||||
const notSharePage = useMemo(
|
||||
() => chatType !== 'share' && isResponseDetail,
|
||||
[chatType, isResponseDetail]
|
||||
);
|
||||
|
||||
const {
|
||||
isOpen: isOpenWholeModal,
|
||||
|
|
@ -78,6 +92,7 @@ const ResponseTags = ({
|
|||
: true;
|
||||
|
||||
const citationRenderList: CitationRenderItem[] = useMemo(() => {
|
||||
if (!isResponseDetail) return [];
|
||||
// Dataset citations
|
||||
const datasetItems = Object.values(
|
||||
quoteList.reduce((acc: Record<string, SearchDataResponseItemType[]>, cur) => {
|
||||
|
|
@ -116,7 +131,7 @@ const ResponseTags = ({
|
|||
}));
|
||||
|
||||
return [...datasetItems, ...linkItems];
|
||||
}, [quoteList, toolCiteLinks, onOpenCiteModal]);
|
||||
}, [quoteList, toolCiteLinks, onOpenCiteModal, isResponseDetail]);
|
||||
|
||||
const notEmptyTags = notSharePage || quoteList.length > 0 || (isPc && durationSeconds > 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,13 @@ import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
|
|||
import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents';
|
||||
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { type OnOpenCiteModalProps } from '@/web/core/chat/context/chatItemContext';
|
||||
import {
|
||||
type OnOpenCiteModalProps,
|
||||
ChatItemContext
|
||||
} from '@/web/core/chat/context/chatItemContext';
|
||||
import { WorkflowRuntimeContext } from '../ChatContainer/context/workflowRuntimeContext';
|
||||
import { useCreation } from 'ahooks';
|
||||
import { removeDatasetCiteText } from '@fastgpt/global/core/ai/llm/utils';
|
||||
|
||||
const accordionButtonStyle = {
|
||||
w: 'auto',
|
||||
|
|
@ -102,13 +106,13 @@ const RenderText = React.memo(function RenderText({
|
|||
const appId = useContextSelector(WorkflowRuntimeContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowRuntimeContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowRuntimeContext, (v) => v.outLinkAuthData);
|
||||
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
|
||||
|
||||
const source = useMemo(() => {
|
||||
if (!text) return '';
|
||||
|
||||
// Remove quote references if not showing response detail
|
||||
return text;
|
||||
}, [text]);
|
||||
return removeDatasetCiteText(text, isResponseDetail);
|
||||
}, [text, isResponseDetail]);
|
||||
|
||||
const chatAuthData = useCreation(() => {
|
||||
return { appId, chatId, chatItemDataId, ...outLinkAuthData };
|
||||
|
|
@ -329,6 +333,8 @@ const AIResponseBox = ({
|
|||
isChatting: boolean;
|
||||
onOpenCiteModal?: (e?: OnOpenCiteModalProps) => void;
|
||||
}) => {
|
||||
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
|
||||
|
||||
if (value.type === ChatItemValueTypeEnum.text && value.text) {
|
||||
return (
|
||||
<RenderText
|
||||
|
|
@ -348,7 +354,7 @@ const AIResponseBox = ({
|
|||
/>
|
||||
);
|
||||
}
|
||||
if (value.type === ChatItemValueTypeEnum.tool && value.tools) {
|
||||
if (value.type === ChatItemValueTypeEnum.tool && value.tools && isResponseDetail) {
|
||||
return <RenderTool showAnimation={isChatting} tools={value.tools} />;
|
||||
}
|
||||
if (value.type === ChatItemValueTypeEnum.interactive && value.interactive) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ const AppChatWindow = ({ myApps }: Props) => {
|
|||
const onUpdateHistoryTitle = useContextSelector(ChatContext, (v) => v.onUpdateHistoryTitle);
|
||||
|
||||
const isPlugin = useContextSelector(ChatItemContext, (v) => v.isPlugin);
|
||||
const showNodeStatus = useContextSelector(ChatItemContext, (v) => v.showNodeStatus);
|
||||
const onChangeChatId = useContextSelector(ChatContext, (v) => v.onChangeChatId);
|
||||
const chatBoxData = useContextSelector(ChatItemContext, (v) => v.chatBoxData);
|
||||
const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData);
|
||||
|
|
@ -106,7 +107,8 @@ const AppChatWindow = ({ myApps }: Props) => {
|
|||
variables,
|
||||
responseChatItemId,
|
||||
appId,
|
||||
chatId
|
||||
chatId,
|
||||
retainDatasetCite: showNodeStatus
|
||||
},
|
||||
abortCtrl: controller,
|
||||
onMessage: generatingMessage
|
||||
|
|
@ -122,7 +124,7 @@ const AppChatWindow = ({ myApps }: Props) => {
|
|||
|
||||
return { responseText, isNewChat: forbidLoadChat.current };
|
||||
},
|
||||
[appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat]
|
||||
[appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, showNodeStatus]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
|
|||
const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData);
|
||||
const setChatBoxData = useContextSelector(ChatItemContext, (v) => v.setChatBoxData);
|
||||
const resetVariables = useContextSelector(ChatItemContext, (v) => v.resetVariables);
|
||||
const showNodeStatus = useContextSelector(ChatItemContext, (v) => v.showNodeStatus);
|
||||
|
||||
const pane = useContextSelector(ChatSettingContext, (v) => v.pane);
|
||||
const chatSettings = useContextSelector(ChatSettingContext, (v) => v.chatSettings);
|
||||
|
|
@ -216,7 +217,8 @@ const HomeChatWindow = ({ myApps }: Props) => {
|
|||
variables,
|
||||
responseChatItemId,
|
||||
appId,
|
||||
chatId
|
||||
chatId,
|
||||
retainDatasetCite: showNodeStatus
|
||||
},
|
||||
abortCtrl: controller,
|
||||
onMessage: generatingMessage
|
||||
|
|
@ -264,6 +266,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
|
|||
appId,
|
||||
appName: t('chat:home.chat_app'),
|
||||
chatId,
|
||||
retainDatasetCite: showNodeStatus,
|
||||
...form2AppWorkflow(formData, t)
|
||||
},
|
||||
onMessage: generatingMessage,
|
||||
|
|
|
|||
Loading…
Reference in New Issue