fix: formatted usage entry

This commit is contained in:
yanlong.wang 2025-03-26 14:07:36 +08:00
parent e9d69e6201
commit e953c01e58
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -454,7 +454,6 @@ export class SearcherHost extends RPCHost {
const itemAmount = this.crawler.assignChargeAmount(x) || 0;
if (!itemAmount) {
Reflect.deleteProperty(x, 'usage');
continue;
}
@ -465,6 +464,13 @@ export class SearcherHost extends RPCHost {
const final = Math.max(contentCharge, numCharge);
if (final === numCharge) {
for (const x of formatted) {
x.usage = { tokens: Math.ceil(numCharge / formatted.length) };
}
}
assignMeta(formatted, { usage: { tokens: final } });
return final;