mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-21 21:36:42 +08:00
### What problem does this PR solve? Feat: Add LangfuseCard component. #6155 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -2,12 +2,14 @@ import { LanguageTranslationMap } from '@/constants/common';
|
||||
import { ResponseGetType } from '@/interfaces/database/base';
|
||||
import { IToken } from '@/interfaces/database/chat';
|
||||
import { ITenantInfo } from '@/interfaces/database/knowledge';
|
||||
import { ILangfuseConfig } from '@/interfaces/database/system';
|
||||
import {
|
||||
ISystemStatus,
|
||||
ITenant,
|
||||
ITenantUser,
|
||||
IUserInfo,
|
||||
} from '@/interfaces/database/user-setting';
|
||||
import { ISetLangfuseConfigRequestBody } from '@/interfaces/request/system';
|
||||
import userService, {
|
||||
addTenantUser,
|
||||
agreeTenant,
|
||||
@ -375,3 +377,57 @@ export const useAgreeTenant = () => {
|
||||
|
||||
return { data, loading, agreeTenant: mutateAsync };
|
||||
};
|
||||
|
||||
export const useSetLangfuseConfig = () => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: ['setLangfuseConfig'],
|
||||
mutationFn: async (params: ISetLangfuseConfigRequestBody) => {
|
||||
const { data } = await userService.setLangfuseConfig(params);
|
||||
if (data.code === 0) {
|
||||
message.success(t('message.operated'));
|
||||
}
|
||||
return data?.code;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, setLangfuseConfig: mutateAsync };
|
||||
};
|
||||
|
||||
export const useDeleteLangfuseConfig = () => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: ['deleteLangfuseConfig'],
|
||||
mutationFn: async () => {
|
||||
const { data } = await userService.deleteLangfuseConfig();
|
||||
if (data.code === 0) {
|
||||
message.success(t('message.deleted'));
|
||||
}
|
||||
return data?.code;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, deleteLangfuseConfig: mutateAsync };
|
||||
};
|
||||
|
||||
export const useFetchLangfuseConfig = () => {
|
||||
const { data, isFetching: loading } = useQuery<ILangfuseConfig>({
|
||||
queryKey: ['fetchLangfuseConfig'],
|
||||
gcTime: 0,
|
||||
queryFn: async () => {
|
||||
const { data } = await userService.getLangfuseConfig();
|
||||
|
||||
return data?.data;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user