mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-18 21:57:27 +08:00
Revert "Refactor: dataset / kb API to RESTFul style" (#13646)
Reverts infiniflow/ragflow#13619
This commit is contained in:
@@ -45,7 +45,7 @@ export function ChunkMethodForm() {
|
||||
|
||||
const finalParserId: DocumentParserType = useWatch({
|
||||
control: form.control,
|
||||
name: 'chunk_method',
|
||||
name: 'parser_id',
|
||||
});
|
||||
|
||||
const ConfigurationComponent = useMemo(() => {
|
||||
|
||||
@@ -69,7 +69,7 @@ export function ChunkMethodItem(props: IProps) {
|
||||
return (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'chunk_method'}
|
||||
name={'parser_id'}
|
||||
render={({ field }) => (
|
||||
<FormItem className=" items-center space-y-1">
|
||||
<div className={line === 1 ? 'flex items-center' : ''}>
|
||||
@@ -121,7 +121,7 @@ export const EmbeddingSelect = ({
|
||||
const { handleChange } = useHandleKbEmbedding();
|
||||
|
||||
const oldValue = useMemo(() => {
|
||||
const embdStr = form.getValues(name || 'embedding_model');
|
||||
const embdStr = form.getValues(name || 'embd_id');
|
||||
return embdStr || '';
|
||||
}, [form]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -165,7 +165,7 @@ export function EmbeddingModelItem({ line = 1, isEdit }: IProps) {
|
||||
<>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'embedding_model'}
|
||||
name={'embd_id'}
|
||||
render={({ field }) => (
|
||||
<FormItem className={cn(' items-center space-y-0 ')}>
|
||||
<div
|
||||
|
||||
@@ -14,11 +14,11 @@ export const formSchema = z
|
||||
avatar: z.any().nullish(),
|
||||
permission: z.string().optional(),
|
||||
language: z.string().optional(),
|
||||
chunk_method: z.string(),
|
||||
parser_id: z.string(),
|
||||
pipeline_id: z.string().optional(),
|
||||
pipeline_name: z.string().optional(),
|
||||
pipeline_avatar: z.string().optional(),
|
||||
embedding_model: z.string(),
|
||||
embd_id: z.string(),
|
||||
parser_config: z
|
||||
.object({
|
||||
layout_recognize: z.string(),
|
||||
|
||||
@@ -31,7 +31,7 @@ export function useHasParsedDocument(isEdit?: boolean) {
|
||||
const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration({
|
||||
isEdit,
|
||||
});
|
||||
return knowledgeDetails.chunk_count > 0;
|
||||
return knowledgeDetails.chunk_num > 0;
|
||||
}
|
||||
|
||||
export const useFetchKnowledgeConfigurationOnMount = (
|
||||
@@ -60,14 +60,14 @@ export const useFetchKnowledgeConfigurationOnMount = (
|
||||
'description',
|
||||
'name',
|
||||
'permission',
|
||||
'embd_id',
|
||||
'parser_id',
|
||||
'language',
|
||||
'parser_config',
|
||||
'connectors',
|
||||
'pagerank',
|
||||
'avatar',
|
||||
]),
|
||||
embedding_model: knowledgeDetails.embd_id,
|
||||
chunk_method: knowledgeDetails.parser_id,
|
||||
} as z.infer<typeof formSchema>;
|
||||
form.reset(formValues);
|
||||
}, [form, knowledgeDetails]);
|
||||
|
||||
@@ -219,7 +219,7 @@ export default function DatasetSettings() {
|
||||
defaultValue: knowledgeDetails.pipeline_id ? 2 : 1,
|
||||
});
|
||||
const selectedTag = useWatch({
|
||||
name: 'chunk_method',
|
||||
name: 'parser_id',
|
||||
control: form.control,
|
||||
});
|
||||
useEffect(() => {
|
||||
|
||||
@@ -16,7 +16,7 @@ export function GeneralSavingButton() {
|
||||
() => form.formState.defaultValues ?? {},
|
||||
[form.formState.defaultValues],
|
||||
);
|
||||
const chunk_method = defaultValues['chunk_method'];
|
||||
const parser_id = defaultValues['parser_id'];
|
||||
|
||||
return (
|
||||
<ButtonLoading
|
||||
@@ -31,7 +31,7 @@ export function GeneralSavingButton() {
|
||||
if (isValidate) {
|
||||
saveKnowledgeConfiguration({
|
||||
kb_id,
|
||||
chunk_method,
|
||||
parser_id,
|
||||
name,
|
||||
description,
|
||||
avatar,
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import message from '@/components/ui/message';
|
||||
import agentService from '@/services/agent-service';
|
||||
import {
|
||||
deletePipelineTask,
|
||||
runGraphRag,
|
||||
runRaptor,
|
||||
traceGraphRag,
|
||||
traceRaptor,
|
||||
} from '@/services/knowledge-service';
|
||||
import kbService, { deletePipelineTask } from '@/services/knowledge-service';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { t } from 'i18next';
|
||||
import { useEffect, useState } from 'react';
|
||||
@@ -59,7 +53,9 @@ export const useTraceGenerate = ({ open }: { open: boolean }) => {
|
||||
retryDelay: 1000,
|
||||
enabled: open,
|
||||
queryFn: async () => {
|
||||
const { data } = await traceGraphRag(id);
|
||||
const { data } = await kbService.traceGraphRag({
|
||||
kb_id: id,
|
||||
});
|
||||
return data?.data || {};
|
||||
},
|
||||
});
|
||||
@@ -74,7 +70,9 @@ export const useTraceGenerate = ({ open }: { open: boolean }) => {
|
||||
retryDelay: 1000,
|
||||
enabled: open,
|
||||
queryFn: async () => {
|
||||
const { data } = await traceRaptor(id);
|
||||
const { data } = await kbService.traceRaptor({
|
||||
kb_id: id,
|
||||
});
|
||||
return data?.data || {};
|
||||
},
|
||||
});
|
||||
@@ -135,8 +133,12 @@ export const useDatasetGenerate = () => {
|
||||
mutationKey: [DatasetKey.generate],
|
||||
mutationFn: async ({ type }: { type: GenerateType }) => {
|
||||
const func =
|
||||
type === GenerateType.KnowledgeGraph ? runGraphRag : runRaptor;
|
||||
const { data } = await func(id);
|
||||
type === GenerateType.KnowledgeGraph
|
||||
? kbService.runGraphRag
|
||||
: kbService.runRaptor;
|
||||
const { data } = await func({
|
||||
kb_id: id,
|
||||
});
|
||||
if (data.code === 0) {
|
||||
message.success(t('message.operated'));
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -23,7 +23,7 @@ export function DatasetCard({
|
||||
<HomeCard
|
||||
data={{
|
||||
...dataset,
|
||||
description: `${dataset.document_count} ${t('knowledgeDetails.files')}`,
|
||||
description: `${dataset.doc_num} ${t('knowledgeDetails.files')}`,
|
||||
}}
|
||||
moreDropdown={
|
||||
<DatasetDropdown
|
||||
|
||||
@@ -46,20 +46,20 @@ export function InputForm({ onOk }: IModalProps<any>) {
|
||||
})
|
||||
.trim(),
|
||||
parseType: z.number().optional(),
|
||||
embedding_model: z
|
||||
embd_id: z
|
||||
.string()
|
||||
.min(1, {
|
||||
message: t('knowledgeConfiguration.embeddingModelPlaceholder'),
|
||||
})
|
||||
.trim(),
|
||||
chunk_method: z.string().optional(),
|
||||
parser_id: z.string().optional(),
|
||||
pipeline_id: z.string().optional(),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
// When parseType === 1, chunk_method is required
|
||||
// When parseType === 1, parser_id is required
|
||||
if (
|
||||
data.parseType === 1 &&
|
||||
(!data.chunk_method || data.chunk_method.trim() === '')
|
||||
(!data.parser_id || data.parser_id.trim() === '')
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
@@ -82,8 +82,8 @@ export function InputForm({ onOk }: IModalProps<any>) {
|
||||
defaultValues: {
|
||||
name: '',
|
||||
parseType: 1,
|
||||
chunk_method: '',
|
||||
embedding_model: tenantInfo?.embd_id,
|
||||
parser_id: '',
|
||||
embd_id: tenantInfo?.embd_id,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -16,14 +16,8 @@ export const useSearchKnowledge = () => {
|
||||
|
||||
export interface Iknowledge {
|
||||
name: string;
|
||||
embedding_model?: string;
|
||||
chunk_method?: string;
|
||||
parseType?: number;
|
||||
pipeline_id?: string | null;
|
||||
ext?: {
|
||||
language?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
embd_id: string;
|
||||
parser_id: string;
|
||||
}
|
||||
export const useSaveKnowledge = () => {
|
||||
const { visible: visible, hideModal, showModal } = useSetModalState();
|
||||
@@ -36,7 +30,7 @@ export const useSaveKnowledge = () => {
|
||||
|
||||
if (ret?.code === 0) {
|
||||
hideModal();
|
||||
navigateToDataset(ret.data.id)();
|
||||
navigateToDataset(ret.data.kb_id)();
|
||||
}
|
||||
},
|
||||
[createKnowledge, hideModal, navigateToDataset],
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function Datasets() {
|
||||
|
||||
const {
|
||||
kbs,
|
||||
total_datasets,
|
||||
total,
|
||||
pagination,
|
||||
setPagination,
|
||||
handleInputChange,
|
||||
@@ -107,7 +107,7 @@ export default function Datasets() {
|
||||
<footer className="mt-4 px-5 pb-5">
|
||||
<RAGFlowPagination
|
||||
{...pick(pagination, 'current', 'pageSize')}
|
||||
total={total_datasets}
|
||||
total={total}
|
||||
onChange={handlePageChange}
|
||||
/>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user