o
    Ã¿i¼  ã                   @   sj   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 eG dd„ dejƒƒZG d	d
„ d
e
ƒZdS )zBGroq LLM Service implementation using OpenAI-compatible interface.é    )Ú	dataclass)ÚOptional)Úlogger)ÚBaseOpenAILLMService)ÚOpenAILLMServicec                   @   s   e Zd ZdZdS )ÚGroqLLMSettingszSettings for GroqLLMService.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úM/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/groq/llm.pyr      s    r   c                
       s`   e Zd ZU dZeZeed< ddddœdededee d	ee f‡ fd
d„Z	d‡ fdd„	Z
‡  ZS )ÚGroqLLMServicezöA service for interacting with Groq's API using the OpenAI-compatible interface.

    This service extends OpenAILLMService to connect to Groq's API endpoint while
    maintaining full compatibility with OpenAI's interface and functionality.
    Ú	_settingszhttps://api.groq.com/openai/v1N)Úbase_urlÚmodelÚsettingsÚapi_keyr   r   r   c                   sV   | j dd}|dur|  dd¡ ||_|dur| |¡ tƒ jd|||dœ|¤Ž dS )a…  Initialize Groq LLM service.

        Args:
            api_key: The API key for accessing Groq's API.
            base_url: The base URL for Groq API. Defaults to "https://api.groq.com/openai/v1".
            model: The model identifier to use. Defaults to "llama-3.3-70b-versatile".

                .. deprecated:: 0.0.105
                    Use ``settings=GroqLLMService.Settings(model=...)`` instead.

            settings: Runtime-updatable settings. When provided alongside deprecated
                parameters, ``settings`` values take precedence.
            **kwargs: Additional keyword arguments passed to OpenAILLMService.
        zllama-3.3-70b-versatile)r   Nr   )r   r   r   r   )ÚSettingsÚ"_warn_init_param_moved_to_settingsr   Úapply_updateÚsuperÚ__init__)Úselfr   r   r   r   ÚkwargsÚdefault_settings©Ú	__class__r   r   r   #   s   
zGroqLLMService.__init__c                    s&   t  d|› ¡ tƒ j||fi |¤ŽS )aŽ  Create OpenAI-compatible client for Groq API endpoint.

        Args:
            api_key: API key for authentication. If None, uses instance api_key.
            base_url: Base URL for the API. If None, uses instance base_url.
            **kwargs: Additional arguments passed to the client constructor.

        Returns:
            An OpenAI-compatible client configured for Groq's API.
        zCreating Groq client with api )r   Údebugr   Úcreate_client)r   r   r   r   r   r   r   r   J   s   zGroqLLMService.create_client)NN)r   r	   r
   r   r   r   Ú__annotations__Ústrr   r   r   Ú__classcell__r   r   r   r   r      s"   
 úýüûú'r   N)r   Údataclassesr   Útypingr   Úlogurur   Ú pipecat.services.openai.base_llmr   Úpipecat.services.openai.llmr   r   r   r   r   r   r   r   Ú<module>   s   