-
Notifications
You must be signed in to change notification settings - Fork 57
Add cache_write_tokens mapping to UsageExtractor #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -928,6 +928,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -1313,6 +1316,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
|
Comment on lines
1317
to
+1321
|
||
| UsageExtractorMapping( | ||
| path=['completion_tokens_details', 'audio_tokens'], dest='output_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -1393,6 +1399,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['completion_tokens_details', 'audio_tokens'], dest='output_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -1596,6 +1605,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2247,6 +2259,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2289,6 +2304,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2348,6 +2366,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2426,6 +2447,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2593,6 +2617,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -2914,6 +2941,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -3637,6 +3667,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -3882,6 +3915,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -3984,6 +4020,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -4101,6 +4140,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -4218,6 +4260,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -4705,6 +4750,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping(path='completion_tokens', dest='output_tokens', required=True), | ||
| ], | ||
| api_flavor='chat', | ||
|
|
@@ -5005,6 +5053,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
|
Comment on lines
5054
to
+5058
|
||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -9402,6 +9453,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'audio_tokens'], dest='input_audio_tokens', required=False | ||
| ), | ||
|
|
@@ -10036,6 +10090,9 @@ | |
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cached_tokens'], dest='cache_read_tokens', required=False | ||
| ), | ||
| UsageExtractorMapping( | ||
| path=['prompt_tokens_details', 'cache_write_tokens'], dest='cache_write_tokens', required=False | ||
| ), | ||
|
Comment on lines
10091
to
+10095
|
||
| UsageExtractorMapping( | ||
| path=['completion_tokens_details', 'audio_tokens'], dest='output_audio_tokens', required=False | ||
| ), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure’s chat extractor now maps
usage.prompt_tokens_details.cache_write_tokensintocache_write_tokens, but Azure/OpenAI-priced models in this file don’t definecache_write_mtok. Sincecache_write_tokensare subtracted from uncached input and priced viacache_write_mtok, a non-zero value from the API would undercharge. Consider only extracting this field when acache_write_mtokis defined (or ensure the pricing model includes the appropriate cache-write rate).