Bases: SingletonFactory
        Factory class for creating LiteLLM language model instances.
This class implements the Singleton pattern to ensure only one instance
of an LiteLLM model with a specific configuration exists in the application.
It uses LiteLLMConfiguration to configure the model parameters.
  
    
    
  
  
    
      | Attributes: | 
      
        
            - 
              
_configuration_class
                  (Type)
              –
              
                Type of the configuration class used for
creating LiteLLM model instances. 
               
             
         
       | 
    
  
              
                Source code in src/augmentation/components/llms/lite_llm/llm.py
                11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46  | class LiteLLMFactory(SingletonFactory):
    """
    Factory class for creating LiteLLM language model instances.
    This class implements the Singleton pattern to ensure only one instance
    of an LiteLLM model with a specific configuration exists in the application.
    It uses LiteLLMConfiguration to configure the model parameters.
    Attributes:
        _configuration_class: Type of the configuration class used for
            creating LiteLLM model instances.
    """
    _configuration_class: Type = LiteLLMConfiguration
    @classmethod
    def _create_instance(cls, configuration: LiteLLMConfiguration) -> LiteLLM:
        """
        Creates a new instance of the LiteLLM language model.
        Args:
            configuration (LiteLLMConfiguration): Configuration object containing
                settings for the LiteLLM model, including API key, model name,
                maximum tokens, and retry settings.
        Returns:
            LiteLLM: An instance of the LiteLLM language model configured with the
                provided settings.
        """
        return LiteLLM(
            api_key=configuration.secrets.api_key.get_secret_value(),
            api_base=configuration.api_base,
            model=configuration.name,
            max_tokens=configuration.max_tokens,
            max_retries=configuration.max_retries,
        )
  |