HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/.local/lib/python3.10/site-packages/openai/lib/__pycache__/_pydantic.cpython-310.pyc
o

���g��@s�ddlmZddlZddlmZmZddlmZddlZddl	m
Z
ddlmZ
mZddlmZmZed	�Zd,dd�Zd-dd�Zd.dd�Zd/dd �Zd0d"d#�Zd1d&d'�Zd2d*d+�ZdS)3�)�annotationsN)�Any�TypeVar)�	TypeGuard�)�	NOT_GIVEN)�is_dict�is_list)�PYDANTIC_V2�model_json_schema�_T�model�4type[pydantic.BaseModel] | pydantic.TypeAdapter[Any]�return�dict[str, Any]cCsRt�|�rt|�rt|�}ntrt|tj�r|��}nt	d|����t
|d|d�S)Nz:Non BaseModel types are only supported with Pydantic v2 - ���path�root)�inspect�isclass�is_basemodel_typerr
�
isinstance�pydantic�TypeAdapter�json_schema�	TypeError�_ensure_strict_json_schema)r
�schemarr�G/home/arjun/.local/lib/python3.10/site-packages/openai/lib/_pydantic.py�to_strict_json_schemas

r r�objectr�tuple[str, ...]r�dict[str, object]csrt|�std|�d�����|�d�}t|�r.|��D]\}}t|g��d�|�R�d�q|�d�}t|�rN|��D]\}}t|g��d�|�R�d�q;|�d�}	|	dkr_d|vr_d	|d<|�d
�}
t|
�r�dd�|
��D�|d
<��fdd�|
��D�|d
<|�d�}t|�r�t|g��d�R�d�|d<|�d�}t|�r���fdd�t|�D�|d<|�d�}
t|
�r�t|
�dkr�|�	t|
dg��d�d�R�d��|�
d�n��fdd�t|
�D�|d<|�dt�dur�|�
d�|�d�}|�r7t|d��r7t
|t��s
Jd|����t�|d�}t|��s"td|�d|����|�	i|�|��|�
d�t|��d�S|S)zkMutates the given JSON schema to ensure it conforms to the `strict` standard
    that the API expects.
    z	Expected z to be a dictionary; path=z$defsr�definitions�typer!�additionalPropertiesF�
propertiescSsg|]}|�qSrr)�.0�proprrr�
<listcomp>9sz._ensure_strict_json_schema.<locals>.<listcomp>�requiredcs.i|]\}}|t|g��d�|�R�d��qS)r'r)r)r(�key�prop_schemarrr�
<dictcomp>:s��z._ensure_strict_json_schema.<locals>.<dictcomp>�items�anyOfc�0g|]\}}t|g��d�t|��R�d��qS)r0r�r�str)r(�i�variantrrrr*H����allOf�r�0cr1)r7rr2)r(r4�entryrrrr*Tr6�defaultNz$refzReceived non-string $ref - )r�refzExpected `$ref: z&` to resolved to a dictionary but got )rr�getr/r�keysr	�	enumerate�len�update�popr�has_more_than_n_keysrr3�resolve_ref�
ValueError)rrr�defs�def_name�
def_schemar$�definition_name�definition_schema�typr'r/�any_of�all_ofr<�resolvedrrrrs^	




�


�
&
�



rr<r3cCsf|�d�s
td|�d���|dd��d�}|}|D]}||}t|�s.Jd|�d|����|}q|S)Nz#/zUnexpected $ref format z; Does not start with #/r�/z1encountered non-dictionary entry while resolving z - )�
startswithrE�splitr)rr<rrNr,�valuerrrrDvs
rDrKr%�#TypeGuard[type[pydantic.BaseModel]]cCst�|�sdSt|tj�S)NF)rr�
issubclassr�	BaseModel�rKrrrr�s
r�boolcCs
t|d�S)z@Returns True if the given type likely used `@pydantic.dataclass`�__pydantic_config__)�hasattrrVrrr�is_dataclass_like_type�s
rZ�obj�TypeGuard[dict[str, object]]cCst|�S)N)�_is_dict)r[rrrr�sr�n�intcCs,d}|��D]
}|d7}||krdSqdS)Nrr8TF)r>)r[r^r4�_rrrrC�s�rC)r
rrr)rr!rr"rr#rr)rr#r<r3rr!)rKr%rrS)rKr%rrW)r[r!rr\)r[r#r^r_rrW)�
__future__rr�typingrr�typing_extensionsrr�_typesr�_utilsrr]r	�_compatr
rrr rrDrrZrCrrrr�<module>s 


[