Get a model by provider ID and model ID, with fuzzy matching on failure.
(
&self,
provider_id: &str,
model_id: &str,
)
| 1531 | |
| 1532 | /// Get a model by provider ID and model ID, with fuzzy matching on failure. |
| 1533 | pub fn get_model( |
| 1534 | &self, |
| 1535 | provider_id: &str, |
| 1536 | model_id: &str, |
| 1537 | ) -> Result<&ProviderModel, BootstrapError> { |
| 1538 | let provider = self.providers.get(provider_id).ok_or_else(|| { |
| 1539 | let available: Vec<String> = self.providers.keys().cloned().collect(); |
| 1540 | let suggestions = fuzzy_match(provider_id, &available, 3); |
| 1541 | BootstrapError::ModelNotFound { |
| 1542 | provider_id: provider_id.to_string(), |
| 1543 | model_id: model_id.to_string(), |
| 1544 | suggestions, |
| 1545 | } |
| 1546 | })?; |
| 1547 | |
| 1548 | provider.models.get(model_id).ok_or_else(|| { |
| 1549 | let available: Vec<String> = provider.models.keys().cloned().collect(); |
| 1550 | let suggestions = fuzzy_match(model_id, &available, 3); |
| 1551 | BootstrapError::ModelNotFound { |
| 1552 | provider_id: provider_id.to_string(), |
| 1553 | model_id: model_id.to_string(), |
| 1554 | suggestions, |
| 1555 | } |
| 1556 | }) |
| 1557 | } |
| 1558 | |
| 1559 | /// Find the closest matching model for a provider given a list of query strings. |
| 1560 | pub fn closest(&self, provider_id: &str, queries: &[&str]) -> Option<(String, String)> { |
no test coverage detected