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

from __future__ import annotations

from typing import Any

from goodmem._generated.api.embedders_base import AsyncEmbeddersAPIBase, EmbeddersAPIBase
from goodmem.registries.convenience import apply_convenience_transforms


class EmbeddersAPI(EmbeddersAPIBase):
    """Embedders API with GoodMem convenience defaults.

    Extends ``EmbeddersAPIBase`` with:

    - **Model registry**: auto-infers ``provider_type``, ``endpoint_url``, ``dimensions``,
      ``max_sequence_length``, ``supported_modalities``, and ``distribution_type`` from
      ``model_identifier`` for 29 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.
    - **Default distribution_type**: defaults to ``"DENSE"`` when not specified.
    """

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


class AsyncEmbeddersAPI(AsyncEmbeddersAPIBase):
    """Async Embedders API with GoodMem convenience defaults. See ``EmbeddersAPI``."""

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