This commit is contained in:
heheer 2025-12-22 16:37:19 +08:00
parent f93417e32b
commit 9bfacb9167
No known key found for this signature in database
GPG Key ID: 37DCB43201661540
15 changed files with 41 additions and 43 deletions

View File

@ -87,7 +87,7 @@ const QuoteList = React.memo(function QuoteList({
>
<QuoteItem
quoteItem={item}
canViewSource={canDownloadSource}
canDownloadSource={canDownloadSource}
canEditData={showRouteToDatasetDetail}
canEditDataset={showRouteToDatasetDetail}
{...RawSourceBoxProps}

View File

@ -49,14 +49,14 @@ const ResponseTags = ({
const chatTime = historyItem.time || new Date();
const durationSeconds = historyItem.durationSeconds || 0;
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isShowQuote);
const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite);
const {
totalQuoteList: quoteList = [],
llmModuleAccount = 0,
historyPreviewLength = 0,
toolCiteLinks = []
} = useMemo(() => {
if (!isResponseDetail)
if (!isShowCite)
return {
totalQuoteList: [],
llmModuleAccount: 0,
@ -64,16 +64,13 @@ const ResponseTags = ({
toolCiteLinks: []
};
return addStatisticalDataToHistoryItem(historyItem);
}, [historyItem, isResponseDetail]);
}, [historyItem, isShowCite]);
const [quoteFolded, setQuoteFolded] = useState<boolean>(true);
const chatType = useContextSelector(ChatBoxContext, (v) => v.chatType);
const notSharePage = useMemo(
() => chatType !== 'share' && isResponseDetail,
[chatType, isResponseDetail]
);
const notSharePage = useMemo(() => chatType !== 'share' && isShowCite, [chatType, isShowCite]);
const {
isOpen: isOpenWholeModal,
@ -92,7 +89,7 @@ const ResponseTags = ({
: true;
const citationRenderList: CitationRenderItem[] = useMemo(() => {
if (!isResponseDetail) return [];
if (!isShowCite) return [];
// Dataset citations
const datasetItems = Object.values(
quoteList.reduce((acc: Record<string, SearchDataResponseItemType[]>, cur) => {
@ -131,7 +128,7 @@ const ResponseTags = ({
}));
return [...datasetItems, ...linkItems];
}, [quoteList, toolCiteLinks, onOpenCiteModal, isResponseDetail]);
}, [quoteList, toolCiteLinks, onOpenCiteModal, isShowCite]);
const notEmptyTags = notSharePage || quoteList.length > 0 || (isPc && durationSeconds > 0);

View File

@ -106,16 +106,16 @@ 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 isShowQuote = useContextSelector(ChatItemContext, (v) => v.isShowQuote);
const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite);
const source = useMemo(() => {
if (!text) return '';
if (isShowQuote) {
if (isShowCite) {
return text;
}
return removeDatasetCiteText(text, isShowQuote);
}, [text, isShowQuote]);
return removeDatasetCiteText(text, isShowCite);
}, [text, isShowCite]);
const chatAuthData = useCreation(() => {
return { appId, chatId, chatItemDataId, ...outLinkAuthData };
@ -336,7 +336,7 @@ const AIResponseBox = ({
isChatting: boolean;
onOpenCiteModal?: (e?: OnOpenCiteModalProps) => void;
}) => {
const isShowQuote = useContextSelector(ChatItemContext, (v) => v.isShowQuote);
const showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus);
if (value.type === ChatItemValueTypeEnum.text && value.text) {
return (
@ -357,7 +357,7 @@ const AIResponseBox = ({
/>
);
}
if (value.type === ChatItemValueTypeEnum.tool && value.tools && isShowQuote) {
if (value.type === ChatItemValueTypeEnum.tool && value.tools && showRunningStatus) {
return <RenderTool showAnimation={isChatting} tools={value.tools} />;
}
if (value.type === ChatItemValueTypeEnum.interactive && value.interactive) {

View File

@ -91,13 +91,13 @@ export const formatScore = (score: ScoreItemType[]) => {
const QuoteItem = ({
quoteItem,
canViewSource,
canDownloadSource,
canEditData,
canEditDataset,
...RawSourceBoxProps
}: {
quoteItem: SearchDataResponseItemType;
canViewSource?: boolean;
canDownloadSource?: boolean;
canEditData?: boolean;
canEditDataset?: boolean;
} & Omit<readCollectionSourceBody, 'collectionId'>) => {
@ -208,7 +208,7 @@ const QuoteItem = ({
collectionId={quoteItem.collectionId}
sourceName={quoteItem.sourceName}
sourceId={quoteItem.sourceId}
canView={canViewSource}
canView={canDownloadSource}
{...RawSourceBoxProps}
/>
<Box flex={1} />

View File

@ -206,7 +206,7 @@ const Render = ({
<ChatItemContextProvider
showRouteToDatasetDetail={true}
canDownloadSource={true}
isShowQuote={true}
isShowCite={true}
isShowFullText={true}
showRunningStatus={true}
>

View File

@ -265,7 +265,7 @@ const Render = (props: Props) => {
<ChatItemContextProvider
showRouteToDatasetDetail={true}
canDownloadSource={true}
isShowQuote={true}
isShowCite={true}
isShowFullText={true}
showRunningStatus={true}
>

View File

@ -183,7 +183,7 @@ const Render = ({
<ChatItemContextProvider
showRouteToDatasetDetail={true}
canDownloadSource={true}
isShowQuote={true}
isShowCite={true}
isShowFullText={true}
showRunningStatus={true}
>

View File

@ -119,7 +119,7 @@ const Render = ({ appForm, setRenderEdit }: Props) => {
<ChatItemContextProvider
showRouteToDatasetDetail={true}
canDownloadSource={true}
isShowQuote={true}
isShowCite={true}
isShowFullText={true}
showRunningStatus={true}
>

View File

@ -207,7 +207,7 @@ const Render = (Props: Props) => {
<ChatItemContextProvider
showRouteToDatasetDetail={true}
canDownloadSource={true}
isShowQuote={true}
isShowCite={true}
isShowFullText={true}
showRunningStatus={true}
>

View File

@ -45,7 +45,7 @@ const AppChatWindow = ({ myApps }: Props) => {
const onUpdateHistoryTitle = useContextSelector(ChatContext, (v) => v.onUpdateHistoryTitle);
const isPlugin = useContextSelector(ChatItemContext, (v) => v.isPlugin);
const showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus);
const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite);
const onChangeChatId = useContextSelector(ChatContext, (v) => v.onChangeChatId);
const chatBoxData = useContextSelector(ChatItemContext, (v) => v.chatBoxData);
const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData);
@ -108,7 +108,7 @@ const AppChatWindow = ({ myApps }: Props) => {
responseChatItemId,
appId,
chatId,
retainDatasetCite: showRunningStatus
retainDatasetCite: isShowCite
},
abortCtrl: controller,
onMessage: generatingMessage
@ -124,7 +124,7 @@ const AppChatWindow = ({ myApps }: Props) => {
return { responseText, isNewChat: forbidLoadChat.current };
},
[appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, showRunningStatus]
[appId, chatId, onUpdateHistoryTitle, setChatBoxData, forbidLoadChat, isShowCite]
);
return (

View File

@ -84,7 +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 showRunningStatus = useContextSelector(ChatItemContext, (v) => v.showRunningStatus);
const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite);
const pane = useContextSelector(ChatSettingContext, (v) => v.pane);
const chatSettings = useContextSelector(ChatSettingContext, (v) => v.chatSettings);
@ -218,7 +218,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
responseChatItemId,
appId,
chatId,
retainDatasetCite: showRunningStatus
retainDatasetCite: isShowCite
},
abortCtrl: controller,
onMessage: generatingMessage
@ -266,7 +266,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
appId,
appName: t('chat:home.chat_app'),
chatId,
retainDatasetCite: showRunningStatus,
retainDatasetCite: isShowCite,
...form2AppWorkflow(formData, t)
},
onMessage: generatingMessage,
@ -397,7 +397,8 @@ const HomeChatWindow = ({ myApps }: Props) => {
setSelectedToolIds,
setChatBoxData,
isPc,
isQuickApp
isQuickApp,
isShowCite
]
);

View File

@ -449,7 +449,7 @@ const TestResults = React.memo(function TestResults({
<Box mt={1} gap={4}>
{datasetTestItem?.results.map((item, index) => (
<Box key={item.id} p={3} borderRadius={'lg'} bg={'myGray.100'} _notLast={{ mb: 2 }}>
<QuoteItem quoteItem={item} canViewSource canEditData />
<QuoteItem quoteItem={item} canDownloadSource canEditData />
</Box>
))}
</Box>

View File

@ -150,7 +150,7 @@ const Render = (props: {
showRouteToDatasetDetail={isStandalone !== '1'}
showRunningStatus={props.showRunningStatus}
canDownloadSource={props.canDownloadSource}
isShowQuote={props.showCite}
isShowCite={props.showCite}
isShowFullText={props.showFullText}
>
<ChatRecordContextProvider params={chatRecordProviderParams}>

View File

@ -54,7 +54,7 @@ type Props = {
authToken: string;
customUid: string;
canDownloadSource: boolean;
isShowQuote: boolean;
isShowCite: boolean;
isShowFullText: boolean;
showRunningStatus: boolean;
};
@ -95,7 +95,7 @@ const OutLink = (props: Props) => {
const setChatBoxData = useContextSelector(ChatItemContext, (v) => v.setChatBoxData);
const datasetCiteData = useContextSelector(ChatItemContext, (v) => v.datasetCiteData);
const setCiteModalData = useContextSelector(ChatItemContext, (v) => v.setCiteModalData);
const canDownloadSource = useContextSelector(ChatItemContext, (v) => v.canDownloadSource);
const isShowCite = useContextSelector(ChatItemContext, (v) => v.isShowCite);
const chatRecords = useContextSelector(ChatRecordContext, (v) => v.chatRecords);
const totalRecordsCount = useContextSelector(ChatRecordContext, (v) => v.totalRecordsCount);
@ -175,7 +175,7 @@ const OutLink = (props: Props) => {
responseChatItemId,
chatId: completionChatId,
...outLinkAuthData,
retainDatasetCite: canDownloadSource
retainDatasetCite: isShowCite
},
onMessage: generatingMessage,
abortCtrl: controller
@ -213,7 +213,7 @@ const OutLink = (props: Props) => {
chatId,
customVariables,
outLinkAuthData,
canDownloadSource,
isShowCite,
onUpdateHistoryTitle,
setChatBoxData,
forbidLoadChat,
@ -389,7 +389,7 @@ const Render = (props: Props) => {
<ChatItemContextProvider
showRouteToDatasetDetail={false}
canDownloadSource={props.canDownloadSource}
isShowQuote={props.isShowQuote}
isShowCite={props.isShowCite}
isShowFullText={props.isShowFullText}
showRunningStatus={props.showRunningStatus}
>
@ -433,7 +433,7 @@ export async function getServerSideProps(context: any) {
appAvatar: app?.associatedApp?.avatar ?? '',
appIntro: app?.associatedApp?.intro ?? 'AI',
canDownloadSource: app?.canDownloadSource ?? false,
isShowQuote: app?.showCite ?? false,
isShowCite: app?.showCite ?? false,
isShowFullText: app?.showFullText ?? false,
showRunningStatus: app?.showRunningStatus ?? false,
shareId: shareId ?? '',

View File

@ -14,7 +14,7 @@ import { type OutLinkChatAuthProps } from '@fastgpt/global/support/permission/ch
type ContextProps = {
showRouteToDatasetDetail: boolean;
canDownloadSource: boolean;
isShowQuote: boolean;
isShowCite: boolean;
isShowFullText: boolean;
showRunningStatus: boolean;
};
@ -121,7 +121,7 @@ const ChatItemContextProvider = ({
children,
showRouteToDatasetDetail,
canDownloadSource,
isShowQuote,
isShowCite,
isShowFullText,
showRunningStatus
}: {
@ -197,7 +197,7 @@ const ChatItemContextProvider = ({
clearChatRecords,
showRouteToDatasetDetail,
canDownloadSource,
isShowQuote,
isShowCite,
isShowFullText,
showRunningStatus,
@ -215,7 +215,7 @@ const ChatItemContextProvider = ({
clearChatRecords,
showRouteToDatasetDetail,
canDownloadSource,
isShowQuote,
isShowCite,
showRunningStatus,
isShowFullText,
datasetCiteData,