Feat: Files uploaded via the dialog box can be uploaded without binding to a dataset. #9590 (#11630)

### What problem does this PR solve?

Feat: Files uploaded via the dialog box can be uploaded without binding
to a dataset. #9590

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-12-01 16:29:02 +08:00
committed by GitHub
parent 221947acc4
commit 1120575021
11 changed files with 60 additions and 466 deletions

View File

@ -6,7 +6,6 @@ import {
IDocumentMetaRequestBody,
} from '@/interfaces/request/document';
import i18n from '@/locales/config';
import chatService from '@/services/chat-service';
import kbService, { listDocument } from '@/services/knowledge-service';
import api, { api_host } from '@/utils/api';
import { buildChunkHighlights } from '@/utils/document-util';
@ -428,39 +427,6 @@ export const useDeleteDocument = () => {
return { data, loading, deleteDocument: mutateAsync };
};
export const useUploadAndParseDocument = (uploadMethod: string) => {
const {
data,
isPending: loading,
mutateAsync,
} = useMutation({
mutationKey: ['uploadAndParseDocument'],
mutationFn: async ({
conversationId,
fileList,
}: {
conversationId: string;
fileList: UploadFile[];
}) => {
try {
const formData = new FormData();
formData.append('conversation_id', conversationId);
fileList.forEach((file: UploadFile) => {
formData.append('file', file as any);
});
if (uploadMethod === 'upload_and_parse') {
const data = await kbService.upload_and_parse(formData);
return data?.data;
}
const data = await chatService.uploadAndParseExternal(formData);
return data?.data;
} catch (error) {}
},
});
return { data, loading, uploadAndParseDocument: mutateAsync };
};
export const useParseDocument = () => {
const {
data,

View File

@ -11,6 +11,7 @@ import { IAskRequestBody } from '@/interfaces/request/chat';
import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-shared-message';
import { isConversationIdExist } from '@/pages/next-chats/utils';
import chatService from '@/services/next-chat-service';
import api from '@/utils/api';
import { buildMessageListWithUuid, getConversationId } from '@/utils/chat';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
@ -427,6 +428,7 @@ export function useUploadAndParseFile() {
const { data } = await chatService.uploadAndParse(
{
url: api.upload_and_parse(conversationId || id),
signal: controller.current.signal,
data: formData,
onUploadProgress: ({ progress }) => {