mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-07-30 08:12:00 +08:00
fix: formatted usage entry
This commit is contained in:
parent
e9d69e6201
commit
e953c01e58
@ -454,7 +454,6 @@ export class SearcherHost extends RPCHost {
|
|||||||
const itemAmount = this.crawler.assignChargeAmount(x) || 0;
|
const itemAmount = this.crawler.assignChargeAmount(x) || 0;
|
||||||
|
|
||||||
if (!itemAmount) {
|
if (!itemAmount) {
|
||||||
Reflect.deleteProperty(x, 'usage');
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +464,13 @@ export class SearcherHost extends RPCHost {
|
|||||||
|
|
||||||
const final = Math.max(contentCharge, numCharge);
|
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 } });
|
assignMeta(formatted, { usage: { tokens: final } });
|
||||||
|
|
||||||
return final;
|
return final;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user