|
|
|
@@ -652,16 +652,29 @@ export const calculateModelPrice = ({ |
|
|
|
const completionRatioPriceUSD = |
|
|
|
record.model_ratio * record.completion_ratio * 2 * usedGroupRatio; |
|
|
|
|
|
|
|
// 缓存读取价格 = 输入价格 × 缓存倍率(默认 1 表示与输入价格相同) |
|
|
|
const cacheRatio = record.cache_ratio ?? 1; |
|
|
|
const cacheRatioPriceUSD = inputRatioPriceUSD * cacheRatio; |
|
|
|
// 缓存创建价格 = 输入价格 × 缓存创建倍率(默认 1.25) |
|
|
|
const cacheCreationRatio = record.cache_creation_ratio ?? 1.25; |
|
|
|
const cacheCreationRatioPriceUSD = inputRatioPriceUSD * cacheCreationRatio; |
|
|
|
|
|
|
|
const unitDivisor = tokenUnit === 'K' ? 1000 : 1; |
|
|
|
const unitLabel = tokenUnit === 'K' ? 'K' : 'M'; |
|
|
|
|
|
|
|
const rawDisplayInput = displayPrice(inputRatioPriceUSD); |
|
|
|
const rawDisplayCompletion = displayPrice(completionRatioPriceUSD); |
|
|
|
const rawDisplayCache = displayPrice(cacheRatioPriceUSD); |
|
|
|
const rawDisplayCacheCreation = displayPrice(cacheCreationRatioPriceUSD); |
|
|
|
|
|
|
|
const numInput = |
|
|
|
parseFloat(rawDisplayInput.replace(/[^0-9.]/g, '')) / unitDivisor; |
|
|
|
const numCompletion = |
|
|
|
parseFloat(rawDisplayCompletion.replace(/[^0-9.]/g, '')) / unitDivisor; |
|
|
|
const numCache = |
|
|
|
parseFloat(rawDisplayCache.replace(/[^0-9.]/g, '')) / unitDivisor; |
|
|
|
const numCacheCreation = |
|
|
|
parseFloat(rawDisplayCacheCreation.replace(/[^0-9.]/g, '')) / unitDivisor; |
|
|
|
|
|
|
|
let symbol = '$'; |
|
|
|
if (currency === 'CNY') { |
|
|
|
@@ -683,6 +696,10 @@ export const calculateModelPrice = ({ |
|
|
|
return { |
|
|
|
inputPrice: `${symbol}${numInput.toFixed(precision)}`, |
|
|
|
completionPrice: `${symbol}${numCompletion.toFixed(precision)}`, |
|
|
|
cachePrice: `${symbol}${numCache.toFixed(precision)}`, |
|
|
|
cacheCreationPrice: `${symbol}${numCacheCreation.toFixed(precision)}`, |
|
|
|
cacheRatio, |
|
|
|
cacheCreationRatio, |
|
|
|
unitLabel, |
|
|
|
isPerToken: true, |
|
|
|
usedGroup, |
|
|
|
|