Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Feat: Remove unnecessary dialogue-related code. #10427 (#11652)

balibabu519f03097e61
diff --git a/web/src/components/message-item/hooks.ts b/web/src/components/message-item/hooks.ts
index f77da05011..5992027757 100644
--- a/web/src/components/message-item/hooks.ts
+++ b/web/src/components/message-item/hooks.ts
@@ -1,6 +1,6 @@
-import { useDeleteMessage, useFeedback } from '@/hooks/chat-hooks';
import { useSetModalState } from '@/hooks/common-hooks';
import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
+import { useDeleteMessage, useFeedback } from '@/hooks/use-chat-request';
import { IFeedbackRequestBody } from '@/interfaces/request/chat';
import { hexStringToUint8Array } from '@/utils/common-util';
import { SpeechPlayer } from 'openai-speech-stream-player';
diff --git a/web/src/components/next-message-item/hooks.ts b/web/src/components/next-message-item/hooks.ts
index f77da05011..27d86e9161 100644
--- a/web/src/components/next-message-item/hooks.ts
+++ b/web/src/components/next-message-item/hooks.ts
@@ -1,6 +1,7 @@
-import { useDeleteMessage, useFeedback } from '@/hooks/chat-hooks';
+// import { useDeleteMessage, useFeedback } from '@/hooks/chat-hooks';
import { useSetModalState } from '@/hooks/common-hooks';
import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
+import { useDeleteMessage, useFeedback } from '@/hooks/use-chat-request';
import { IFeedbackRequestBody } from '@/interfaces/request/chat';
import { hexStringToUint8Array } from '@/utils/common-util';
import { SpeechPlayer } from 'openai-speech-stream-player';
diff --git a/web/src/hooks/chat-hooks.ts b/web/src/hooks/chat-hooks.ts
deleted file mode 100644
index a8e1509a39..0000000000
--- a/web/src/hooks/chat-hooks.ts
+++ /dev/null
@@ -1,642 +0,0 @@
-import { ChatSearchParams } from '@/constants/chat';
-import {
- IClientConversation,
- IConversation,
- IDialog,
- IStats,
- IToken,
-} from '@/interfaces/database/chat';
-import {
- IAskRequestBody,
- IFeedbackRequestBody,
-} from '@/interfaces/request/chat';
-import i18n from '@/locales/config';
-import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-shared-message';
-import chatService from '@/services/chat-service';
-import {
- buildMessageListWithUuid,
- getConversationId,
- isConversationIdExist,
-} from '@/utils/chat';
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import { message } from 'antd';
-import dayjs, { Dayjs } from 'dayjs';
-import { has, set } from 'lodash';
-import { useCallback, useMemo, useState } from 'react';
-import { history, useSearchParams } from 'umi';
-
-//#region logic
-
-export const useClickDialogCard = () => {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const [_, setSearchParams] = useSearchParams();
-
- const newQueryParameters: URLSearchParams = useMemo(() => {
- return new URLSearchParams();
- }, []);
-
- const handleClickDialog = useCallback(
- (dialogId: string) => {
- newQueryParameters.set(ChatSearchParams.DialogId, dialogId);
- // newQueryParameters.set(
- // ChatSearchParams.ConversationId,
- // EmptyConversationId,
- // );
- setSearchParams(newQueryParameters);
- },
- [newQueryParameters, setSearchParams],
- );
-
- return { handleClickDialog };
-};
-
-export const useClickConversationCard = () => {
- const [currentQueryParameters, setSearchParams] = useSearchParams();
- const newQueryParameters: URLSearchParams = useMemo(
- () => new URLSearchParams(currentQueryParameters.toString()),
- [currentQueryParameters],
- );
-
- const handleClickConversation = useCallback(
- (conversationId: string, isNew: string) => {
- newQueryParameters.set(ChatSearchParams.ConversationId, conversationId);
- newQueryParameters.set(ChatSearchParams.isNew, isNew);
- setSearchParams(newQueryParameters);
- },
- [setSearchParams, newQueryParameters],
- );
-
- return { handleClickConversation };
-};
-
-export const useGetChatSearchParams = () => {
- const [currentQueryParameters] = useSearchParams();
-
- return {
- dialogId: currentQueryParameters.get(ChatSearchParams.DialogId) || '',
- conversationId:
- currentQueryParameters.get(ChatSearchParams.ConversationId) || '',
- isNew: currentQueryParameters.get(ChatSearchParams.isNew) || '',
- };
-};
-
-//#endregion
-
-//#region dialog
-
-export const useFetchNextDialogList = (pureFetch = false) => {
- const { handleClickDialog } = useClickDialogCard();
- const { dialogId } = useGetChatSearchParams();
-
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IDialog[]>({
- queryKey: ['fetchDialogList'],
- initialData: [],
- gcTime: 0,
- refetchOnWindowFocus: false,
- queryFn: async (...params) => {
- console.log('🚀 ~ queryFn: ~ params:', params);
- const { data } = await chatService.listDialog();
-
- if (data.code === 0) {
- const list: IDialog[] = data.data;
- if (!pureFetch) {
- if (list.length > 0) {
- if (list.every((x) => x.id !== dialogId)) {
- handleClickDialog(data.data[0].id);
- }
- } else {
- history.push('/chat');
- }
- }
- }
-
- return data?.data ?? [];
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useFetchChatAppList = () => {
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IDialog[]>({
- queryKey: ['fetchChatAppList'],
- initialData: [],
- gcTime: 0,
- refetchOnWindowFocus: false,
- queryFn: async () => {
- const { data } = await chatService.listDialog();
-
- return data?.data ?? [];
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useSetNextDialog = () => {
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['setDialog'],
- mutationFn: async (params: IDialog) => {
- const { data } = await chatService.setDialog(params);
- if (data.code === 0) {
- queryClient.invalidateQueries({
- exact: false,
- queryKey: ['fetchDialogList'],
- });
-
- queryClient.invalidateQueries({
- queryKey: ['fetchDialog'],
- });
- message.success(
- i18n.t(`message.${params.dialog_id ? 'modified' : 'created'}`),
- );
- }
- return data?.code;
- },
- });
-
- return { data, loading, setDialog: mutateAsync };
-};
-
-export const useFetchNextDialog = () => {
- const { dialogId } = useGetChatSearchParams();
-
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IDialog>({
- queryKey: ['fetchDialog', dialogId],
- gcTime: 0,
- initialData: {} as IDialog,
- enabled: !!dialogId,
- refetchOnWindowFocus: false,
- queryFn: async () => {
- const { data } = await chatService.getDialog({ dialogId });
-
- return data?.data ?? ({} as IDialog);
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useFetchManualDialog = () => {
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['fetchManualDialog'],
- gcTime: 0,
- mutationFn: async (dialogId: string) => {
- const { data } = await chatService.getDialog({ dialogId });
-
- return data;
- },
- });
-
- return { data, loading, fetchDialog: mutateAsync };
-};
-
-export const useRemoveNextDialog = () => {
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['removeDialog'],
- mutationFn: async (dialogIds: string[]) => {
- const { data } = await chatService.removeDialog({ dialogIds });
- if (data.code === 0) {
- queryClient.invalidateQueries({ queryKey: ['fetchDialogList'] });
-
- message.success(i18n.t('message.deleted'));
- }
- return data.code;
- },
- });
-
- return { data, loading, removeDialog: mutateAsync };
-};
-
-//#endregion
-
-//#region conversation
-
-export const useFetchNextConversationList = () => {
- const { dialogId } = useGetChatSearchParams();
- const { handleClickConversation } = useClickConversationCard();
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IConversation[]>({
- queryKey: ['fetchConversationList', dialogId],
- initialData: [],
- gcTime: 0,
- refetchOnWindowFocus: false,
- enabled: !!dialogId,
- queryFn: async () => {
- const { data } = await chatService.listConversation({ dialogId });
- if (data.code === 0) {
- if (data.data.length > 0) {
- handleClickConversation(data.data[0].id, '');
- } else {
- handleClickConversation('', '');
- }
- }
- return data?.data;
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useFetchNextConversation = () => {
- const { isNew, conversationId } = useGetChatSearchParams();
- const { sharedId } = useGetSharedChatSearchParams();
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IClientConversation>({
- queryKey: ['fetchConversation', conversationId],
- initialData: {} as IClientConversation,
- // enabled: isConversationIdExist(conversationId),
- gcTime: 0,
- refetchOnWindowFocus: false,
- queryFn: async () => {
- if (
- isNew !== 'true' &&
- isConversationIdExist(sharedId || conversationId)
- ) {
- const { data } = await chatService.getConversation({
- conversationId: conversationId || sharedId,
- });
-
- const conversation = data?.data ?? {};
-
- const messageList = buildMessageListWithUuid(conversation?.message);
-
- return { ...conversation, message: messageList };
- }
- return { message: [] };
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useFetchNextConversationSSE = () => {
- const { isNew } = useGetChatSearchParams();
- const { sharedId } = useGetSharedChatSearchParams();
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IClientConversation>({
- queryKey: ['fetchConversationSSE', sharedId],
- initialData: {} as IClientConversation,
- gcTime: 0,
- refetchOnWindowFocus: false,
- queryFn: async () => {
- if (isNew !== 'true' && isConversationIdExist(sharedId || '')) {
- if (!sharedId) return {};
- const { data } = await chatService.getConversationSSE({}, sharedId);
- const conversation = data?.data ?? {};
- const messageList = buildMessageListWithUuid(conversation?.message);
- return { ...conversation, message: messageList };
- }
- return { message: [] };
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useFetchManualConversation = () => {
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['fetchManualConversation'],
- gcTime: 0,
- mutationFn: async (conversationId: string) => {
- const { data } = await chatService.getConversation({ conversationId });
-
- return data;
- },
- });
-
- return { data, loading, fetchConversation: mutateAsync };
-};
-
-export const useUpdateNextConversation = () => {
- const queryClient = useQueryClient();
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['updateConversation'],
- mutationFn: async (params: Record<string, any>) => {
- const { data } = await chatService.setConversation({
- ...params,
- conversation_id: params.conversation_id
- ? params.conversation_id
- : getConversationId(),
- });
- if (data.code === 0) {
- queryClient.invalidateQueries({ queryKey: ['fetchConversationList'] });
- message.success(i18n.t(`message.modified`));
- }
- return data;
- },
- });
-
- return { data, loading, updateConversation: mutateAsync };
-};
-
-export const useRemoveNextConversation = () => {
- const queryClient = useQueryClient();
- const { dialogId } = useGetChatSearchParams();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['removeConversation'],
- mutationFn: async (conversationIds: string[]) => {
- const { data } = await chatService.removeConversation({
- conversationIds,
- dialogId,
- });
- if (data.code === 0) {
- queryClient.invalidateQueries({ queryKey: ['fetchConversationList'] });
- }
- return data.code;
- },
- });
-
- return { data, loading, removeConversation: mutateAsync };
-};
-
-export const useDeleteMessage = () => {
- const { conversationId } = useGetChatSearchParams();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['deleteMessage'],
- mutationFn: async (messageId: string) => {
- const { data } = await chatService.deleteMessage({
- messageId,
- conversationId,
- });
-
- if (data.code === 0) {
- message.success(i18n.t(`message.deleted`));
- }
-
- return data.code;
- },
- });
-
- return { data, loading, deleteMessage: mutateAsync };
-};
-
-export const useFeedback = () => {
- const { conversationId } = useGetChatSearchParams();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['feedback'],
- mutationFn: async (params: IFeedbackRequestBody) => {
- const { data } = await chatService.thumbup({
- ...params,
- conversationId,
- });
- if (data.code === 0) {
- message.success(i18n.t(`message.operated`));
- }
- return data.code;
- },
- });
-
- return { data, loading, feedback: mutateAsync };
-};
-
-//#endregion
-
-// #region API provided for external calls
-
-export const useCreateNextToken = () => {
- const queryClient = useQueryClient();
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['createToken'],
- mutationFn: async (params: Record<string, any>) => {
- const { data } = await chatService.createToken(params);
- if (data.code === 0) {
- queryClient.invalidateQueries({ queryKey: ['fetchTokenList'] });
- }
- return data?.data ?? [];
- },
- });
-
- return { data, loading, createToken: mutateAsync };
-};
-
-export const useFetchTokenList = (params: Record<string, any>) => {
- const {
- data,
- isFetching: loading,
- refetch,
- } = useQuery<IToken[]>({
- queryKey: ['fetchTokenList', params],
- initialData: [],
- gcTime: 0,
- queryFn: async () => {
- const { data } = await chatService.listToken(params);
-
- return data?.data ?? [];
- },
- });
-
- return { data, loading, refetch };
-};
-
-export const useRemoveNextToken = () => {
- const queryClient = useQueryClient();
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['removeToken'],
- mutationFn: async (params: {
- tenantId: string;
- dialogId?: string;
- tokens: string[];
- }) => {
- const { data } = await chatService.removeToken(params);
- if (data.code === 0) {
- queryClient.invalidateQueries({ queryKey: ['fetchTokenList'] });
- }
- return data?.data ?? [];
- },
- });
-
- return { data, loading, removeToken: mutateAsync };
-};
-
-type RangeValue = [Dayjs | null, Dayjs | null] | null;
-
-const getDay = (date?: Dayjs) => date?.format('YYYY-MM-DD');
-
-export const useFetchNextStats = () => {
- const [pickerValue, setPickerValue] = useState<RangeValue>([
- dayjs().subtract(7, 'day'),
- dayjs(),
- ]);
- const { data, isFetching: loading } = useQuery<IStats>({
- queryKey: ['fetchStats', pickerValue],
- initialData: {} as IStats,
- gcTime: 0,
- queryFn: async () => {
- if (Array.isArray(pickerValue) && pickerValue[0]) {
- const { data } = await chatService.getStats({
- fromDate: getDay(pickerValue[0]),
- toDate: getDay(pickerValue[1] ?? dayjs()),
- });
- return data?.data ?? {};
- }
- return {};
- },
- });
-
- return { data, loading, pickerValue, setPickerValue };
-};
-
-//#endregion
-
-//#region shared chat
-
-export const useCreateNextSharedConversation = () => {
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['createSharedConversation'],
- mutationFn: async (userId?: string) => {
- const { data } = await chatService.createExternalConversation({ userId });
-
- return data;
- },
- });
-
- return { data, loading, createSharedConversation: mutateAsync };
-};
-
-// deprecated
-export const useFetchNextSharedConversation = (
- conversationId?: string | null,
-) => {
- const { data, isPending: loading } = useQuery({
- queryKey: ['fetchSharedConversation'],
- enabled: !!conversationId,
- queryFn: async () => {
- if (!conversationId) {
- return {};
- }
- const { data } = await chatService.getExternalConversation(
- null,
- conversationId,
- );
-
- const messageList = buildMessageListWithUuid(data?.data?.message);
-
- set(data, 'data.message', messageList);
-
- return data;
- },
- });
-
- return { data, loading };
-};
-
-//#endregion
-
-//#region search page
-
-export const useFetchMindMap = () => {
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['fetchMindMap'],
- gcTime: 0,
- mutationFn: async (params: IAskRequestBody) => {
- try {
- const ret = await chatService.getMindMap(params);
- return ret?.data?.data ?? {};
- } catch (error: any) {
- if (has(error, 'message')) {
- message.error(error.message);
- }
-
- return [];
- }
- },
- });
-
- return { data, loading, fetchMindMap: mutateAsync };
-};
-
-export const useFetchRelatedQuestions = () => {
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: ['fetchRelatedQuestions'],
- gcTime: 0,
- mutationFn: async (question: string): Promise<string[]> => {
- const { data } = await chatService.getRelatedQuestions({ question });
-
- return data?.data ?? [];
- },
- });
-
- return { data, loading, fetchRelatedQuestions: mutateAsync };
-};
-//#endregion
diff --git a/web/src/hooks/use-chat-request.ts b/web/src/hooks/use-chat-request.ts
index 77663ea9bd..0213acbb3a 100644
--- a/web/src/hooks/use-chat-request.ts
+++ b/web/src/hooks/use-chat-request.ts
@@ -7,7 +7,11 @@ import {
IDialog,
IExternalChatInfo,
} from '@/interfaces/database/chat';
-import { IAskRequestBody } from '@/interfaces/request/chat';
+import {
+ IAskRequestBody,
+ IFeedbackRequestBody,
+} from '@/interfaces/request/chat';
+import i18n from '@/locales/config';
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';
@@ -39,6 +43,9 @@ export const enum ChatApiAction {
FetchRelatedQuestions = 'fetchRelatedQuestions',
UploadAndParse = 'upload_and_parse',
FetchExternalChatInfo = 'fetchExternalChatInfo',
+ Feedback = 'feedback',
+ CreateSharedConversation = 'createSharedConversation',
+ FetchConversationSse = 'fetchConversationSSE',
}
export const useGetChatSearchParams = () => {
@@ -397,6 +404,30 @@ export const useDeleteMessage = () => {
return { data, loading, deleteMessage: mutateAsync };
};
+export const useFeedback = () => {
+ const { conversationId } = useGetChatSearchParams();
+
+ const {
+ data,
+ isPending: loading,
+ mutateAsync,
+ } = useMutation({
+ mutationKey: [ChatApiAction.Feedback],
+ mutationFn: async (params: IFeedbackRequestBody) => {
+ const { data } = await chatService.thumbup({
+ ...params,
+ conversationId,
+ });
+ if (data.code === 0) {
+ message.success(i18n.t(`message.operated`));
+ }
+ return data.code;
+ },
+ });
+
+ return { data, loading, feedback: mutateAsync };
+};
+
type UploadParameters = Parameters<NonNullable<FileUploadProps['onUpload']>>;
type X = {
@@ -532,3 +563,47 @@ export const useFetchRelatedQuestions = () => {
return { data, loading, fetchRelatedQuestions: mutateAsync };
};
//#endregion
+
+export const useCreateNextSharedConversation = () => {
+ const {
+ data,
+ isPending: loading,
+ mutateAsync,
+ } = useMutation({
+ mutationKey: [ChatApiAction.CreateSharedConversation],
+ mutationFn: async (userId?: string) => {
+ const { data } = await chatService.createExternalConversation({ userId });
+
+ return data;
+ },
+ });
+
+ return { data, loading, createSharedConversation: mutateAsync };
+};
+
+export const useFetchNextConversationSSE = () => {
+ const { isNew } = useGetChatSearchParams();
+ const { sharedId } = useGetSharedChatSearchParams();
+ const {
+ data,
+ isFetching: loading,
+ refetch,
+ } = useQuery<IClientConversation>({
+ queryKey: [ChatApiAction.FetchConversationSse, sharedId],
+ initialData: {} as IClientConversation,
+ gcTime: 0,
+ refetchOnWindowFocus: false,
+ queryFn: async () => {
+ if (isNew !== 'true' && isConversationIdExist(sharedId || '')) {
+ if (!sharedId) return {};
+ const { data } = await chatService.getConversationSSE(sharedId);
+ const conversation = data?.data ?? {};
+ const messageList = buildMessageListWithUuid(conversation?.message);
+ return { ...conversation, message: messageList };
+ }
+ return { message: [] };
+ },
+ });
+
+ return { data, loading, refetch };
+};
diff --git a/web/src/pages/next-chats/hooks/use-send-shared-message.ts b/web/src/pages/next-chats/hooks/use-send-shared-message.ts
index 022998e708..7063d5d958 100644
--- a/web/src/pages/next-chats/hooks/use-send-shared-message.ts
+++ b/web/src/pages/next-chats/hooks/use-send-shared-message.ts
@@ -1,10 +1,10 @@
import { MessageType, SharedFrom } from '@/constants/chat';
-import { useCreateNextSharedConversation } from '@/hooks/chat-hooks';
import {
useHandleMessageInputChange,
useSelectDerivedMessages,
useSendMessageWithSse,
} from '@/hooks/logic-hooks';
+import { useCreateNextSharedConversation } from '@/hooks/use-chat-request';
import { Message } from '@/interfaces/database/chat';
import { message } from 'antd';
import { get } from 'lodash';
diff --git a/web/src/pages/next-chats/share/index.tsx b/web/src/pages/next-chats/share/index.tsx
index c08d14feb0..2ca8298a35 100644
--- a/web/src/pages/next-chats/share/index.tsx
+++ b/web/src/pages/next-chats/share/index.tsx
@@ -5,9 +5,11 @@ import PdfSheet from '@/components/pdf-drawer';
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
import { useSyncThemeFromParams } from '@/components/theme-provider';
import { MessageType, SharedFrom } from '@/constants/chat';
-import { useFetchNextConversationSSE } from '@/hooks/chat-hooks';
import { useFetchFlowSSE } from '@/hooks/flow-hooks';
-import { useFetchExternalChatInfo } from '@/hooks/use-chat-request';
+import {
+ useFetchExternalChatInfo,
+ useFetchNextConversationSSE,
+} from '@/hooks/use-chat-request';
import i18n from '@/locales/config';
import { buildMessageUuidWithRole } from '@/utils/chat';
import React, { forwardRef, useMemo } from 'react';
diff --git a/web/src/pages/next-search/hooks.ts b/web/src/pages/next-search/hooks.ts
index 34a810ad17..f03b52826b 100644
--- a/web/src/pages/next-search/hooks.ts
+++ b/web/src/pages/next-search/hooks.ts
@@ -12,8 +12,8 @@ import { ResponsePostType } from '@/interfaces/database/base';
import { IAnswer } from '@/interfaces/database/chat';
import { ITestingResult } from '@/interfaces/database/knowledge';
import { IAskRequestBody } from '@/interfaces/request/chat';
-import chatService from '@/services/chat-service';
import kbService from '@/services/knowledge-service';
+import chatService from '@/services/next-chat-service';
import searchService from '@/services/search-service';
import api from '@/utils/api';
import { useMutation } from '@tanstack/react-query';
diff --git a/web/src/services/chat-service.ts b/web/src/services/chat-service.ts
deleted file mode 100644
index 7d4d8facef..0000000000
--- a/web/src/services/chat-service.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import api from '@/utils/api';
-import registerServer from '@/utils/register-server';
-import request from '@/utils/request';
-
-const {
- getDialog,
- setDialog,
- listDialog,
- removeDialog,
- getConversation,
- getConversationSSE,
- setConversation,
- completeConversation,
- listConversation,
- removeConversation,
- createToken,
- listToken,
- removeToken,
- getStats,
- createExternalConversation,
- getExternalConversation,
- completeExternalConversation,
- uploadAndParseExternal,
- deleteMessage,
- thumbup,
- tts,
- ask,
- mindmap,
- getRelatedQuestions,
-} = api;
-
-const methods = {
- getDialog: {
- url: getDialog,
- method: 'get',
- },
- setDialog: {
- url: setDialog,
- method: 'post',
- },
- removeDialog: {
- url: removeDialog,
- method: 'post',
- },
- listDialog: {
- url: listDialog,
- method: 'get',
- },
- listConversation: {
- url: listConversation,
- method: 'get',
- },
- getConversation: {
- url: getConversation,
- method: 'get',
- },
- getConversationSSE: {
- url: getConversationSSE,
- method: 'get',
- },
- setConversation: {
- url: setConversation,
- method: 'post',
- },
- completeConversation: {
- url: completeConversation,
- method: 'post',
- },
- removeConversation: {
- url: removeConversation,
- method: 'post',
- },
- createToken: {
- url: createToken,
- method: 'post',
- },
- listToken: {
- url: listToken,
- method: 'get',
- },
- removeToken: {
- url: removeToken,
- method: 'post',
- },
- getStats: {
- url: getStats,
- method: 'get',
- },
- createExternalConversation: {
- url: createExternalConversation,
- method: 'get',
- },
- getExternalConversation: {
- url: getExternalConversation,
- method: 'get',
- },
- completeExternalConversation: {
- url: completeExternalConversation,
- method: 'post',
- },
- uploadAndParseExternal: {
- url: uploadAndParseExternal,
- method: 'post',
- },
- deleteMessage: {
- url: deleteMessage,
- method: 'post',
- },
- thumbup: {
- url: thumbup,
- method: 'post',
- },
- tts: {
- url: tts,
- method: 'post',
- },
- ask: {
- url: ask,
- method: 'post',
- },
- getMindMap: {
- url: mindmap,
- method: 'post',
- },
- getRelatedQuestions: {
- url: getRelatedQuestions,
- method: 'post',
- },
-} as const;
-
-const chatService = registerServer<keyof typeof methods>(methods, request);
-
-export default chatService;
diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts
index 2c2c39a209..a0939155b6 100644
--- a/web/src/utils/api.ts
+++ b/web/src/utils/api.ts
@@ -119,7 +119,8 @@ export default {
listDialog: `${api_host}/dialog/list`,
setConversation: `${api_host}/conversation/set`,
getConversation: `${api_host}/conversation/get`,
- getConversationSSE: `${api_host}/conversation/getsse`,
+ getConversationSSE: (dialogId: string) =>
+ `${api_host}/conversation/getsse/${dialogId}`,
listConversation: `${api_host}/conversation/list`,
removeConversation: `${api_host}/conversation/rm`,
completeConversation: `${api_host}/conversation/completion`,