"""
LLM Client base interface.
"""

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


@dataclass
class LLMResponse:
    """Response from an LLM."""
    content: str
    model: str
    tokens_used: int = 0
    metadata: Dict[str, Any] = None
    
    def __post_init__(self):
        if self.metadata is None:
            self.metadata = {}


class LLMClient(ABC):
    """
    Abstract base class for LLM clients.
    
    Implement this to add support for different LLM providers.
    """
    
    def __init__(
        self,
        model: str,
        base_url: Optional[str] = None,
        timeout: int = 300,
        **kwargs
    ):
        self.model = model
        self.base_url = base_url
        self.timeout = timeout
        self.config = kwargs
    
    @abstractmethod
    def generate(
        self,
        prompt: str,
        system_prompt: Optional[str] = None,
        model: Optional[str] = None,
        **kwargs
    ) -> LLMResponse:
        """
        Generate a response from the LLM.
        
        Args:
            prompt: The user prompt
            system_prompt: Optional system prompt
            model: Model override (uses default if not provided)
            **kwargs: Additional provider-specific options
            
        Returns:
            LLMResponse with the generated content
        """
        pass
    
    @abstractmethod
    def is_available(self) -> bool:
        """Check if the LLM service is available."""
        pass
    
    def get_model(self, override: Optional[str] = None) -> str:
        """Get model name, with optional override."""
        return override or self.model
