(&mut self, models: FxHashMap<String, ModelsDevModel>)
| 313 | } |
| 314 | |
| 315 | fn load_models_dev_models(&mut self, models: FxHashMap<String, ModelsDevModel>) -> usize { |
| 316 | let mut loaded_count = 0; |
| 317 | for (model_key, model) in models { |
| 318 | let model_id = model.id.unwrap_or(model_key); |
| 319 | if self.entries.contains_key(&model_id) { |
| 320 | continue; |
| 321 | } |
| 322 | let Some(cost) = model.cost else { |
| 323 | continue; |
| 324 | }; |
| 325 | let Some(input) = cost.input else { |
| 326 | continue; |
| 327 | }; |
| 328 | let Some(output) = cost.output else { |
| 329 | continue; |
| 330 | }; |
| 331 | let input = input / 1_000_000.0; |
| 332 | let output = output / 1_000_000.0; |
| 333 | let cache_read_explicit = cost.cache_read.is_some(); |
| 334 | self.entries.insert( |
| 335 | model_id.clone(), |
| 336 | Pricing { |
| 337 | input, |
| 338 | output, |
| 339 | cache_create: cost |
| 340 | .cache_write |
| 341 | .map(|value| value / 1_000_000.0) |
| 342 | .unwrap_or(input * 1.25), |
| 343 | cache_read: cost |
| 344 | .cache_read |
| 345 | .map(|value| value / 1_000_000.0) |
| 346 | .unwrap_or(input * 0.1), |
| 347 | cache_read_explicit, |
| 348 | input_above_200k: None, |
| 349 | output_above_200k: None, |
| 350 | cache_create_above_200k: None, |
| 351 | cache_read_above_200k: None, |
| 352 | fast_multiplier: 1.0, |
| 353 | }, |
| 354 | ); |
| 355 | if let Some(context_limit) = model.limit.and_then(|limit| limit.context) { |
| 356 | self.context_limits.insert(model_id, context_limit); |
| 357 | } |
| 358 | loaded_count += 1; |
| 359 | } |
| 360 | loaded_count |
| 361 | } |
| 362 | |
| 363 | pub(crate) fn find(&self, model: &str) -> Option<Pricing> { |
| 364 | let alias = crate::model_aliases::resolve_model_name(model); |
no outgoing calls
no test coverage detected