"""
Abstract base class for LLM service providers.
"""
import os
import logging
from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Any, Union
from django.conf import settings

logger = logging.getLogger(__name__)

class LLMService(ABC):
    """
    Abstract base class for LLM service providers.
    """
    def __init__(self, api_key: Optional[str] = None, model: Optional[str] = None):
        """
        Initialize the LLM service with API key and model.
        
        Args:
            api_key: API key for the service
            model: Model to use
        """
        self.api_key = api_key
        self.model = model
    
    @abstractmethod
    def get_completion(self, 
                      prompt: str, 
                      system_prompt: Optional[str] = None,
                      temperature: float = 0.7,
                      max_tokens: int = 4096,
                      top_p: float = 0.9) -> str:
        """
        Get a text completion from the LLM.
        
        Args:
            prompt: The user prompt to send to the model
            system_prompt: Optional system prompt to set context
            temperature: Controls randomness (0-1), lower is more deterministic
            max_tokens: Maximum number of tokens to generate
            top_p: Nucleus sampling parameter
            
        Returns:
            The text response from the model
        """
        pass
    
    @abstractmethod
    def change_model(self, model_key: str) -> bool:
        """
        Change the model being used by the service.
        
        Args:
            model_key: Key from the service's models dictionary in settings
            
        Returns:
            True if successful, False otherwise
        """
        pass
    
    @abstractmethod
    def get_available_models(self) -> Dict[str, str]:
        """
        Get a dictionary of available models.
        
        Returns:
            Dictionary with model keys and their corresponding model IDs
        """
        pass 