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 )z;OLLama LLM service implementation for Pipecat AI framework.    )	dataclass)Optional)logger)BaseOpenAILLMService)OpenAILLMServicec                   @   s   e Zd ZdZdS )OllamaLLMSettingszSettings for OLLamaLLMService.N)__name__
__module____qualname____doc__ r   r   O/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/ollama/llm.pyr      s    r   c                       s\   e Zd ZU dZeZeed< dddddee dedee f fd	d
Z	d fdd	Z
  ZS )OLLamaLLMServicezOLLama LLM service that provides local language model capabilities.

    This service extends OpenAILLMService to work with locally hosted OLLama models,
    providing a compatible interface for running large language models locally.
    	_settingsNzhttp://localhost:11434/v1)modelbase_urlsettingsr   r   r   c                   sV   | j dd}|dur| dd ||_|dur|| t jd|d|d| dS )aW  Initialize OLLama LLM service.

        Args:
            model: The OLLama model to use. Defaults to "llama2".

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

            base_url: The base URL for the OLLama API endpoint.
                    Defaults to "http://localhost:11434/v1".
            settings: Runtime-updatable settings. When provided alongside deprecated
                parameters, ``settings`` values take precedence.
            **kwargs: Additional keyword arguments passed to OpenAILLMService.
        llama2)r   Nr   ollama)r   api_keyr   r   )Settings"_warn_init_param_moved_to_settingsr   apply_updatesuper__init__)selfr   r   r   kwargsdefault_settings	__class__r   r   r   #   s   
zOLLamaLLMService.__init__c                    s&   t d|  t jdd|i|S )aC  Create OpenAI-compatible client for Ollama.

        Args:
            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 Ollama.
        z Creating Ollama client with api r   Nr   )r   debugr   create_client)r   r   r   r   r   r   r!   I   s   
zOLLamaLLMService.create_client)N)r   r	   r
   r   r   r   __annotations__r   strr   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   