o
    i                  
   @  s   d dl mZ d dlZd dl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 zd dlmZ W n eyE Z zed	edZ[ww G d
d dee ZdS )    )annotationsN)ModelProfile)	UserError)cached_async_http_clientcohere_model_profile)Provider)AsyncClientV2u   Please install the `cohere` package to use the Cohere provider, you can use the `cohere` optional group — `pip install "pydantic-ai-slim[cohere]"`c                   @  sX   e Zd ZdZedddZedddZedd	d
ZdddZdddddddZ	dS )CohereProviderzProvider for Cohere API.returnstrc                 C  s   dS )Ncohere selfr   r   b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_ai/providers/cohere.pyname   s   zCohereProvider.namec                 C  s   | j j}t| S N)client_client_wrapperr   get_base_url)r   client_wrapperr   r   r   base_url   s   zCohereProvider.base_urlr	   c                 C  s   | j S r   )_clientr   r   r   r   r   "   s   zCohereProvider.client
model_nameModelProfile | Nonec                 C  s   t |S r   r   )r   r   r   r   r   model_profile&   s   zCohereProvider.model_profileN)api_keycohere_clienthttp_clientr   
str | Noner   AsyncClientV2 | Noner   httpx.AsyncClient | NoneNonec                C  s   |dur|du sJ d|du sJ d|| _ dS |ptd}|s&tdtd}|dur9t|||d| _ dS tdd	}t|||d| _ dS )
a  Create a new Cohere provider.

        Args:
            api_key: The API key to use for authentication, if not provided, the `CO_API_KEY` environment variable
                will be used if available.
            cohere_client: An existing
                [AsyncClientV2](https://github.com/cohere-ai/cohere-python)
                client to use. If provided, `api_key` and `http_client` must be `None`.
            http_client: An existing `httpx.AsyncClient` to use for making HTTP requests.
        Nz5Cannot provide both `cohere_client` and `http_client`z1Cannot provide both `cohere_client` and `api_key`
CO_API_KEYzqSet the `CO_API_KEY` environment variable or pass it via `CohereProvider(api_key=...)`to use the Cohere provider.CO_BASE_URL)r   httpx_clientr   r   )provider)r   osgetenvr   r	   r   )r   r   r   r   r   r   r   r   __init__)   s   


zCohereProvider.__init__)r   r   )r   r	   )r   r   r   r   )r   r    r   r!   r   r"   r   r#   )
__name__
__module____qualname____doc__propertyr   r   r   r   r*   r   r   r   r   r
      s    
r
   )
__future__r   _annotationsr(   httpxpydantic_air   pydantic_ai.exceptionsr   pydantic_ai.modelsr   pydantic_ai.profiles.coherer   pydantic_ai.providersr   r   r	   ImportError_import_errorr
   r   r   r   r   <module>   s&    