DeepSeek: cache pricing support

This commit is contained in:
Enrico Ros
2024-12-29 23:54:54 -08:00
parent c18be131a1
commit 9bfcb50735
2 changed files with 14 additions and 0 deletions
@@ -339,6 +339,16 @@ function _fromOpenAIUsage(usage: OpenAIWire_API_Chat_Completions.Response['usage
}
}
// [DeepSeek] Input redistribution: Cache Read
if (usage.prompt_cache_hit_tokens !== undefined) {
const TCacheRead = usage.prompt_cache_hit_tokens;
if (TCacheRead > 0) {
metricsUpdate.TCacheRead = TCacheRead;
if (usage.prompt_cache_miss_tokens !== undefined)
metricsUpdate.TIn = usage.prompt_cache_miss_tokens;
}
}
// TODO Input redistribution: Audio tokens
// Output Metrics
@@ -384,6 +384,10 @@ export namespace OpenAIWire_API_Chat_Completions {
accepted_prediction_tokens: z.number().optional(), // [OpenAI, 2024-11-05] Predicted Outputs
rejected_prediction_tokens: z.number().optional(), // [OpenAI, 2024-11-05] Predicted Outputs
}).optional(), // not present in other APIs yet
// [DeepSeek, 2024-08-02] context caching on disk
prompt_cache_hit_tokens: z.number().optional(),
prompt_cache_miss_tokens: z.number().optional(),
}).nullable();
const Choice_NS_schema = z.object({