nomagick commited on
Commit
e953c01
·
unverified ·
1 Parent(s): e9d69e6

fix: formatted usage entry

Browse files
Files changed (1) hide show
  1. src/api/searcher-serper.ts +7 -1
src/api/searcher-serper.ts CHANGED
@@ -454,7 +454,6 @@ export class SearcherHost extends RPCHost {
454
  const itemAmount = this.crawler.assignChargeAmount(x) || 0;
455
 
456
  if (!itemAmount) {
457
- Reflect.deleteProperty(x, 'usage');
458
  continue;
459
  }
460
 
@@ -465,6 +464,13 @@ export class SearcherHost extends RPCHost {
465
 
466
  const final = Math.max(contentCharge, numCharge);
467
 
 
 
 
 
 
 
 
468
  assignMeta(formatted, { usage: { tokens: final } });
469
 
470
  return final;
 
454
  const itemAmount = this.crawler.assignChargeAmount(x) || 0;
455
 
456
  if (!itemAmount) {
 
457
  continue;
458
  }
459
 
 
464
 
465
  const final = Math.max(contentCharge, numCharge);
466
 
467
+ if (final === numCharge) {
468
+ for (const x of formatted) {
469
+ x.usage = { tokens: Math.ceil(numCharge / formatted.length) };
470
+ }
471
+ }
472
+
473
+
474
  assignMeta(formatted, { usage: { tokens: final } });
475
 
476
  return final;