
    P1i                         d Z ddlZddlZddlmZmZ ddlmZmZm	Z	m
Z
mZ ddlmZ  ej                  e      Z G d de      Zy)z0
Abstract base class for LLM service providers.
    N)ABCabstractmethod)DictListOptionalAnyUnion)settingsc                       e Zd ZdZddee   dee   fdZe	 	 	 	 ddedee   ded	e	d
edefd       Z
ededefd       Zedeeef   fd       Zy)
LLMServicez8
    Abstract base class for LLM service providers.
    Napi_keymodelc                      || _         || _        y)z
        Initialize the LLM service with API key and model.
        
        Args:
            api_key: API key for the service
            model: Model to use
        N)r   r   )selfr   r   s      9/home/cursorai/projects/iching/ai/services/llm_service.py__init__zLLMService.__init__   s     
    promptsystem_prompttemperature
max_tokenstop_preturnc                      y)a  
        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
        N )r   r   r   r   r   r   s         r   get_completionzLLMService.get_completion   s    ( 	r   	model_keyc                      y)z
        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
        Nr   )r   r   s     r   change_modelzLLMService.change_model1   s     	r   c                      y)z
        Get a dictionary of available models.
        
        Returns:
            Dictionary with model keys and their corresponding model IDs
        Nr   )r   s    r   get_available_modelszLLMService.get_available_models>   s     	r   )NN)Ngffffff?i   g?)__name__
__module____qualname____doc__r   strr   r   floatintr   boolr   r   r!   r   r   r   r   r      s    	 	Xc] 	  6:+.(,%(!%-c] $) #&	
 #
 .1 * 
c 
d 
 
 d38n  r   r   )r%   osloggingabcr   r   typingr   r   r   r   r	   django.confr
   	getLoggerr"   loggerr   r   r   r   <module>r1      s<    
  # 3 3  			8	$: :r   