mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Requesty: Only report final usage (#3542)
This commit is contained in:
parent
f6cae4df05
commit
a14b655590
2 changed files with 12 additions and 1 deletions
5
.changeset/twelve-ants-scream.md
Normal file
5
.changeset/twelve-ants-scream.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"roo-cline": patch
|
||||
---
|
||||
|
||||
Requesty: Fix token usage counts
|
||||
|
|
@ -101,6 +101,8 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
|
|||
|
||||
const stream = await this.client.chat.completions.create(completionParams)
|
||||
|
||||
let lastUsage: any = undefined
|
||||
|
||||
for await (const chunk of stream) {
|
||||
const delta = chunk.choices[0]?.delta
|
||||
if (delta?.content) {
|
||||
|
|
@ -118,9 +120,13 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
|
|||
}
|
||||
|
||||
if (chunk.usage) {
|
||||
yield this.processUsageMetrics(chunk.usage, model.info)
|
||||
lastUsage = chunk.usage
|
||||
}
|
||||
}
|
||||
|
||||
if (lastUsage) {
|
||||
yield this.processUsageMetrics(lastUsage, model.info)
|
||||
}
|
||||
}
|
||||
|
||||
async completePrompt(prompt: string): Promise<string> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue