Skip to content

Commit

Permalink
DeepSeek: cache pricing support
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Dec 30, 2024
1 parent c18be13 commit 9bfcb50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/modules/aix/server/dispatch/wiretypes/openai.wiretypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 9bfcb50

Please sign in to comment.