o
    Ã¿iW  ã                   @   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 )zBQwen LLM service implementation using OpenAI-compatible interface.é    )Ú	dataclass)ÚOptional)Úlogger)ÚBaseOpenAILLMService)ÚOpenAILLMServicec                   @   s   e Zd ZdZdS )ÚQwenLLMSettingszSettings for QwenLLMService.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úM/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/qwen/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 )ÚQwenLLMServicea  A service for interacting with Alibaba Cloud's Qwen LLM API using the OpenAI-compatible interface.

    This service extends OpenAILLMService to connect to Qwen's API endpoint while
    maintaining full compatibility with OpenAI's interface and functionality.
    Ú	_settingsz6https://dashscope-intl.aliyuncs.com/compatible-mode/v1N)Úbase_urlÚmodelÚsettingsÚapi_keyr   r   r   c                   sj   | j dd}|dur|  dd¡ ||_|dur| |¡ tƒ jd|||dœ|¤Ž t d| jj› ¡ dS )a£  Initialize the Qwen LLM service.

        Args:
            api_key: The API key for accessing Qwen's API (DashScope API key).
            base_url: Base URL for Qwen API. Defaults to "https://dashscope-intl.aliyuncs.com/compatible-mode/v1".
            model: The model identifier to use. Defaults to "qwen-plus".

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

            settings: Runtime-updatable settings. When provided alongside deprecated
                parameters, ``settings`` values take precedence.
            **kwargs: Additional keyword arguments passed to OpenAILLMService.
        z	qwen-plus)r   Nr   )r   r   r   z)Initialized Qwen LLM service with model: r   )	ÚSettingsÚ"_warn_init_param_moved_to_settingsr   Úapply_updateÚsuperÚ__init__r   Úinfor   )Úselfr   r   r   r   ÚkwargsÚdefault_settings©Ú	__class__r   r   r   #   s   
zQwenLLMService.__init__c                    s&   t  d|› ¡ tƒ j||fi |¤ŽS )a‘  Create OpenAI-compatible client for Qwen API endpoint.

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

        Returns:
            An OpenAI-compatible client configured for Qwen's API.
        z$Creating Qwen client with base URL: )r   Údebugr   Úcreate_client)r   r   r   r   r   r   r   r    K   s   zQwenLLMService.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   