This commit is contained in:
Archer
2023-09-18 13:37:25 +08:00
committed by GitHub
parent 0bb31b985d
commit b8ea546b3f
25 changed files with 288 additions and 225 deletions

View File

@@ -18,7 +18,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
throw new Error('最多 10 组 API 秘钥');
}
const apiKey = `fastgpt-${nanoid()}`;
const apiKey = `${global.systemEnv?.openapiPrefix || 'fastgpt'}-${nanoid()}`;
await OpenApi.create({
userId,

View File

@@ -116,7 +116,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
appId,
userId
}),
getChatHistory({ chatId, userId })
getChatHistory({ chatId, appId, userId })
]);
const isOwner = !shareId && userId === String(app.userId);

View File

@@ -7,6 +7,7 @@ import { Types } from 'mongoose';
import type { ChatItemType } from '@/types/chat';
export type Props = {
appId?: string;
chatId?: string;
limit?: number;
};
@@ -36,9 +37,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
export async function getChatHistory({
chatId,
userId,
appId,
limit = 30
}: Props & { userId: string }): Promise<Response> {
if (!chatId) {
if (!chatId || !appId) {
return { history: [] };
}
@@ -46,6 +48,7 @@ export async function getChatHistory({
{
$match: {
chatId,
appId: new Types.ObjectId(appId),
userId: new Types.ObjectId(userId)
}
},