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: //usr/local/lib/python3.10/dist-packages/openai/__pycache__/_models.cpython-310.pyc
o

���g�w�@s(ddlmZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZddlZddlZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd	l,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:dd
l;m<Z<m=Z=m>Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGddlHmIZIer�ddlJmKZKmLZLmMZMd
dgZNed�ZOedd
d�ZPed�ZQeee
eRefZSeGdd�de��ZTGdd
�d
ejU�ZUdddd�ZVded"d#�ZWdfd%d&�ZXdgd-d.�ZYdhd0d1�ZZdid2d3�Z[eGd4d5�d5e��Z\Gd6d7�d7�Z]djd<d=�Z^dkdBdC�Z_dldDdE�Z`dmdKdL�ZadndPdQ�Zbe�r7eUZ>n	GdRd�de?eU�Z>e<�reddSlmcZdedTe1ddU�ed��Zee�r]ddSlmcZcneeZcdldVdW�Zfne�s}GdXdY�dYe>e
eO�ZgdldZdW�Zfdod\d]�ZhGd^d_�d_ed`da�ZieGdbdc�dcejU��ZjdS)p�)�annotationsN)
�
TYPE_CHECKING�Any�Type�Tuple�Union�Generic�TypeVar�Callable�Optional�cast)�date�datetime)�Unpack�Literal�ClassVar�Protocol�Required�Sequence�	ParamSpec�	TypedDict�	TypeGuard�final�override�runtime_checkable)�	FieldInfo�)	�Body�IncEx�Query�ModelT�Headers�Timeout�NotGiven�
AnyMapping�HttpxRequestFiles)�PropertyInfo�is_list�is_given�	json_safe�	lru_cache�
is_mapping�
parse_date�coerce_boolean�parse_datetime�strip_not_given�extract_type_arg�is_annotated_type�is_type_alias_type�strip_annotated_type)�PYDANTIC_V2�
ConfigDict�GenericModel�get_args�is_union�	parse_obj�
get_origin�is_literal_type�get_model_config�get_model_fields�field_get_default)�RAW_RESPONSE_HEADER)�
ModelField�
LiteralSchema�ModelFieldsSchema�	BaseModelr6�_T�_BaseModelT)�bound�Pc@�eZdZUded<dS)�_ConfigProtocol�bool�allow_population_by_field_nameN��__name__�
__module__�__qualname__�__annotations__�rQrQ�9/usr/local/lib/python3.10/dist-packages/openai/_models.pyrIQ�
rIc
sFeZdZUeredeej�dd��d�Z	de
d<needEd	d
���Z
Gdd�dej�ZedF�fdd��Zer=dZde
d<	ddddddd�dGd d!�Zd"dddddd#�dHd'd(�ZedId)d*��Zee	dJdKd2d3���ZesmeZes�edddddddddddd4�dL�fd@dA��ZeddddddddddddB�dM�fdCdD��Z�ZS�ZS)NrC�allow�DEFER_PYDANTIC_BUILD�true)�extra�defer_build�ClassVar[ConfigDict]�model_config�return�set[str]cCs|jS�N)�__fields_set__��selfrQrQrR�model_fields_set]szBaseModel.model_fields_setc@seZdZUejjZded<dS)zBaseModel.ConfigrrWN)rMrNrO�pydantic�ExtrarTrWrPrQrQrQrR�Configcs
rd�ReprArgscsdd�t���D�S)NcSsg|]
}|ddvr|�qS)r>�_request_id�__exclude_fields__rQ)�.0�argrQrQrR�
<listcomp>isz+BaseModel.__repr_args__.<locals>.<listcomp>)�super�
__repr_args__r_��	__class__rQrRrlfszBaseModel.__repr_args__Nz
Optional[str]rf�pythonTF)�mode�
use_api_names�
exclude_unset�exclude_defaults�exclude_none�warningsrp�Literal['json', 'python']rqrJrrrsrtru�dict[str, object]cC�|j||||||d�S)aDRecursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

        By default, fields that were not set by the API will not be included,
        and keys will match the API response, *not* the property names from the model.

        For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
        the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).

        Args:
            mode:
                If mode is 'json', the dictionary will only contain JSON serializable types. e.g. `datetime` will be turned into a string, `"2024-3-22T18:11:19.117000Z"`.
                If mode is 'python', the dictionary may contain any Python objects. e.g. `datetime(2024, 3, 22)`

            use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
            exclude_unset: Whether to exclude fields that have not been explicitly set.
            exclude_defaults: Whether to exclude fields that are set to their default value from the output.
            exclude_none: Whether to exclude fields that have a value of `None` from the output.
            warnings: Whether to log warnings when invalid fields are encountered. This is only supported in Pydantic v2.
        )rp�by_aliasrrrsrtru)�
model_dump)r`rprqrrrsrtrurQrQrR�to_dict|s�zBaseModel.to_dict�)�indentrqrrrsrtrur}�
int | None�strcCrx)alGenerates a JSON string representing this model as it would be received from or sent to the API (but with indentation).

        By default, fields that were not set by the API will not be included,
        and keys will match the API response, *not* the property names from the model.

        For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
        the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).

        Args:
            indent: Indentation to use in the JSON output. If `None` is passed, the output will be compact. Defaults to `2`
            use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
            exclude_unset: Whether to exclude fields that have not been explicitly set.
            exclude_defaults: Whether to exclude fields that have the default value.
            exclude_none: Whether to exclude fields that have a value of `None`.
            warnings: Whether to show any warnings that occurred during serialization. This is only supported in Pydantic v2.
        )r}ryrrrsrtru)�model_dump_json)r`r}rqrrrsrtrurQrQrR�to_json�s�zBaseModel.to_jsoncCs|���d|�d��d�S)N�(z, �))�
__repr_name__�__repr_str__r_rQrQrR�__str__�szBaseModel.__str__�_BaseModel__cls�Type[ModelT]�_fields_set�set[str] | None�values�objectr c
KsD|�|�}i}t|�}t|t�r|jn|�d�}|durt�}t|�}|��D].\}}	|	j	}
|
dus8|
|vr:|r:|}
|
|vrOt
||
|	|
d�||<|�|�q't|	�||<q'i}|��D]\}
}|
|vrtt
rk|||
<q\|�|
�|||
<q\t�|d|�t
r�t�|dd�t�|d|�t�|d|�|S|��t�|d|�|S)N�populate_by_name)�value�field�key�__dict__�__pydantic_private__�__pydantic_extra__�__pydantic_fields_set__r^)�__new__r<�
isinstancerIrK�get�setr=�items�alias�_construct_field�addr>r4r��__setattr__�_init_private_attributes)
r�r�r��m�
fields_values�configr��model_fields�namer�r��_extrar�rQrQrR�	construct�sF
��

��zBaseModel.construct)rp�include�excluderyrrrsrt�
round_tripru�context�serialize_as_any�Literal['json', 'python'] | strr��IncEx | Noner�ryr��'bool | Literal['none', 'warn', 'error']r��dict[str, Any] | Noner��dict[str, Any]c
s�|dvrtd��|dkrtd��|	dkrtd��|
dur td��|dkr(td	��t�j||||||d
�}|dkrCttttft|��S|S)a
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump

            Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

            Args:
                mode: The mode in which `to_python` should run.
                    If mode is 'json', the dictionary will only contain JSON serializable types.
                    If mode is 'python', the dictionary may contain any Python objects.
                include: A list of fields to include in the output.
                exclude: A list of fields to exclude from the output.
                by_alias: Whether to use the field's alias in the dictionary key if defined.
                exclude_unset: Whether to exclude fields that are unset or None from the output.
                exclude_defaults: Whether to exclude fields that are set to their default value from the output.
                exclude_none: Whether to exclude fields that have a value of `None` from the output.
                round_trip: Whether to enable serialization and deserialization round-trip support.
                warnings: Whether to log warnings when invalid fields are encountered.

            Returns:
                A dictionary representation of the model.
            >�jsonroz&mode must be either 'json' or 'python'F�+round_trip is only supported in Pydantic v2T�)warnings is only supported in Pydantic v2N�(context is only supported in Pydantic v2�1serialize_as_any is only supported in Pydantic v2)r�r�ryrrrsrtr�)�
ValueErrorrk�dictrrrr))
r`rpr�r�ryrrrsrtr�rur�r��dumpedrmrQrRrzs&$�"	zBaseModel.model_dump)r}r�r�ryrrrsrtr�rur�r�c	sZ|dkrtd��|	dkrtd��|
durtd��|dkr td��t�j|||||||d�S)	a�Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json

            Generates a JSON representation of the model using Pydantic's `to_json` method.

            Args:
                indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
                include: Field(s) to include in the JSON output. Can take either a string or set of strings.
                exclude: Field(s) to exclude from the JSON output. Can take either a string or set of strings.
                by_alias: Whether to serialize using field aliases.
                exclude_unset: Whether to exclude fields that have not been explicitly set.
                exclude_defaults: Whether to exclude fields that have the default value.
                exclude_none: Whether to exclude fields that have a value of `None`.
                round_trip: Whether to use serialization/deserialization between JSON and class instance.
                warnings: Whether to show any warnings that occurred during serialization.

            Returns:
                A JSON string representation of the model.
            Fr�Tr�Nr�r�)r}r�r�ryrrrsrt)r�rkr�)r`r}r�r�ryrrrsrtr�rur�r�rmrQrRr�Js""�zBaseModel.model_dump_json)r[r\)r[re)rprvrqrJrrrJrsrJrtrJrurJr[rw)r}r~rqrJrrrJrsrJrtrJrurJr[r)r[rr])r�r�r�r�r�r�r[r )rpr�r�r�r�r�ryrJrrrJrsrJrtrJr�rJrur�r�r�r�rJr[r�)r}r~r�r�r�r�ryrJrrrJrsrJrtrJr�rJrur�r�r�r�rJr[r)rMrNrOr4r5r-�os�environr�rZrP�propertyrrarb�
BaseConfigrdrlrrfr{r�r��classmethodr��model_constructrzr��
__classcell__rQrQrmrRrCVs�
��)�#�7�8��r�r�r�rr�rr[cCsJ|durt|�Str|j}ntt|j�}|durtd|����t||d�S)Nz"Unexpected field type is None for �r��type_)r>r4�
annotationr�type�outer_type_�RuntimeError�construct_type)r�r�r�r�rQrQrRr�sr�r�r�rJcCs0t|�rt|�D]	}t|�rdSqdSt|�S)zWReturns whether or not the given type is either a `BaseModel` or a union of `BaseModel`TF)r8r7�is_basemodel�is_basemodel_type)r��variantrQrQrRr��s�r��/TypeGuard[type[BaseModel] | type[GenericModel]]cCs.t|�p|}t�|�s
dSt|t�pt|t�S)NF)r:�inspect�isclass�
issubclassrCr6)r��originrQrQrRr��s
r��base_model_cls�Callable[P, _BaseModelT]�args�P.args�kwargs�P.kwargscOs|rtd��ttt||d��S)a?Construct a BaseModel class without validation.

    This is useful for cases where you need to instantiate a `BaseModel`
    from an API response as this provides type-safe params which isn't supported
    by helpers like `construct_type()`.

    ```py
    build(MyModel, my_field_a="foo", my_field_b=123)
    ```
    z]Received positional arguments which are not supported; Keyword arguments must be used instead�r�r�)�	TypeErrorrrEr�)r�r�r�rQrQrR�build�s
�r��type[_T]cCsttt||d��S)z�Loose coercion to the expected type with construction of nested values.

    Note: the returned value from this function is not guaranteed to match the
    given type.
    r�)rrDr�r�rQrQrR�construct_type_unchecked�sr�c	s�d}td���t��r�}�j�t��r"t��dd�}t�d��nt�}t��p*�}t��}t|�r�zt	td|p:��|d�WSt
yHYnwt�|d�}|rst|�rs|�
|jp\|j�}|rst|t�rs|j�
|�}|rst||d�S|D]}	z	t||	d�WSt
y�Yquwtd�����|tkr�t|�s�|St��\}
��fd	d
�|��D�St��s�t�|�r�t|t�s�t|t�r�t|�ṙfdd�|D�St|�r�t�t�r݈jdi|��Stt��jdi|��S|t kr�t|�s�|S|d��fd
d�|D�S|t!k�rt|t"��rt!|�}||k�r|S|S|S�t#k�r0zt$|�WSt
�y/|YSw�t%k�rGzt&|�WSt
�yF|YSw|S)z�Loose coercion to the expected type with construction of nested values.

    If the given value does not match the expected type then it is returned as-is.
    Nztype[object]rrr�)�union�meta_annotationsr�z0Could not convert data into a valid instance of csi|]\}}|t|�d��qS�r��r�)rhr��item)�
items_typerQrR�
<dictcomp>sz"construct_type.<locals>.<dictcomp>cs.g|]}t|�rtt��jdi|��n|�qS)rQ)r+rrr��rh�entry�r�rQrRrjs.z"construct_type.<locals>.<listcomp>csg|]}t|�d��qSr�r�r�)�
inner_typerQrRrjsrQ)'rr2�	__value__r1r7r0�tupler:r8�
validate_type�	Exception�_build_discriminated_union_metar+r��field_alias_from�
field_namer�r�mappingr�r�r�r�r;r�r�r�rCr6r'r�r�list�float�intrr.r
r,)r�r��
original_type�metar�r��
discriminator�
variant_value�variant_typer��_�coercedrQ)r�r�r�rRr��s�
������




�

�r�c@rH)�CachedDiscriminatorType�DiscriminatorDetails�__discriminator__NrLrQrQrQrRr�7rSr�c@s6eZdZUded<	ded<	ded<	ddd�Zd
S)r�rr��
str | Noner��dict[str, type]r��discriminator_field�discriminator_aliasr[�NonecCs||_||_||_dSr])r�r�r�)r`r�r�r�rQrQrR�__init__Ys
zDiscriminatorDetails.__init__N)r�r�r�rr�r�r[r�)rMrNrOrPr�rQrQrQrRr�<s


r�r�r��tuple[Any, ...]�DiscriminatorDetails | NonecCs:t|t�r|jSd}|D]}t|t�r|jdur|j}nq|s"dSi}d}t|�D]_}t|�}t|�r�trat	||�}|s>q*|�
d�}|d}|ddkr`td|�dD]}	t|	t�r_|||	<qTq*td|j
��
|�}
|
smq*|
j}|
jr�t|
j�r�t|
j�D]}	t|	t�r�|||	<q}q*|s�dSt|||d�}|tt|�_|S)	N�serialization_alias�schemar��literalrA�expectedzdict[str, FieldInfo])r�r�r�)r�r�r�r&r�r7r3r�r4�_extract_field_schema_pv2r�rr�
__fields__r�r�r;r�)r�r��discriminator_field_namer�r�r�r�r��field_schemar��
field_info�detailsrQrQrRr�esX
�


�
��r��model�type[BaseModel]r��ModelField | NonecCsX|j}|ddkrdS|d}|ddkrdStd|�}|d�|�}|s'dStd|�S)Nr�rrzmodel-fieldsrB�fieldsr@)�__pydantic_core_schema__rr�)rr�r�
fields_schemar�rQrQrRr�s

rcCs8t�|�rt|tj�rttt||��Sttt||d��S)z@Strict validation that the given value matches the expected typer�)	r�r�r�rbrCrrDr9�_validate_non_model_typer�rQrQrRr��sr��typrr��pydantic.ConfigDictr�cCst|d|�dS)zYAdd a pydantic config for the given type.

    Note: this is a no-op on Pydantic v1.
    �__pydantic_config__N)�setattr)rr�rQrQrR�set_pydantic_config�sr�obj�
request_idr�cCs^||_ts-z|j}Wntyddhtt|�_YdSwh|p!i�d�d�tt|�_dSdS)Nrfrg)rfr4rg�AttributeErrorrr)rr�exclude_fieldsrQrQrR�add_request_id�s
� �rc@seZdZdS)r6N)rMrNrOrQrQrQrRr6�s)�TypeAdapterzTypeAdapter[object])�maxsizecCst|��|�Sr])r�validate_pythonr�rQrQrRr�src@�eZdZUdZded<dS)�	RootModelz�Used as a placeholder to easily convert runtime types to a Pydantic format
        to provide validation.

        For example:
        ```py
        validated = RootModel[int](__root__="5").__root__
        # validated: 5
        ```
        rD�__root__N)rMrNrO�__doc__rPrQrQrQrRr �s

r cCst|��|�}tt|j�Sr])�_create_pydantic_model�validaterrDr!)r�r�rrQrQrRr�s�Type[RootModel[_T]]cCst|Sr])r r�rQrQrRr#�sr#c@s^eZdZUded<ded<ded<ded<ded	<d
ed<ded
<ded<ded<ded<dS)�FinalRequestOptionsInputz
Required[str]�method�urlr�paramsr!�headersr��max_retrieszfloat | Timeout | None�timeoutzHttpxRequestFiles | None�filesr�idempotency_keyr�	json_datar$�
extra_jsonNrLrQrQrQrRr&�s
r&F)�totalcs�eZdZUded<ded<iZded<e�Zded<e�Zded	<e�Zd
ed<dZ	d
ed<dZ
ded<e�Zded<dZded<dZ
ded<erSedd�Zded<n	Gdd�dej�Zd*dd �Zd+d"d#�Ze	d,d-�fd(d)�
�ZesyeZ�ZS�ZS).�FinalRequestOptionsrr'r(rr)zUnion[Headers, NotGiven]r*zUnion[int, NotGiven]r+z%Union[float, Timeout, None, NotGiven]r,NzUnion[HttpxRequestFiles, None]r-zUnion[str, None]r.z%Union[Callable[[Any], Any], NotGiven]�post_parserzUnion[Body, None]r/zUnion[AnyMapping, None]r0T)�arbitrary_types_allowedrYrZc@r)zFinalRequestOptions.ConfigTrJr4N)rMrNrOr4rPrQrQrQrRrd!s
rdr�r[cCst|jt�r|S|jSr])r�r+r#)r`r+rQrQrR�get_max_retries$sz#FinalRequestOptions.get_max_retriesr�cCs:t|j�sdS|j�t�ri|j�|_|j�t�dSdSr])r(r*r�r?�popr_rQrQrR�_strip_raw_response_header)s
�z.FinalRequestOptions._strip_raw_response_headerr�r�r�� Unpack[FinalRequestOptionsInput]csDdd�|��D�}trt�j|fi|��Sttt�j|fi|���S)NcSsi|]	\}}|t|��qSrQ)r/)rhr�r�rQrQrRr�=s��z1FinalRequestOptions.construct.<locals>.<dictcomp>)r�r4rkr�rr2r�)�clsr�r�r�rmrQrRr�7s�zFinalRequestOptions.construct)r+r�r[r�)r[r�r])r�r�r�r8r[r2)rMrNrOrPr)r#r*r+r,r-r.r3r/r0r4r5rZrbr�rdr5r7r�r�rr�r�rQrQrmrRr2s.


��r2)r�r�r�rr�rr[r�)r�r�r[rJ)r�r�r[r�)r�r�r�r�r�r�r[rE)r�r�r�r�r[rD)r�r�r�r�r[r�)r�r�r�r�r[r)rrr�rr[r
)r�r�r�r�r[rD)rrr�rr[r�)rrCrr�r[r�)r�rDr[r%)k�
__future__rr�r��typingrrrrrrr	r
rrrr
�typing_extensionsrrrrrrrrrrrrrb�pydantic.generics�pydantic.fieldsr�_typesrrrr r!r"r#r$r%�_utilsr&r'r(r)r*r+r,r-r.r/r0r1r2r3�_compatr4r5r6�BaseGenericModelr7r8r9r:r;r<r=r>�
_constantsr?�pydantic_core.core_schemar@rArB�__all__rDrErGrrerIrCr�r�r�r�r�r�r�r�r�rr�rrr�_TypeAdapter�_CachedTypeAdapterrr r#r&r2rQrQrQrR�<module>sp08,@4

+




	v
)
;