o
    i                  
   @  s   d dl mZ d dlZd dlm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yK Z zed
edZ[ww G dd dee ZdS )    )annotationsN)overload)ModelProfile)	UserError)cached_async_http_clientmistral_model_profile)Provider)Mistralu   Please install the `mistral` package to use the Mistral provider, you can use the `mistral` optional group — `pip install "pydantic-ai-slim[mistral]"`c                   @  s   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e	ddd"ddZ
e	dddd#ddZ
dddddd$ddZ
dS )%MistralProviderzProvider for Mistral API.returnstrc                 C  s   dS )Nmistral selfr   r   c/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_ai/providers/mistral.pyname   s   zMistralProvider.namec                 C  s   | j j d S )Nr   )clientsdk_configurationget_server_detailsr   r   r   r   base_url   s   zMistralProvider.base_urlr
   c                 C  s   | j S N)_clientr   r   r   r   r   "   s   zMistralProvider.client
model_nameModelProfile | Nonec                 C  s   t |S r   r   )r   r   r   r   r   model_profile&   s   zMistralProvider.model_profileN)mistral_clientr   Mistral | NoneNonec                C     d S r   r   )r   r   r   r   r   __init__)      zMistralProvider.__init__)api_keyhttp_clientr#   
str | Noner$   httpx.AsyncClient | Nonec                C  r    r   r   )r   r#   r$   r   r   r   r!   ,   r"   )r#   r   r   r$   r   c                C  s   |dur!|du sJ d|du sJ d|du sJ d|| _ dS |p'td}|s.td|dur<t|||d| _ dS tdd	}t|||d| _ dS )
a  Create a new Mistral provider.

        Args:
            api_key: The API key to use for authentication, if not provided, the `MISTRAL_API_KEY` environment variable
                will be used if available.
            mistral_client: An existing `Mistral` client to use, if provided, `api_key` and `http_client` must be `None`.
            base_url: The base url for the Mistral requests.
            http_client: An existing async client to use for making HTTP requests.
        Nz6Cannot provide both `mistral_client` and `http_client`z2Cannot provide both `mistral_client` and `api_key`z3Cannot provide both `mistral_client` and `base_url`MISTRAL_API_KEYzxSet the `MISTRAL_API_KEY` environment variable or pass it via `MistralProvider(api_key=...)`to use the Mistral provider.)r#   async_client
server_urlr   )provider)r   osgetenvr   r
   r   )r   r#   r   r   r$   r   r   r   r!   /   s   

)r   r   )r   r
   )r   r   r   r   )r   r   r   r   )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   r      s$    
r   )
__future__r   _annotationsr+   typingr   httpxpydantic_air   pydantic_ai.exceptionsr   pydantic_ai.modelsr   pydantic_ai.profiles.mistralr   pydantic_ai.providersr	   	mistralair
   ImportErrorer   r   r   r   r   <module>   s(    