from __future__ import annotations

from dataclasses import dataclass
from typing import Optional
from enum import Enum

from analogai.foundation.infrastructure.services.embedding_service import EmbeddingService
from analogai.foundation.common.enums.embedding_type import EmbeddingType  # type: ignore[import-not-found]


@dataclass(frozen=True)
class EmbeddingConfig:
    provider_instance: Optional[EmbeddingService] = None
    embed_type: Optional[EmbeddingType] = None
    provider: Optional[str | Enum] = None
    model: Optional[str] = None

    def to_overrides(self) -> dict[str, str]:
        overrides: dict[str, str] = {}
        if self.embed_type:
            overrides["embed.type"] = self.embed_type.value
        if self.provider:
            provider_value = (
                self.provider.value
                if isinstance(self.provider, Enum)
                else self.provider
            )
            overrides["embed.provider"] = provider_value
        if self.model:
            overrides["embed.model"] = self.model
        return overrides
