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 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mZmZ d dlm Z  zd dl!m"Z" W n e#yy 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)amazon_model_profile)anthropic_model_profile)cohere_model_profile)deepseek_model_profile)google_model_profile)grok_model_profile)mistral_model_profile)OpenAIJsonSchemaTransformerOpenAIModelProfileopenai_model_profile)Provider)AsyncOpenAIu   Please install the `openai` package to use the Vercel provider, you can use the `openai` optional group — `pip install "pydantic-ai-slim[openai]"`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Z
e	d$ddZ
e	d%ddZ
e	ddd&ddZ
ddddd'ddZ
dS )(VercelProviderz#Provider for Vercel AI Gateway API.returnstrc                 C     dS )Nvercel selfr   r   b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_ai/providers/vercel.pyname!      zVercelProvider.namec                 C  r   )Nzhttps://ai-gateway.vercel.sh/v1r   r   r   r   r   base_url%   r   zVercelProvider.base_urlr   c                 C  s   | j S N)_clientr   r   r   r   client)   s   zVercelProvider.client
model_nameModelProfile | Nonec              	   C  sp   t tttttttd}d }z
|dd\}}W n t	y%   t
d|w ||v r0|| |}ttd|S )N)	anthropicbedrockcoheredeepseekmistralopenaivertexxai/   z4Model name must be in 'provider/model' format, got: )json_schema_transformer)r   r   r	   r
   r   r   r   r   split
ValueErrorr   r   r   update)r   r"   provider_to_profileprofileproviderr   r   r   model_profile-   s,   zVercelProvider.model_profileNonec                 C     d S r   r   r   r   r   r   __init__I      zVercelProvider.__init__api_keyc                C  r7   r   r   )r   r:   r   r   r   r8   L   r9   http_clienthttpx.AsyncClientc                C  r7   r   r   )r   r:   r;   r   r   r   r8   O   r9   N)openai_clientr=   AsyncOpenAI | Nonec                C  r7   r   r   )r   r=   r   r   r   r8   R   r9   )r:   r=   r;   
str | Nonehttpx.AsyncClient | Nonec                C  s   |pt dpt d}|s|d u rtdddd}|d ur$|| _d S |d ur4t| j|||d| _d S tdd	}t| j|||d| _d S )
NVERCEL_AI_GATEWAY_API_KEYVERCEL_OIDC_TOKENzSet the `VERCEL_AI_GATEWAY_API_KEY` or `VERCEL_OIDC_TOKEN` environment variable or pass the API key via `VercelProvider(api_key=...)` to use the Vercel provider.zhttps://ai.pydantic.dev/zpydantic-ai)zhttp-refererzx-title)r   r:   r;   default_headersr   )r4   )osgetenvr   r    r   r   r   )r   r:   r=   r;   rC   r   r   r   r8   U   s    




)r   r   )r   r   )r"   r   r   r#   )r   r6   )r:   r   r   r6   )r:   r   r;   r<   r   r6   )r=   r>   r   r6   )r:   r?   r=   r>   r;   r@   r   r6   )__name__
__module____qualname____doc__propertyr   r   r!   r5   r   r8   r   r   r   r   r      s*    
r   )&
__future__r   _annotationsrD   typingr   httpxpydantic_air   pydantic_ai.exceptionsr   pydantic_ai.modelsr   pydantic_ai.profiles.amazonr   pydantic_ai.profiles.anthropicr   pydantic_ai.profiles.coherer	   pydantic_ai.profiles.deepseekr
   pydantic_ai.profiles.googler   pydantic_ai.profiles.grokr   pydantic_ai.profiles.mistralr   pydantic_ai.profiles.openair   r   r   pydantic_ai.providersr   r)   r   ImportError_import_errorr   r   r   r   r   <module>   s6    