Match every internal model name to the best upstream candidate. Priority: exact match > seed alias > learned alias > fuzzy match.
(self)
| 415 | return 0 |
| 416 | |
| 417 | def _build_map(self) -> None: |
| 418 | """Match every internal model name to the best upstream candidate. |
| 419 | |
| 420 | Priority: exact match > seed alias > learned alias > fuzzy match. |
| 421 | """ |
| 422 | from uncommon_route.router.config import DEFAULT_MODEL_PRICING |
| 423 | |
| 424 | self._map.clear() |
| 425 | for internal in DEFAULT_MODEL_PRICING: |
| 426 | if internal in self._upstream_models: |
| 427 | continue |
| 428 | alias = self._seed_alias_match(internal) |
| 429 | if alias: |
| 430 | self._map[internal] = alias |
| 431 | continue |
| 432 | if internal in self._learned_aliases: |
| 433 | candidate = self._learned_aliases[internal] |
| 434 | if candidate in self._upstream_models: |
| 435 | self._map[internal] = candidate |
| 436 | continue |
| 437 | match = self._fuzzy_match(internal) |
| 438 | if match: |
| 439 | self._map[internal] = match |
| 440 | |
| 441 | def _seed_alias_match(self, internal: str) -> str | None: |
| 442 | """Check seed alias table for known renames.""" |