mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
AIX: OpenaI parser: cleanup
This commit is contained in:
@@ -670,7 +670,9 @@ function _fromOpenAIUsage(usage: OpenAIWire_API_Chat_Completions.Response['usage
|
||||
|
||||
// Input redistribution: Cache Read
|
||||
if (usage.prompt_tokens_details) {
|
||||
const TCacheRead = usage.prompt_tokens_details.cached_tokens;
|
||||
// TODO Input redistribution: Audio tokens
|
||||
// const TAudioIn = usage.prompt_tokens_details.audio_tokens ?? undefined;
|
||||
const TCacheRead = usage.prompt_tokens_details.cached_tokens ?? undefined;
|
||||
if (TCacheRead !== undefined && TCacheRead > 0) {
|
||||
metricsUpdate.TCacheRead = TCacheRead;
|
||||
if (metricsUpdate.TIn !== undefined)
|
||||
@@ -688,18 +690,18 @@ function _fromOpenAIUsage(usage: OpenAIWire_API_Chat_Completions.Response['usage
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Input redistribution: Audio tokens
|
||||
|
||||
// Output Metrics
|
||||
|
||||
// Output breakdown: Reasoning
|
||||
if (usage.completion_tokens_details) {
|
||||
const details = usage.completion_tokens_details || {};
|
||||
if (details.reasoning_tokens !== undefined)
|
||||
metricsUpdate.TOutR = usage.completion_tokens_details.reasoning_tokens;
|
||||
const TOutReasoning = usage.completion_tokens_details.reasoning_tokens ?? undefined;
|
||||
if (TOutReasoning !== undefined)
|
||||
metricsUpdate.TOutR = TOutReasoning;
|
||||
// TODO: Output breakdown: Audio / Image
|
||||
// const TOutAudio = details.audio_tokens ?? undefined;
|
||||
// const TOutImage = details.image_tokens ?? undefined;
|
||||
}
|
||||
|
||||
// TODO: Output breakdown: Audio
|
||||
|
||||
// Upstream Cost Reporting
|
||||
|
||||
|
||||
@@ -514,11 +514,11 @@ export namespace OpenAIWire_API_Chat_Completions {
|
||||
// text_tokens: z.number().optional(), // [Discord, 2024-04-10] revealed as present on custom OpenAI endpoint - not using it here yet
|
||||
audio_tokens: z.number().optional() // [OpenAI, 2024-10-01] audio tokens used in the completion (charged at a different rate)
|
||||
.nullable(), // [Arcee, 2026-04-02]
|
||||
// image_tokens: z.number().optional(), // [OpenRouter, 2026-02-06] confirmed: image tokens in image generation output
|
||||
accepted_prediction_tokens: z.number().optional() // [OpenAI, 2024-11-05] Predicted Outputs
|
||||
.nullable(), // [Arcee, 2026-04-02]
|
||||
rejected_prediction_tokens: z.number().optional() // [OpenAI, 2024-11-05] Predicted Outputs
|
||||
image_tokens: z.number().optional() // [OpenRouter, 2026-02-06] confirmed: image tokens in image generation output
|
||||
.nullable(), // [Arcee, 2026-04-02]
|
||||
// DO-NOT-CARE: we do NOT care at all about these, for predicted outputs (probably unsupported now)
|
||||
// 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
|
||||
.nullable(), // [2025-06-02] no issues yet, but preventive
|
||||
|
||||
@@ -636,8 +636,8 @@ export namespace OpenAIWire_API_Chat_Completions {
|
||||
|
||||
// [Perplexity] String array of citations, the first element is the first reference, i.e. '[1]'.
|
||||
// DEPRECATED: The citations field is being deprecated in favor of the new search_results field
|
||||
citations: z.array(z.any()).optional()
|
||||
.nullable(), // [Arcee, 2026-04-02]
|
||||
// citations: z.array(z.any()).optional()
|
||||
// .nullable(), // [Arcee, 2026-04-02]
|
||||
// [Perplexity, 2025-06-23] Search results
|
||||
search_results: z.array(z.object({
|
||||
title: z.string().optional().nullable(), // Title of the search result
|
||||
@@ -810,8 +810,8 @@ export namespace OpenAIWire_API_Chat_Completions {
|
||||
|
||||
// [Perplexity] String array of citations, the first element is the first reference, i.e. '[1]'.
|
||||
// DEPRECATED: The citations field is being deprecated in favor of the new search_results field
|
||||
citations: z.array(z.any()).optional()
|
||||
.nullable(), // [Arcee, 2026-04-02]
|
||||
// citations: z.array(z.any()).optional()
|
||||
// .nullable(), // [Arcee, 2026-04-02]
|
||||
// [Perplexity, 2025-06-23] Search results
|
||||
search_results: z.array(z.object({
|
||||
title: z.string().optional().nullable(), // Title of the search result
|
||||
|
||||
Reference in New Issue
Block a user