- {i18next.t('输入价格:${{price}} / 1M tokens', { + {i18next.t('输入价格:${{price}} / 1M tokens{{audioPrice}}', { price: inputRatioPrice, + audioPrice: audioInputSeperatePrice + ? `,音频 $${audioInputPrice} / 1M tokens` + : '', })}
@@ -817,96 +899,93 @@ export function renderModelPrice( )}
- {cacheTokens > 0 && !image && !webSearch && !fileSearch - ? i18next.t( - '输入 {{nonCacheInput}} tokens / 1M tokens * ${{price}} + 缓存 {{cacheInput}} tokens / 1M tokens * ${{cachePrice}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} = ${{total}}', - { - nonCacheInput: inputTokens - cacheTokens, - cacheInput: cacheTokens, - cachePrice: inputRatioPrice * cacheRatio, - price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, - ratio: groupRatio, - total: price.toFixed(6), - }, - ) - : image && imageOutputTokens > 0 && !webSearch && !fileSearch - ? i18next.t( - '输入 {{nonImageInput}} tokens + 图片输入 {{imageInput}} tokens * {{imageRatio}} / 1M tokens * ${{price}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} = ${{total}}', + {(() => { + // 构建输入部分描述 + let inputDesc = ''; + if (image && imageOutputTokens > 0) { + inputDesc = i18next.t( + '(输入 {{nonImageInput}} tokens + 图片输入 {{imageInput}} tokens * {{imageRatio}} / 1M tokens * ${{price}}', { nonImageInput: inputTokens - imageOutputTokens, imageInput: imageOutputTokens, imageRatio: imageRatio, price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, - ratio: groupRatio, - total: price.toFixed(6), }, - ) - : webSearch && webSearchCallCount > 0 && !image && !fileSearch + ); + } else if (cacheTokens > 0) { + inputDesc = i18next.t( + '(输入 {{nonCacheInput}} tokens / 1M tokens * ${{price}} + 缓存 {{cacheInput}} tokens / 1M tokens * ${{cachePrice}}', + { + nonCacheInput: inputTokens - cacheTokens, + cacheInput: cacheTokens, + price: inputRatioPrice, + cachePrice: cacheRatioPrice, + }, + ); + } else if (audioInputSeperatePrice && audioInputTokens > 0) { + inputDesc = i18next.t( + '(输入 {{nonAudioInput}} tokens / 1M tokens * ${{price}} + 音频输入 {{audioInput}} tokens / 1M tokens * ${{audioPrice}}', + { + nonAudioInput: inputTokens - audioInputTokens, + audioInput: audioInputTokens, + price: inputRatioPrice, + audioPrice: audioInputPrice, + }, + ); + } else { + inputDesc = i18next.t( + '(输入 {{input}} tokens / 1M tokens * ${{price}}', + { + input: inputTokens, + price: inputRatioPrice, + }, + ); + } + + // 构建输出部分描述 + const outputDesc = i18next.t( + '输出 {{completion}} tokens / 1M tokens * ${{compPrice}}) * 分组倍率 {{ratio}}', + { + completion: completionTokens, + compPrice: completionRatioPrice, + ratio: groupRatio, + }, + ); + + // 构建额外服务描述 + const extraServices = [ + webSearch && webSearchCallCount > 0 ? i18next.t( - '输入 {{input}} tokens / 1M tokens * ${{price}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} + Web搜索 {{webSearchCallCount}}次 / 1K 次 * ${{webSearchPrice}} * {{ratio}} = ${{total}}', - { - input: inputTokens, - price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, - ratio: groupRatio, - webSearchCallCount, - webSearchPrice, - total: price.toFixed(6), - }, - ) - : fileSearch && - fileSearchCallCount > 0 && - !image && - !webSearch - ? i18next.t( - '输入 {{input}} tokens / 1M tokens * ${{price}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} + 文件搜索 {{fileSearchCallCount}}次 / 1K 次 * ${{fileSearchPrice}} * {{ratio}}= ${{total}}', + ' + Web搜索 {{count}}次 / 1K 次 * ${{price}} * 分组倍率 {{ratio}}', { - input: inputTokens, - price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, + count: webSearchCallCount, + price: webSearchPrice, ratio: groupRatio, - fileSearchCallCount, - fileSearchPrice, - total: price.toFixed(6), }, ) - : webSearch && - webSearchCallCount > 0 && - fileSearch && - fileSearchCallCount > 0 && - !image - ? i18next.t( - '输入 {{input}} tokens / 1M tokens * ${{price}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} + Web搜索 {{webSearchCallCount}}次 / 1K 次 * ${{webSearchPrice}} * {{ratio}}+ 文件搜索 {{fileSearchCallCount}}次 / 1K 次 * ${{fileSearchPrice}} * {{ratio}}= ${{total}}', - { - input: inputTokens, - price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, - ratio: groupRatio, - webSearchCallCount, - webSearchPrice, - fileSearchCallCount, - fileSearchPrice, - total: price.toFixed(6), - }, - ) - : i18next.t( - '输入 {{input}} tokens / 1M tokens * ${{price}} + 输出 {{completion}} tokens / 1M tokens * ${{compPrice}} * 分组 {{ratio}} = ${{total}}', - { - input: inputTokens, - price: inputRatioPrice, - completion: completionTokens, - compPrice: completionRatioPrice, - ratio: groupRatio, - total: price.toFixed(6), - }, - )} + : '', + fileSearch && fileSearchCallCount > 0 + ? i18next.t( + ' + 文件搜索 {{count}}次 / 1K 次 * ${{price}} * 分组倍率 {{ratio}}', + { + count: fileSearchCallCount, + price: fileSearchPrice, + ratio: groupRatio, + }, + ) + : '', + ].join(''); + + return i18next.t( + '{{inputDesc}} + {{outputDesc}}{{extraServices}} = ${{total}}', + { + inputDesc, + outputDesc, + extraServices, + total: price.toFixed(6), + }, + ); + })()}
{i18next.t('仅供参考,以实际扣费为准')}