File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " roo-cline " : patch
3+ ---
4+
5+ Requesty: Fix token usage counts
Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
101101
102102 const stream = await this . client . chat . completions . create ( completionParams )
103103
104+ let lastUsage : any = undefined
105+
104106 for await ( const chunk of stream ) {
105107 const delta = chunk . choices [ 0 ] ?. delta
106108 if ( delta ?. content ) {
@@ -118,9 +120,13 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
118120 }
119121
120122 if ( chunk . usage ) {
121- yield this . processUsageMetrics ( chunk . usage , model . info )
123+ lastUsage = chunk . usage
122124 }
123125 }
126+
127+ if ( lastUsage ) {
128+ yield this . processUsageMetrics ( lastUsage , model . info )
129+ }
124130 }
125131
126132 async completePrompt ( prompt : string ) : Promise < string > {
You can’t perform that action at this time.
0 commit comments