feat: 修改计费模式为tokens

This commit is contained in:
archer
2023-03-25 14:43:32 +08:00
parent 4eaf3a1be0
commit 6bba859060
18 changed files with 97 additions and 38 deletions

View File

@@ -12,12 +12,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
await connectToDatabase();
await Bill.updateMany(
{},
{
type: 'chat',
modelName: 'gpt-3.5-turbo'
}
const bills = await Bill.find({
tokenLen: { $exists: false }
});
await Promise.all(
bills.map((bill) =>
Bill.findByIdAndUpdate(bill._id, {
tokenLen: bill.textLen
})
)
);
jsonRes(res, {