
    P1i                         d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ  ej                  e      Z G d	 d
      Zy)z-
Factory for creating LLM service instances.
    N)OptionalDictAny)settings   )
LLMService)GroqService)OpenAIServicec                   \    e Zd ZdZeddee   defd       Zede	ee	eef   f   fd       Z
y)LLMServiceFactoryz;
    Factory class for creating LLM service instances.
    Nproviderreturnc                     | t        t        dd      } | j                         } | dk(  r
t               S | dk(  r
t	               S t
        j                  d|         t        d|        )a  
        Get an LLM service instance based on provider.
        
        Args:
            provider: LLM provider name (e.g., 'groq', 'openai')
                     If None, uses settings.DEFAULT_LLM_PROVIDER
                     
        Returns:
            An instance of the appropriate LLM service
            
        Raises:
            ValueError: If the provider is not supported
        DEFAULT_LLM_PROVIDERgroqopenaizUnsupported LLM provider: )getattrr   lowerr	   r
   loggererror
ValueError)r   s    5/home/cursorai/projects/iching/ai/services/factory.pyget_servicezLLMServiceFactory.get_service   sl     x)?HH>>#v= ! ?"LL5hZ@A9(DEE    c                      i } t        t        d      rt        t        di       | d<   t        t        d      rt        t        di       | d<   | S )z
        Get a dictionary of available providers and their models.
        
        Returns:
            Dictionary with provider names as keys and their models as values
        GROQ_MODELSr   OPENAI_MODELSr   )hasattrr   r   )	providerss    r   get_available_providersz)LLMServiceFactory.get_available_providers.   sM     	 8]+ '- DIf 8_-")(OR"HIhr   )N)__name__
__module____qualname____doc__staticmethodr   strr   r   r   r     r   r   r   r      s^     Fhsm Fz F F6 T#tCH~*=%>  r   r   )r$   loggingtypingr   r   r   django.confr   llm_servicer   r   r	   r   r
   	getLoggerr!   r   r   r'   r   r   <module>r-      s=     & &   #  !			8	$3 3r   