
    qi                         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
 ddlmZ e G d d	e             Z G d
 de
      Zy)zBQwen LLM service implementation using OpenAI-compatible interface.    )	dataclass)Optional)logger)OpenAILLMSettings)OpenAILLMService)_warn_deprecated_paramc                       e Zd ZdZy)QwenLLMSettingszSettings for QwenLLMService.N)__name__
__module____qualname____doc__     K/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/services/qwen/llm.pyr
   r
      s    &r   r
   c            
       f     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
Z	d fd	Z
 x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                    t        d      }|t        dt         d       ||_        ||j                  |       t	        |   d|||d| t        j                  d| j                  j                          y)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=OpenAILLMSettings(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   )	r
   r   r   apply_updatesuper__init__r   infor   )selfr   r   r   r   kwargsdefault_settings	__class__s          r   r   zQwenLLMService.__init__$   s}    0 += "7OWE%*"
 ))(3a8FVaZ`a?@T@T?UVWr   c                 V    t        j                  d|        t        |   ||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!   s       r   r$   zQwenLLMService.create_clientL   s0     	;H:FGw$WhA&AAr   )NN)r   r   r   r   r
   Settings__annotations__strr   r   r$   __classcell__)r!   s   @r   r   r      si     H Q#.2&X &X 	&X
 }&X ?+&XPB Br   r   N)r   dataclassesr   typingr   logurur    pipecat.services.openai.base_llmr   pipecat.services.openai.llmr   pipecat.services.settingsr   r
   r   r   r   r   <module>r/      sH    I !   > 8 < 	' 	 	>B% >Br   