perf: chat上下文截断;QA提示词

This commit is contained in:
archer
2023-04-21 23:30:26 +08:00
parent 4397a0ad6b
commit 3ea2cf1dcb
10 changed files with 63 additions and 34 deletions

View File

@@ -41,11 +41,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const tokens = encode(splitText + chunk).length;
if (tokens >= 4000) {
// 超过 4000不要这块内容
textList.push(splitText);
splitText && textList.push(splitText);
splitText = chunk;
} else if (tokens >= 3000) {
// 超过 3000取内容
textList.push(splitText + chunk);
splitText && textList.push(splitText + chunk);
splitText = '';
} else {
//没超过 3000继续添加