[Bugfix] Fix --enable-prompt-tokens-details omitting zero cached tokens (#44383)
Signed-off-by: Sasindharan Sankar <sasindharansankar@email.com> Co-authored-by: Sasindharan Sankar <sasindharansankar@email.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
This commit is contained in:
co-authored by
Sasindharan Sankar
Chauncey
parent
2263f8a3de
commit
42ae5e7ac6
@@ -58,9 +58,12 @@ async def test_single_completion(client: openai.AsyncOpenAI, model_name: str) ->
|
||||
choice = completion.choices[0]
|
||||
assert len(choice.text) >= 5
|
||||
assert choice.finish_reason == "length"
|
||||
assert completion.usage == openai.types.CompletionUsage(
|
||||
completion_tokens=5, prompt_tokens=6, total_tokens=11
|
||||
)
|
||||
assert completion.usage is not None
|
||||
assert completion.usage.completion_tokens == 5
|
||||
assert completion.usage.prompt_tokens == 6
|
||||
assert completion.usage.total_tokens == 11
|
||||
assert completion.usage.prompt_tokens_details is not None
|
||||
assert completion.usage.prompt_tokens_details.cached_tokens == 0
|
||||
|
||||
# test using token IDs
|
||||
completion = await client.completions.create(
|
||||
|
||||
Reference in New Issue
Block a user