Log-scale cost normalization. Uses log(1 + cost) to prevent free models from having an absolute cost advantage. The gap between $0 and $0.30 is compressed vs linear.
(
models: list[str],
pricing: dict[str, ModelPricing],
)
| 1055 | |
| 1056 | |
| 1057 | def _normalized_costs( |
| 1058 | models: list[str], |
| 1059 | pricing: dict[str, ModelPricing], |
| 1060 | ) -> dict[str, float]: |
| 1061 | """Log-scale cost normalization. |
| 1062 | |
| 1063 | Uses log(1 + cost) to prevent free models from having an absolute |
| 1064 | cost advantage. The gap between $0 and $0.30 is compressed vs linear. |
| 1065 | """ |
| 1066 | raw = {} |
| 1067 | for m in models: |
| 1068 | mp = _pricing_for_model(m, pricing) |
| 1069 | raw[m] = math.log1p(mp.input_price + mp.output_price) |
| 1070 | if not raw: |
| 1071 | return {} |
| 1072 | lo = min(raw.values()) |
| 1073 | hi = max(raw.values()) |
| 1074 | span = hi - lo |
| 1075 | if span <= 0: |
| 1076 | return {m: 0.5 for m in models} |
| 1077 | return {m: (raw[m] - lo) / span for m in models} |
| 1078 | |
| 1079 | |
| 1080 | def _pressure_rescue_note( |
nothing calls this directly
no test coverage detected