"""
Base LLM interface
"""

from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Dict, List, Optional


@dataclass
class LLMResponse:
    """Unified response from an LLM generation call.

    Holds text output and optional image output.
    """

    text: str = ""
    image_path: Optional[str] = None


class LLMInterface(ABC):
    """Abstract base class for LLM interfaces"""

    @abstractmethod
    async def generate(
        self, system_message: str, messages: List[Dict[str, Any]], **kwargs
    ) -> str:
        """Generate a text response using a system message and conversational context.

        Messages can contain multimodal content (text + images) when the
        content field is a list of content parts instead of a plain string.

        Returns:
            The generated text.
        """
        pass

    async def generate_image(
        self, system_message: str, messages: List[Dict[str, Any]], **kwargs
    ) -> LLMResponse:
        """Generate text + image using native image generation.

        Kwargs:
            output_dir (str): Directory to save generated images.
            program_id (str): ID for naming the image file.

        Returns:
            LLMResponse with text and image_path.
        """
        raise NotImplementedError(
            f"{type(self).__name__} does not support image generation"
        )
