mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Yields the usage tokens
This commit is contained in:
@@ -96,6 +96,7 @@ export class UnboundHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
|
|
||||||
for await (const chunk of completion) {
|
for await (const chunk of completion) {
|
||||||
const delta = chunk.choices[0]?.delta
|
const delta = chunk.choices[0]?.delta
|
||||||
|
const usage = chunk.usage
|
||||||
|
|
||||||
if (delta?.content) {
|
if (delta?.content) {
|
||||||
yield {
|
yield {
|
||||||
@@ -103,6 +104,14 @@ export class UnboundHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
text: delta.content,
|
text: delta.content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usage) {
|
||||||
|
yield {
|
||||||
|
type: "usage",
|
||||||
|
inputTokens: usage?.prompt_tokens || 0,
|
||||||
|
outputTokens: usage?.completion_tokens || 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user