mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-08 12:24:48 +08:00
### What problem does this PR solve? Fix: When adding a chat in the main interface, a warning will automatically pop up (even if embedding and LLM model have already been configured). ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Modal } from '@/components/ui/modal/modal';
|
|
import DOMPurify from 'dompurify';
|
|
import { isEmpty } from 'lodash';
|
|
import { useEffect, useRef } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useNavigatePage } from './logic-hooks/navigate-hooks';
|
|
|
|
export const useWarnEmptyModel = (
|
|
showEmptyModelWarn: boolean,
|
|
embdId?: string,
|
|
llmId?: string,
|
|
loading?: boolean,
|
|
) => {
|
|
const { t } = useTranslation();
|
|
const warnedRef = useRef(false);
|
|
const { navigateToModelSetting } = useNavigatePage();
|
|
|
|
useEffect(() => {
|
|
if (
|
|
showEmptyModelWarn &&
|
|
!warnedRef.current &&
|
|
!loading &&
|
|
(isEmpty(embdId) || isEmpty(llmId)) &&
|
|
typeof embdId === 'string' &&
|
|
typeof llmId === 'string'
|
|
) {
|
|
warnedRef.current = true;
|
|
Modal.warning({
|
|
title: t('common.warn'),
|
|
content: (
|
|
<div
|
|
dangerouslySetInnerHTML={{
|
|
__html: DOMPurify.sanitize(t('setting.modelProvidersWarn')),
|
|
}}
|
|
></div>
|
|
),
|
|
closable: false,
|
|
showCancel: false,
|
|
onOk() {
|
|
navigateToModelSetting();
|
|
},
|
|
});
|
|
}
|
|
}, [showEmptyModelWarn, embdId, llmId, loading, navigateToModelSetting, t]);
|
|
};
|