Use conservative pricing for unknown models instead of treating them as free.
(model: str, pricing: dict[str, ModelPricing])
| 59 | |
| 60 | |
| 61 | def _pricing_for_model(model: str, pricing: dict[str, ModelPricing]) -> ModelPricing: |
| 62 | """Use conservative pricing for unknown models instead of treating them as free.""" |
| 63 | candidate = pricing.get(model) or DEFAULT_MODEL_PRICING.get(model) or _UNKNOWN_MODEL_PRICING |
| 64 | if ( |
| 65 | candidate.input_price < 0 |
| 66 | or candidate.output_price < 0 |
| 67 | or not math.isfinite(candidate.input_price) |
| 68 | or not math.isfinite(candidate.output_price) |
| 69 | ): |
| 70 | return _UNKNOWN_MODEL_PRICING |
| 71 | return candidate |
| 72 | |
| 73 | |
| 74 | def _stabilize_agent_step_selection(features: RoutingFeatures) -> bool: |
no test coverage detected