mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-14 04:36:52 +08:00
Co-authored-by: chanx <1243304602@qq.com>
This commit is contained in:
@@ -41,8 +41,7 @@ import {
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useCallback, useMemo, useState, useSyncExternalStore } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useWarnEmptyModel } from './use-warn-empty-model';
|
||||
import { useFetchDefaultModelDictionary } from './use-llm-request';
|
||||
|
||||
export const enum UserSettingApiAction {
|
||||
UserInfo = 'userInfo',
|
||||
@@ -88,40 +87,30 @@ export const useFetchUserInfo = (): ResponseGetType<IUserInfo> => {
|
||||
return { data, loading };
|
||||
};
|
||||
|
||||
// Stop using this interface to retrieve the default model; instead, directly call `useFetchDefaultModelDictionary`.
|
||||
export const useFetchTenantInfo = (
|
||||
showEmptyModelWarn = false,
|
||||
): ResponseGetType<ITenantInfo> => {
|
||||
export const useFetchTenantData = (): ResponseGetType<ITenantInfo> => {
|
||||
const { data, isFetching: loading } = useQuery({
|
||||
queryKey: [UserSettingApiAction.TenantInfo, showEmptyModelWarn],
|
||||
queryKey: [UserSettingApiAction.TenantInfo],
|
||||
initialData: {},
|
||||
gcTime: 0,
|
||||
queryFn: async () => {
|
||||
const { data: res } = await userService.getTenantInfo();
|
||||
if (res.code === 0) {
|
||||
// llm_id is chat_id
|
||||
// asr_id is speech2txt
|
||||
const { data } = res;
|
||||
data.chat_id = data.llm_id;
|
||||
data.speech2text_id = data.asr_id;
|
||||
|
||||
return data;
|
||||
return res.data ?? {};
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
});
|
||||
|
||||
useWarnEmptyModel(showEmptyModelWarn, data?.embd_id, data?.llm_id, loading);
|
||||
|
||||
return { data, loading };
|
||||
};
|
||||
|
||||
export const useFetchTenantInfo = useFetchTenantData;
|
||||
|
||||
export const useSelectParserList = (): Array<{
|
||||
value: string;
|
||||
label: string;
|
||||
}> => {
|
||||
const { data: tenantInfo } = useFetchTenantInfo(true);
|
||||
const { data: tenantInfo } = useFetchTenantInfo();
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Detect backend runtime language (Go vs Python) so we can choose
|
||||
@@ -144,6 +133,7 @@ export const useSelectParserList = (): Array<{
|
||||
staleTime: Infinity,
|
||||
enabled: backendLang === 'go',
|
||||
});
|
||||
useFetchDefaultModelDictionary(true);
|
||||
|
||||
const defaultParsers = useMemo(
|
||||
() => [
|
||||
|
||||
@@ -147,25 +147,10 @@ export interface IKnowledgeFile {
|
||||
}
|
||||
|
||||
export interface ITenantInfo {
|
||||
asr_id: string;
|
||||
embd_id: string;
|
||||
img2txt_id: string;
|
||||
llm_id: string;
|
||||
name: string;
|
||||
parser_ids: string;
|
||||
role: string;
|
||||
tenant_id: string;
|
||||
chat_id: string;
|
||||
speech2text_id: string;
|
||||
rerank_id?: string;
|
||||
tts_id: string;
|
||||
// Tenant model IDs
|
||||
tenant_asr_id?: string;
|
||||
tenant_embd_id?: string;
|
||||
tenant_img2txt_id?: string;
|
||||
tenant_llm_id?: string;
|
||||
tenant_rerank_id?: string;
|
||||
tenant_tts_id?: string;
|
||||
}
|
||||
|
||||
export type ChunkDocType = 'image' | 'table' | 'text';
|
||||
|
||||
Reference in New Issue
Block a user