mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Accommodate Chutes.ai / sglang parsing
This commit is contained in:
@@ -410,7 +410,7 @@ function _fromOpenAIUsage(usage: OpenAIWire_API_Chat_Completions.Response['usage
|
||||
// Input Metrics
|
||||
|
||||
// Input redistribution: Cache Read
|
||||
if (usage.prompt_tokens_details !== undefined) {
|
||||
if (usage.prompt_tokens_details) {
|
||||
const TCacheRead = usage.prompt_tokens_details.cached_tokens;
|
||||
if (TCacheRead !== undefined && TCacheRead > 0) {
|
||||
metricsUpdate.TCacheRead = TCacheRead;
|
||||
@@ -434,8 +434,11 @@ function _fromOpenAIUsage(usage: OpenAIWire_API_Chat_Completions.Response['usage
|
||||
// Output Metrics
|
||||
|
||||
// Output breakdown: Reasoning
|
||||
if (usage.completion_tokens_details?.reasoning_tokens !== undefined)
|
||||
metricsUpdate.TOutR = usage.completion_tokens_details.reasoning_tokens;
|
||||
if (usage.completion_tokens_details) {
|
||||
const details = usage.completion_tokens_details || {};
|
||||
if (details.reasoning_tokens !== undefined)
|
||||
metricsUpdate.TOutR = usage.completion_tokens_details.reasoning_tokens;
|
||||
}
|
||||
|
||||
// TODO: Output breakdown: Audio
|
||||
|
||||
|
||||
@@ -394,7 +394,8 @@ export namespace OpenAIWire_API_Chat_Completions {
|
||||
prompt_tokens_details: z.object({
|
||||
audio_tokens: z.number().optional(),
|
||||
cached_tokens: z.number().optional(),
|
||||
}).optional(),
|
||||
}).optional()
|
||||
.nullable(), // [2025-06-02] Chutes.ai using slang server returns null for prompt_tokens_details
|
||||
|
||||
// [OpenAI o1, 2024-09-12] breaks down the completion tokens into components
|
||||
completion_tokens_details: z.object({
|
||||
@@ -403,7 +404,8 @@ export namespace OpenAIWire_API_Chat_Completions {
|
||||
audio_tokens: z.number().optional(), // [OpenAI, 2024-10-01] audio tokens used in the completion (charged at a different rate)
|
||||
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
|
||||
}).optional() // not present in other APIs yet
|
||||
.nullable(), // [2025-06-02] no issues yet, but preventive
|
||||
|
||||
// [DeepSeek, 2024-08-02] context caching on disk
|
||||
prompt_cache_hit_tokens: z.number().optional(),
|
||||
|
||||
Reference in New Issue
Block a user