Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
6032c82f
Unverified
Commit
6032c82f
authored
Jun 25, 2025
by
Zhongdongming Dai
Committed by
GitHub
Jun 25, 2025
Browse files
fix: fix usage.total_tokens count for OpenAI endpoints (#1649)
parent
b4aa67a6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
lib/llm/src/protocols/openai/chat_completions/delta.rs
lib/llm/src/protocols/openai/chat_completions/delta.rs
+6
-1
lib/llm/src/protocols/openai/completions/delta.rs
lib/llm/src/protocols/openai/completions/delta.rs
+6
-1
No files found.
lib/llm/src/protocols/openai/chat_completions/delta.rs
View file @
6032c82f
...
...
@@ -150,6 +150,11 @@ impl DeltaGenerator {
let
choices
=
vec!
[
choice
];
let
mut
usage
=
self
.usage
.clone
();
if
self
.options.enable_usage
{
usage
.total_tokens
=
usage
.prompt_tokens
+
usage
.completion_tokens
;
}
async_openai
::
types
::
CreateChatCompletionStreamResponse
{
id
:
self
.id
.clone
(),
object
:
self
.object
.clone
(),
...
...
@@ -158,7 +163,7 @@ impl DeltaGenerator {
system_fingerprint
:
self
.system_fingerprint
.clone
(),
choices
,
usage
:
if
self
.options.enable_usage
{
Some
(
self
.usage
.clone
()
)
Some
(
usage
)
}
else
{
None
},
...
...
lib/llm/src/protocols/openai/completions/delta.rs
View file @
6032c82f
...
...
@@ -86,6 +86,11 @@ impl DeltaGenerator {
)
->
CompletionResponse
{
// todo - update for tool calling
let
mut
usage
=
self
.usage
.clone
();
if
self
.options.enable_usage
{
usage
.total_tokens
=
usage
.prompt_tokens
+
usage
.completion_tokens
;
}
CompletionResponse
{
id
:
self
.id
.clone
(),
object
:
self
.object
.clone
(),
...
...
@@ -99,7 +104,7 @@ impl DeltaGenerator {
logprobs
:
None
,
}],
usage
:
if
self
.options.enable_usage
{
Some
(
self
.usage
.clone
()
)
Some
(
usage
)
}
else
{
None
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment