From e953c01e5873c2af80eeb658eee1a8f2f33648f2 Mon Sep 17 00:00:00 2001 From: "yanlong.wang" Date: Wed, 26 Mar 2025 14:07:36 +0800 Subject: [PATCH] fix: formatted usage entry --- src/api/searcher-serper.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/searcher-serper.ts b/src/api/searcher-serper.ts index b0bf1c5..c80229b 100644 --- a/src/api/searcher-serper.ts +++ b/src/api/searcher-serper.ts @@ -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;