Resolve a ``auth/ `` model name to its subscription handler.
(model: str)
| 39 | |
| 40 | |
| 41 | def _select_auth_handler(model: str) -> CustomLLM: |
| 42 | """Resolve a ``auth/<slug>`` model name to its subscription handler.""" |
| 43 | supported = ", ".join(f"{p}*" for p, _ in _PREFIX_HANDLERS) |
| 44 | if not isinstance(model, str) or not model.strip(): |
| 45 | # None / non-string / empty model: LiteLLM occasionally dispatches with |
| 46 | # the model passed neither positionally nor by keyword. Fail with a typed |
| 47 | # BadRequestError instead of letting ``.split`` raise a raw TypeError. |
| 48 | raise litellm.BadRequestError( |
| 49 | message=( |
| 50 | f"auth/ provider: missing or invalid model {model!r}. " |
| 51 | f"Expected a non-empty 'auth/<slug>' string. Supported prefixes: {supported}." |
| 52 | ), |
| 53 | model=str(model), |
| 54 | llm_provider="auth", |
| 55 | ) |
| 56 | slug = model.split("/", 1)[-1] if "/" in model else model |
| 57 | slug_lower = slug.lower() |
| 58 | for prefix, handler in _PREFIX_HANDLERS: |
| 59 | if slug_lower.startswith(prefix): |
| 60 | return handler |
| 61 | raise litellm.BadRequestError( |
| 62 | message=( |
| 63 | f"auth/ provider: model slug {slug!r} did not match any known " |
| 64 | f"subscription handler. Supported prefixes: {supported}." |
| 65 | ), |
| 66 | model=model, |
| 67 | llm_provider="auth", |
| 68 | ) |
| 69 | |
| 70 | |
| 71 | def _model_arg(args: tuple[Any, ...], kwargs: dict[str, Any]) -> str: |
no outgoing calls
no test coverage detected