mirror of
https://github.com/praveentcom/openproxy.git
synced 2026-08-13 06:30:26 +02:00
fix(cost): use optional chaining for cost match and Number.parseFloat for fixed total
Co-authored-by: Genie <genie@cosine.sh>
This commit is contained in:
committed by
Genie
co-authored by
Genie
parent
308a251056
commit
eeebf1c6e9
@@ -166,7 +166,7 @@ export function getCostConfig(model: string): CostConfig {
|
|||||||
* Check Helicone costs with operator matching
|
* Check Helicone costs with operator matching
|
||||||
*/
|
*/
|
||||||
const exactMatch = heliconeCosts.get(normalizedModel);
|
const exactMatch = heliconeCosts.get(normalizedModel);
|
||||||
if (exactMatch && exactMatch.operator === "equals") {
|
if (exactMatch?.operator === "equals") {
|
||||||
return exactMatch.config;
|
return exactMatch.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,5 +229,5 @@ export function calculateCost(
|
|||||||
(completion_tokens / 1_000_000) * cost.output;
|
(completion_tokens / 1_000_000) * cost.output;
|
||||||
|
|
||||||
const total = inputCost + cachedCost + outputCost;
|
const total = inputCost + cachedCost + outputCost;
|
||||||
return total > 0 ? Number(total.toFixed(6)) : null;
|
return total > 0 ? Number.parseFloat(total.toFixed(6)) : null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user