v4.6.6-search test adapt diff search mode (#685)

This commit is contained in:
Archer
2024-01-03 15:40:03 +08:00
committed by GitHub
parent c766a0ed8a
commit 13b10720ac
57 changed files with 1101 additions and 612 deletions

View File

@@ -14,7 +14,14 @@ import { searchQueryExtension } from '@fastgpt/service/core/ai/functions/queryEx
export default withNextCors(async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
await connectToDatabase();
const { datasetId, text, limit = 20, searchMode, usingReRank } = req.body as SearchTestProps;
const {
datasetId,
text,
limit = 1500,
similarity,
searchMode,
usingReRank
} = req.body as SearchTestProps;
if (!datasetId || !text) {
throw new Error('缺少参数');
@@ -40,11 +47,12 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
// model: global.chatModels[0].model
// });
const { searchRes, tokens } = await searchDatasetData({
const { searchRes, tokens, ...result } = await searchDatasetData({
rawQuery: text,
queries: [text],
model: dataset.vectorModel,
limit: Math.min(limit * 800, 30000),
limit: Math.min(limit, 20000),
similarity,
datasetIds: [datasetId],
searchMode,
usingReRank
@@ -68,7 +76,8 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
jsonRes<SearchTestResponse>(res, {
data: {
list: searchRes,
duration: `${((Date.now() - start) / 1000).toFixed(3)}s`
duration: `${((Date.now() - start) / 1000).toFixed(3)}s`,
...result
}
});
} catch (err) {