Files
ragflow/web/src/hooks/use-warn-empty-model.tsx
Lynn dc4b82523b Feat: tenant llm provider (#14595)
### What problem does this PR solve?

Python implementation of the Go-based model_provider API suite.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: bill <yibie_jingnian@163.com>
2026-05-29 17:39:41 +08:00

44 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,
) => {
const { t } = useTranslation();
const warnedRef = useRef(false);
const { navigateToModelSetting } = useNavigatePage();
useEffect(() => {
if (
showEmptyModelWarn &&
!warnedRef.current &&
(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, navigateToModelSetting, t]);
};