From c1d71e9a3fa06b468a8bd89311b51edbe23893f7 Mon Sep 17 00:00:00 2001 From: balibabu Date: Thu, 6 Feb 2025 11:41:02 +0800 Subject: [PATCH] Fix: New user can't accept invite without configuring LLM API #4379 (#4736) ### What problem does this PR solve? Fix: New user can't accept invite without configuring LLM API #4379 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/hooks/logic-hooks.ts | 2 +- web/src/hooks/user-setting-hooks.tsx | 11 ++++++++--- .../chat-configuration-modal/assistant-setting.tsx | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/web/src/hooks/logic-hooks.ts b/web/src/hooks/logic-hooks.ts index 97f6f0f8a..edc2e89a0 100644 --- a/web/src/hooks/logic-hooks.ts +++ b/web/src/hooks/logic-hooks.ts @@ -508,7 +508,7 @@ export const useSelectItem = (defaultId?: string) => { }; export const useFetchModelId = () => { - const { data: tenantInfo } = useFetchTenantInfo(); + const { data: tenantInfo } = useFetchTenantInfo(true); return tenantInfo?.llm_id ?? ''; }; diff --git a/web/src/hooks/user-setting-hooks.tsx b/web/src/hooks/user-setting-hooks.tsx index 2f19cb9c8..6c608a1bc 100644 --- a/web/src/hooks/user-setting-hooks.tsx +++ b/web/src/hooks/user-setting-hooks.tsx @@ -46,7 +46,9 @@ export const useFetchUserInfo = (): ResponseGetType => { return { data, loading }; }; -export const useFetchTenantInfo = (): ResponseGetType => { +export const useFetchTenantInfo = ( + showEmptyModelWarn = false, +): ResponseGetType => { const { t } = useTranslation(); const { data, isFetching: loading } = useQuery({ queryKey: ['tenantInfo'], @@ -58,7 +60,10 @@ export const useFetchTenantInfo = (): ResponseGetType => { // llm_id is chat_id // asr_id is speech2txt const { data } = res; - if (isEmpty(data.embd_id) || isEmpty(data.llm_id)) { + if ( + showEmptyModelWarn && + (isEmpty(data.embd_id) || isEmpty(data.llm_id)) + ) { Modal.warning({ title: t('common.warn'), content: ( @@ -90,7 +95,7 @@ export const useSelectParserList = (): Array<{ value: string; label: string; }> => { - const { data: tenantInfo } = useFetchTenantInfo(); + const { data: tenantInfo } = useFetchTenantInfo(true); const parserList = useMemo(() => { const parserArray: Array = tenantInfo?.parser_ids?.split(',') ?? []; diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index 081e78da2..6ffccd3bf 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -11,7 +11,7 @@ import styles from './index.less'; const AssistantSetting = ({ show, form }: ISegmentedContentProps) => { const { t } = useTranslate('chat'); - const { data } = useFetchTenantInfo(); + const { data } = useFetchTenantInfo(true); const normFile = (e: any) => { if (Array.isArray(e)) {