fix: 重名模型高亮;perf: 未匹配到问题时输出

This commit is contained in:
archer
2023-04-11 17:28:43 +08:00
parent 915b104b8a
commit 488e2f476e
3 changed files with 12 additions and 16 deletions

View File

@@ -96,18 +96,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
if (formatRedisPrompt.length === 0) {
throw new Error('对不起,我没有找到你的问题');
if (formatRedisPrompt.length > 0) {
// textArr 筛选,最多 2800 tokens
const systemPrompt = systemPromptFilter(formatRedisPrompt, 2800);
prompts.unshift({
obj: 'SYSTEM',
value: `${model.systemPrompt} 知识库内容是最新的,知识库内容为: "${systemPrompt}"`
});
} else {
return res.send('对不起,你的问题不在知识库中。');
}
// textArr 筛选,最多 2800 tokens
const systemPrompt = systemPromptFilter(formatRedisPrompt, 2800);
prompts.unshift({
obj: 'SYSTEM',
value: `${model.systemPrompt} 知识库内容是最新的,知识库内容为: "${systemPrompt}"`
});
// 控制在 tokens 数量,防止超出
const filterPrompts = openaiChatFilter(prompts, modelConstantsData.contextMaxToken);