
    P1i*                     2    d Z ddlmZ d Zd Zd Zd Zd Zy)	z
AI Configuration Utilities

Provides functions for retrieving AI provider and model configurations
for different divination types.
    )settingsc                 d    	 ddl m} |j                  |       S # t        $ r t	               cY S w xY w)a  
    Get AI provider and model configuration for a specific divination type.
    
    Args:
        divination_type (str): The divination type ('bazi', 'number', 'liuyao')
    
    Returns:
        dict: Configuration containing 'provider' and 'model' keys
    r   AIProviderConfig)	ai.modelsr   
get_config	Exceptionget_fallback_config)divination_typer   s     1/home/cursorai/projects/iching/ai/utils/config.pyget_ai_configr      s3    %.**?;; %"$$%s    //c                  ~    t        t        dd      } | dk(  rt        t        dd      }nt        t        dd      }| |dS )z
    Get fallback configuration from Django settings.
    
    Returns:
        dict: Configuration containing 'provider' and 'model' keys
    DEFAULT_LLM_PROVIDERgroq
GROQ_MODELllama-3.3-70b-versatileOPENAI_MODELgpt-4oprovidermodel)getattrr   r   s     r   r
   r
      sJ     x!7@H6,0IJ.(;      c                  N    	 ddl m}  | j                  S # t        $ r ddgcY S w xY w)z{
    Get list of available AI providers.
    
    Returns:
        list: List of tuples (provider_code, provider_name)
    r   r   )r   Groq)openaiOpenAI)r   r   PROVIDER_CHOICESr	   r   s    r   get_available_providersr   2   s5    
.000 
 
 	

s    $$c                     	 ddl m} |j                  |       S # t        $ r | dk(  rg dcY S | dk(  rg dcY S g cY S w xY w)z
    Get available models for a specific provider.
    
    Args:
        provider (str): The provider code ('groq' or 'openai')
    
    Returns:
        list: List of tuples (model_code, model_name)
    r   r   r   ))r   z-Llama 3.3 70B (Best quality & context - 128k))z-meta-llama/llama-4-maverick-17b-128e-instructz*Llama 4 Maverick 17B (Good balance - 128k))zllama-3.1-8b-instantzLlama 3.1 8B (Faster - 128k)r   ))r   z%GPT-4o (Latest version, best quality))zgpt-4-turboz$GPT-4 Turbo (Fast with good quality))zgpt-3.5-turboz/GPT-3.5 Turbo (Fastest, good for simpler tasks))zgpt-4zGPT-4 (Original GPT-4))zgpt-4.1zGPT-4.1)zgpt-5zGPT-5)r   r   get_available_modelsr	   )r   r   s     r   r!   r!   C   sW    .44X>> v 
 !  	#s    =	===c                 T    t        |       }|D cg c]  \  }}|	 }}}||v S c c}}w )z
    Check if a provider and model combination is valid.
    
    Args:
        provider (str): The provider code
        model (str): The model code
    
    Returns:
        bool: True if the combination is valid, False otherwise
    )r!   )r   r   available_models
model_code_valid_model_codess         r   #is_valid_provider_model_combinationr'   d   s<     ,H59IJ9I
A9IJ%%% Ks   $N)__doc__django.confr   r   r
   r   r!   r'    r   r   <module>r+      s)    !%&(
"B&r   