mirror of
https://github.com/praveentcom/openproxy.git
synced 2026-02-12 14:02:46 +00: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
parent
308a251056
commit
eeebf1c6e9
4
cost.ts
4
cost.ts
@@ -166,7 +166,7 @@ export function getCostConfig(model: string): CostConfig {
|
||||
* Check Helicone costs with operator matching
|
||||
*/
|
||||
const exactMatch = heliconeCosts.get(normalizedModel);
|
||||
if (exactMatch && exactMatch.operator === "equals") {
|
||||
if (exactMatch?.operator === "equals") {
|
||||
return exactMatch.config;
|
||||
}
|
||||
|
||||
@@ -229,5 +229,5 @@ export function calculateCost(
|
||||
(completion_tokens / 1_000_000) * cost.output;
|
||||
|
||||
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