o
    Ղip                     @   s   d Z ddlmZ ddlmZmZmZ ddlmZmZm	Z	 G dd deZ
G dd de
ZG d	d
 d
eZG dd de
ZG dd deZG dd deZG dd deZG dd deZG dd deZdS )z
Model Provider schemas
    )datetime)AnyListOptional)	BaseModelFieldmodel_validatorc                   @   s   e Zd ZU dZeed< eed< eed< eedZe	e ed< dZ
eed< d	Zee ed
< d	Zee ed< d	Zee ed< d	Zee ed< dZeed< dZeed< dZeed< d	Zeeeef  ed< d	S )	ModelBasezBase model schemacodenametypedefault_factorytagsTenabledN	dimensionremote_model_idcontext_lengthmax_output_tokenssupports_streamFsupports_toolsd   priorityextra_config)__name__
__module____qualname____doc__str__annotations__r   listr   r   r   boolr   r   intr   r   r   r   r   r   r   dictr    r$   r$   </lsinfo/ai/hellotax_ai/base_platform/app/schemas/provider.pyr	   
   s   
 r	   c                   @   s   e Zd ZU dZeed< dS )ModelCreatezSchema for creating a modelprovider_idN)r   r   r   r   r"   r   r$   r$   r$   r%   r&      s   
 r&   c                   @   s   e Zd ZU dZdZee ed< dZee ed< dZ	ee
e  ed< dZee ed< dZee ed< dZee ed< dZee ed	< dZee ed
< dZee ed< dZee ed< dZee ed< dZeeeef  ed< dS )ModelUpdatezSchema for updating a modelNr   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   r   r   r   r   r   r#   r   r$   r$   r$   r%   r(       s   
 r(   c                   @   s\   e Zd ZU dZeed< eed< dZee ed< dZ	e
ed< eed< eed	< G d
d dZdS )ModelResponsezSchema for model responseidr'   Nprovider_nameFis_local
created_at
updated_atc                   @      e Zd ZdZdS )zModelResponse.ConfigTNr   r   r   from_attributesr$   r$   r$   r%   Config9       r2   )r   r   r   r   r"   r   r+   r   r   r,   r!   r   r2   r$   r$   r$   r%   r)   0   s   
 r)   c                   @   s   e Zd ZU dZeed< dZee ed< dZee ed< dZ	ee ed< dZ
ee ed< dZee ed< dZee ed	< dZee ed
< eedZee ed< dZeed< dZee ed< dZeeeef  ed< dS )ProviderBasezBase provider schemar   Ndescriptioniconcolordefault_base_urlprovider_kindprotocol	auth_typer   capabilitiesFr,   healthcheck_pathr   )r   r   r   r   r   r   r5   r   r6   r7   r8   r9   r:   r;   r   r    r<   r   r,   r!   r=   r   r#   r   r$   r$   r$   r%   r4   =   s   
 r4   c                   @   sV   e Zd ZU dZdZeed< dZee	 ed< dZ
ee	 ed< dZeed< d	Zeed
< dS )ProviderCreatezSchema for creating a providerF
configuredNapi_keybase_urlr   r   Tr   )r   r   r   r   r?   r!   r   r@   r   r   rA   r   r"   r   r$   r$   r$   r%   r>   M   s   
 r>   c                   @   s.  e Zd ZU dZdZee ed< dZee ed< dZ	ee ed< dZ
ee ed< dZee ed< dZee ed< dZee ed	< dZee ed
< dZee ed< dZee ed< dZee ed< dZee ed< dZee ed< dZeee  ed< dZee ed< dZee ed< dZeeeef  ed< dS )ProviderUpdatezSchema for updating a providerNr   r5   r6   r7   r?   r8   r@   rA   r   r   r9   r:   r;   r<   r,   r=   r   )r   r   r   r   r   r   r   r   r5   r6   r7   r?   r!   r8   r@   rA   r   r"   r   r9   r:   r;   r<   r   r,   r=   r   r#   r   r$   r$   r$   r%   rB   V   s&   
 rB   c                   @   sj   e Zd ZU dZddiZedddZee e	d< edddZ
ee e	d	< d
Zee e	d< dZee e	d< dS )ProviderConfigz!Schema for provider configurationpopulate_by_nameTNapiKey)aliasr@   baseUrlrA   r   r   r   )r   r   r   r   model_configr   r@   r   r   r   rA   r   r"   r   r!   r$   r$   r$   r%   rC   k   s   
 rC   c                   @   s   e Zd ZU dZeed< eed< dZee	 ed< dZ
ee	 ed< eed< eed< eed	< eed
< eedZee ed< edddd ZG dd dZdS )ProviderResponsezSchema for provider responser*   r?   Nr@   rA   r   r   r-   r.   r   modelsafter)modec                 C   s   ddl m} | jr:z$|| j}|r)t|dkr)|dd  d|dd  | _nd| _W n ty9   d| _Y nw | jrM| jd	krMt| jpH| j| _	| S t| jpS| j
| _	| S )
z%Decrypt and mask API key for responser   )encryption_service   N   z...z***none)app.core.encryptionrM   r@   decryptlen	Exceptionr;   r!   rA   r?   r,   )selfrM   decrypted_keyr$   r$   r%   process_api_key   s    "
z ProviderResponse.process_api_keyc                   @   r/   )zProviderResponse.ConfigTNr0   r$   r$   r$   r%   r2      r3   r2   )r   r   r   r   r"   r   r!   r@   r   r   rA   r   r   r    rJ   r   r)   r   rX   r2   r$   r$   r$   r%   rI   u   s   
 
rI   N)r   r   typingr   r   r   pydanticr   r   r   r	   r&   r(   r)   r4   r>   rB   rC   rI   r$   r$   r$   r%   <module>   s    	
