perf: response tag;feat: history quote

This commit is contained in:
archer
2023-08-15 09:55:00 +08:00
parent b8a65e1742
commit cc57a7e27e
9 changed files with 39 additions and 32 deletions

View File

@@ -4,16 +4,14 @@ import { authUser } from '@/service/utils/auth';
import { sseErrRes } from '@/service/response';
import { sseResponseEventEnum } from '@/constants/chat';
import { sseResponse } from '@/service/utils/tools';
import { type ChatCompletionRequestMessage } from 'openai';
import { AppModuleItemType } from '@/types/app';
import { dispatchModules } from '../openapi/v1/chat/completions';
import { gptMessage2ChatType } from '@/utils/adapt';
import { pushTaskBill } from '@/service/events/pushBill';
import { BillSourceEnum } from '@/constants/user';
import { ChatItemType } from '@/types/chat';
export type MessageItemType = ChatCompletionRequestMessage & { _id?: string };
export type Props = {
history: MessageItemType[];
history: ChatItemType[];
prompt: string;
modules: AppModuleItemType[];
variables: Record<string, any>;
@@ -51,7 +49,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
variables,
user,
params: {
history: gptMessage2ChatType(history),
history,
userChatInput: prompt
},
stream: true,