perf: chunk filter

This commit is contained in:
archer
2023-08-07 10:59:31 +08:00
parent 1964640d5c
commit 7fe20ef041
5 changed files with 47 additions and 51 deletions

View File

@@ -129,16 +129,26 @@ export const pushGenerateVectorBill = async ({
try {
// 计算价格. 至少为1
const unitPrice = global.vectorModels.find((item) => item.model === model)?.price || 0.2;
const vectorModel =
global.vectorModels.find((item) => item.model === model) || global.vectorModels[0];
const unitPrice = vectorModel.price || 0.2;
let total = unitPrice * tokenLen;
total = total > 1 ? total : 1;
// 插入 Bill 记录
const res = await Bill.create({
userId,
model,
model: vectorModel.model,
appName: '索引生成',
total
total,
list: [
{
moduleName: '索引生成',
amount: total,
model: vectorModel.model,
tokenLen
}
]
});
billId = res._id;