"""Rerankers API namespace — domain-specific logic on top of the generated base."""

from __future__ import annotations

from typing import Any

from goodmem._generated.api.rerankers_base import AsyncRerankersAPIBase, RerankersAPIBase
from goodmem.registries.convenience import apply_convenience_transforms


class RerankersAPI(RerankersAPIBase):
    """Rerankers API with GoodMem convenience defaults.

    Extends ``RerankersAPIBase`` with:

    - **Model registry**: auto-infers ``provider_type``, ``endpoint_url``, and
      ``supported_modalities`` from ``model_identifier`` for 16 known models.
    - **api_key shorthand**: ``api_key="sk-..."`` converts to the full ``credentials`` structure.
    - **Endpoint URL inference**: ``endpoint_url`` is inferred from ``provider_type`` when not set.
    """

    def create(self, **kwargs: Any) -> Any:
        apply_convenience_transforms(("rerankers", "create"), kwargs)
        return super().create(**kwargs)


class AsyncRerankersAPI(AsyncRerankersAPIBase):
    """Async Rerankers API with GoodMem convenience defaults. See ``RerankersAPI``."""

    async def create(self, **kwargs: Any) -> Any:
        apply_convenience_transforms(("rerankers", "create"), kwargs)
        return await super().create(**kwargs)
