feat: adapt v1 system plugin (#1366)

This commit is contained in:
Archer
2024-05-06 15:21:29 +08:00
committed by GitHub
parent 8863337606
commit db1c27cdc7
16 changed files with 1511 additions and 22 deletions

View File

@@ -1,25 +1,36 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { HttpBodyType } from '@fastgpt/global/core/workflow/api.d';
//@ts-ignore
import type { HttpBodyType } from '@fastgpt/global/core/module/api.d';
import { getErrText } from '@fastgpt/global/common/error/utils';
import { addCustomFeedbacks } from '@fastgpt/service/core/chat/controller';
import { authRequestFromLocal } from '@fastgpt/service/support/permission/auth/common';
import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
type Props = HttpBodyType<{
appId: string;
chatId?: string;
responseChatItemId?: string;
defaultFeedback: string;
customFeedback: string;
}>;
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
const {
customFeedback,
system_addInputParam: { appId, chatId, responseChatItemId: chatItemId }
appId,
chatId,
responseChatItemId: chatItemId,
defaultFeedback,
customFeedback
} = req.body as Props;
await authRequestFromLocal({ req });
if (!customFeedback) {
return res.json({});
const feedback = customFeedback || defaultFeedback;
if (!feedback) {
return res.json({
response: ''
});
}
// wait the chat finish
@@ -28,17 +39,19 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
appId,
chatId,
chatItemId,
feedbacks: [customFeedback]
feedbacks: [feedback]
});
}, 60000);
if (!chatId || !chatItemId) {
return res.json({
[NodeOutputKeyEnum.answerText]: `\\n\\n**自动反馈调试**: "${customFeedback}"\\n\\n`
response: `\\n\\n**自动反馈调试**: ${feedback}\\n\\n`
});
}
return res.json({});
return res.json({
response: ''
});
} catch (err) {
console.log(err);
res.status(500).send(getErrText(err));