This commit is contained in:
Archer
2023-11-09 09:46:57 +08:00
committed by GitHub
parent 661ee79943
commit 8bb5588305
402 changed files with 9899 additions and 5967 deletions

View File

@@ -1,10 +1,11 @@
import { moduleDispatchResType, ChatItemType } from '@/types/chat';
import type { moduleDispatchResType, ChatItemType } from '@fastgpt/global/core/chat/type.d';
import type { ModuleDispatchProps } from '@/types/core/chat/type';
import { SelectAppItemType } from '@fastgpt/global/core/module/type';
import { dispatchModules } from '@/pages/api/v1/chat/completions';
import { App } from '@/service/mongo';
import { dispatchModules } from '../index';
import { MongoApp } from '@fastgpt/service/core/app/schema';
import { responseWrite } from '@fastgpt/service/common/response';
import { ChatRoleEnum, TaskResponseKeyEnum, sseResponseEventEnum } from '@/constants/chat';
import { ChatRoleEnum, TaskResponseKeyEnum } from '@fastgpt/global/core/chat/constants';
import { sseResponseEventEnum } from '@fastgpt/service/common/response/constant';
import { textAdaptGptResponse } from '@/utils/adapt';
type Props = ModuleDispatchProps<{
@@ -18,21 +19,20 @@ type Response = {
[TaskResponseKeyEnum.history]: ChatItemType[];
};
export const dispatchAppRequest = async (props: Record<string, any>): Promise<Response> => {
export const dispatchAppRequest = async (props: Props): Promise<Response> => {
const {
res,
variables,
user,
stream,
detail,
inputs: { userChatInput, history = [], app }
} = props as Props;
} = props;
if (!userChatInput) {
return Promise.reject('Input is empty');
}
const appData = await App.findOne({
const appData = await MongoApp.findOne({
_id: app.id,
userId: user._id
});
@@ -52,16 +52,12 @@ export const dispatchAppRequest = async (props: Record<string, any>): Promise<Re
}
const { responseData, answerText } = await dispatchModules({
res,
...props,
modules: appData.modules,
user,
variables,
params: {
history,
userChatInput
},
stream,
detail
}
});
const completeMessages = history.concat([