o
    iM                     @   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 )zITogether.ai LLM service implementation using OpenAI-compatible interface.    )	dataclass)Optional)logger)BaseOpenAILLMService)OpenAILLMServicec                   @   s   e Zd ZdZdS )TogetherLLMSettingsz Settings for TogetherLLMService.N)__name__
__module____qualname____doc__ r   r   Q/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/together/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 )TogetherLLMServicea  A service for interacting with Together.ai's API using the OpenAI-compatible interface.

    This service extends OpenAILLMService to connect to Together.ai's API endpoint while
    maintaining full compatibility with OpenAI's interface and functionality.
    	_settingszhttps://api.together.xyz/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 Together.ai LLM service.

        Args:
            api_key: The API key for accessing Together.ai's API.
            base_url: The base URL for Together.ai API. Defaults to "https://api.together.xyz/v1".
            model: The model identifier to use. Defaults to "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo".

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

            settings: Runtime-updatable settings. When provided alongside deprecated
                parameters, ``settings`` values take precedence.
            **kwargs: Additional keyword arguments passed to OpenAILLMService.
        z+meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo)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TogetherLLMService.__init__c                    s&   t d|  t j||fi |S )a  Create OpenAI-compatible client for Together.ai API endpoint.

        Args:
            api_key: The API key to use for the client. If None, uses instance api_key.
            base_url: The base URL for the API. If None, uses instance base_url.
            **kwargs: Additional keyword arguments passed to the parent create_client method.

        Returns:
            An OpenAI-compatible client configured for Together.ai's API.
        z%Creating Together.ai client with api )r   debugr   create_client)r   r   r   r   r   r   r   r   J   s   z TogetherLLMService.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   