perf: refresh page.img mode.collection filter
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { connectToDatabase, SplitData, Model } from '@/service/mongo';
|
||||
import { authToken } from '@/service/utils/auth';
|
||||
import { authModel, authToken } from '@/service/utils/auth';
|
||||
import { generateVector } from '@/service/events/generateVector';
|
||||
import { generateQA } from '@/service/events/generateQA';
|
||||
import { PgClient } from '@/service/pg';
|
||||
@@ -23,15 +23,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const userId = await authToken(req);
|
||||
|
||||
// 验证是否是该用户的 model
|
||||
const model = await Model.findOne({
|
||||
_id: modelId,
|
||||
await authModel({
|
||||
modelId,
|
||||
userId
|
||||
});
|
||||
|
||||
if (!model) {
|
||||
throw new Error('无权操作该模型');
|
||||
}
|
||||
|
||||
if (mode === 'qa') {
|
||||
// 批量QA拆分插入数据
|
||||
await SplitData.create({
|
||||
|
||||
@@ -22,9 +22,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
).sort({
|
||||
_id: -1
|
||||
}),
|
||||
Collection.find({
|
||||
userId
|
||||
}).populate('modelId', '_id avatar name chat.systemPrompt')
|
||||
Collection.find({ userId })
|
||||
.populate({
|
||||
path: 'modelId',
|
||||
select: '_id avatar name chat.systemPrompt',
|
||||
match: { 'share.isShare': true }
|
||||
})
|
||||
.then((res) => res.filter((item) => item.modelId))
|
||||
]);
|
||||
|
||||
jsonRes<ModelListResponse>(res, {
|
||||
|
||||
Reference in New Issue
Block a user