o
    jU                     @  s~  d dl mZ d dlZd dlmZmZmZmZmZm	Z	m
Z
mZ d dlmZmZ d dlmZmZmZmZmZmZmZmZmZmZ d dlZd dlZd dlmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dd	l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 dd
l2m3Z3m4Z4m5Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ erd dlAmBZBmCZC ddgZDe	dZEeG dd deZFG dd dejGZGdIddZHdJdd ZIdKd"d#ZJdLd$d%ZKeG d&d' d'eZLG d(d) d)ZMdMd.d/ZNdNd4d5ZOdOd7d8ZPereGZ5n	G d9d de6eGZ5e3rd d:lmQZQ dOd;d<ZRnes(G d=d> d>e5eeE ZSdOd?d<ZRdPdAdBZTG dCdD dDedEdFZUeG dGdH dHejGZVdS )Q    )annotationsN)TYPE_CHECKINGAnyTypeUnionGenericTypeVarCallablecast)datedatetime)
UnpackLiteralClassVarProtocolRequired	TypedDict	TypeGuardfinaloverrideruntime_checkable)	FieldInfo   )	BodyIncExQueryModelTHeadersTimeoutNotGiven
AnyMappingHttpxRequestFiles)
PropertyInfois_listis_given
is_mapping
parse_dateparse_datetimestrip_not_givenextract_type_argis_annotated_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ModelFieldsSchema	BaseModelr.   _Tc                   @     e Zd ZU ded< dS )_ConfigProtocolboolallow_population_by_field_nameN__name__
__module____qualname____annotations__ rE   rE   T/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/openai/_models.pyr=   E      
 r=   c                      s   e Zd ZU ereddZded< need0ddZ	G d	d
 d
e
jZed1ddZee	d2d3ddZes9eZesgedddddddddd	d4 fd)d*Zedddddddddd+	d5 fd.d/Z  ZS   ZS )6r:   allow)extraClassVar[ConfigDict]model_configreturnset[str]c                 C  s   | j S N)__fields_set__selfrE   rE   rF   model_fields_setO   s   zBaseModel.model_fields_setc                   @  s   e Zd ZU ejjZded< dS )zBaseModel.Configr   rI   N)rA   rB   rC   pydanticExtrarH   rI   rD   rE   rE   rE   rF   ConfigU   s   
 rU   strc                 C  s   |    d| d dS )N(z, ))__repr_name____repr_str__rP   rE   rE   rF   __str__X   s   zBaseModel.__str__NclsType[ModelT]_fields_setset[str] | Nonevaluesobjectr   c                 K  sD  |  | }i }t| }t|tr|jn|d}|d u rt }t| }| D ].\}}	|	j	}
|
d u s8|
|vr:|r:|}
|
|v rOt
||
 |	|
d||< || q't|	||< q'i }| D ]\}
}|
|vrttrk|||
< q\||
 |||
< q\t|d| trt|dd  t|d| t|d| |S |  t|d| |S )Npopulate_by_name)valuefieldkey__dict____pydantic_private____pydantic_extra____pydantic_fields_set__rO   )__new__r4   
isinstancer=   r?   getsetr5   itemsalias_construct_fieldaddr6   r,   ra   __setattr___init_private_attributes)r\   r^   r`   mfields_valuesconfigrb   model_fieldsnamerd   re   _extrarc   rE   rE   rF   	construct_   sF   


zBaseModel.constructpythonFT)	modeincludeexcludeby_aliasexclude_unsetexclude_defaultsexclude_none
round_tripwarningsr|   Literal['json', 'python'] | strr}   r   r~   r   r>   r   r   r   r   r   dict[str, Any]c       	   
        sH   |dkrt d|dkrt d|	dkrt dt j||||||d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.
            r{   z%mode is only supported in Pydantic v2F+round_trip is only supported in Pydantic v2T)warnings is only supported in Pydantic v2)r}   r~   r   r   r   r   )
ValueErrorsuperdict)
rQ   r|   r}   r~   r   r   r   r   r   r   	__class__rE   rF   
model_dump   s   "zBaseModel.model_dump)	indentr}   r~   r   r   r   r   r   r   r   
int | Nonec       	   
   	     s:   |dkrt d|	dkrt d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   )r   r}   r~   r   r   r   r   )r   r   json)
rQ   r   r}   r~   r   r   r   r   r   r   r   rE   rF   model_dump_json   s    zBaseModel.model_dump_json)rL   rM   )rL   rV   rN   )r\   r]   r^   r_   r`   ra   rL   r   )r|   r   r}   r   r~   r   r   r>   r   r>   r   r>   r   r>   r   r>   r   r>   rL   r   )r   r   r}   r   r~   r   r   r>   r   r>   r   r>   r   r>   r   r>   r   r>   rL   rV   )rA   rB   rC   r,   r-   rK   rD   propertyr   rR   rS   
BaseConfigrU   r[   classmethodrz   r   model_constructr   r   __classcell__rE   rE   r   rF   r:   J   sN   
 70rc   ra   rd   r   re   rV   rL   c                 C  sJ   | d u rt |S tr|j}ntt|j}|d u rtd| t| |dS )Nz"Unexpected field type is None for rc   type_)r6   r,   
annotationr
   typeouter_type_RuntimeErrorconstruct_type)rc   rd   re   r   rE   rE   rF   rp     s   rp   r   r   r>   c                 C  s0   t | rt| D ]	}t|r dS qdS t| S )zWReturns whether or not the given type is either a `BaseModel` or a union of `BaseModel`TF)r0   r/   is_basemodelis_basemodel_type)r   variantrE   rE   rF   r     s   r   /TypeGuard[type[BaseModel] | type[GenericModel]]c                 C  s    t | p| }t|tpt|tS rN   )r2   
issubclassr:   r.   )r   originrE   rE   rF   r     s   r   c              	     s^  t rtdd }tdnt }tp}t}t|rz
ttd| dW S  ty6   Y nw t	|d}|rat
| ra| |jpJ|j}|rat|tra|j|}|rat|| dS |D ]}z	t| |dW   S  tyw   Y qcw td |tkrt
| s| S t\}	fd	d
|  D S tst|tst|trt| rfdd| D S t
| rttrƈjdi | S ttjdi | S |tkrt| s| S |d   fdd| D S |tkrt| trt| }
|
| kr| S |
S | S tkrzt | W S  ty   |  Y S w t!kr-zt"| W S  ty,   |  Y S w | S )zLoose 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.
    r   Nr   ztype[object]r   rc   )unionmeta_annotationsr   z0Could not convert data into a valid instance of c                   s   i | ]\}}|t | d qS r   r   ).0re   item)
items_typerE   rF   
<dictcomp>_  s    z"construct_type.<locals>.<dictcomp>c                   s.   g | ]}t |rtt jd i |n|qS )rE   )r%   r
   r   rz   r   entryr   rE   rF   
<listcomp>c  s   . z"construct_type.<locals>.<listcomp>c                   s   g | ]}t | d qS r   r   r   )
inner_typerE   rF   r   p  s    rE   )#r*   r/   r)   tupler2   r0   validate_typer
   	Exception_build_discriminated_union_metar%   rl   field_alias_from
field_namerk   rV   mappingr   r   r   rn   r3   r   r:   r.   r#   rz   r   listfloatintr   r'   r   r&   )rc   r   metar   argsdiscriminatorvariant_valuevariant_typer   _coercedrE   )r   r   r   rF   r   $  s~   





r   c                   @  r<   )CachedDiscriminatorTypeDiscriminatorDetails__discriminator__Nr@   rE   rE   rE   rF   r     rG   r   c                   @  s6   e Zd ZU ded< 	 ded< 	 ded< 	 dddZdS )r   rV   r   
str | Noner   dict[str, type]r   discriminator_fielddiscriminator_aliasrL   Nonec                C  s   || _ || _|| _d S rN   )r   r   r   )rQ   r   r   r   rE   rE   rF   __init__  s   
zDiscriminatorDetails.__init__N)r   r   r   rV   r   r   rL   r   )rA   rB   rC   rD   r   rE   rE   rE   rF   r     s   
 

r   r   r   tuple[Any, ...]DiscriminatorDetails | Nonec                 C  s4  t | tr| jS d }|D ]}t |tr|jd ur|j} nq|s"d S i }d }t| D ]\}t|}t|rtr^t	||}|s>q*|
d}|d }|d dkr]|d D ]}	t |	tr\|||	< qQq*td|j
|}
|
sjq*|
j}|
jrt|
jrt|
jD ]}	t |	tr|||	< qzq*|sd S t|||d}|tt| _|S )Nserialization_aliasschemar   literalexpectedzdict[str, FieldInfo])r   r   r   )rk   r   r   r"   r   r/   r+   r   r,   _extract_field_schema_pv2rl   rV   r
   
__fields__ro   r   r3   r   )r   r   discriminator_field_namer   r   r   r   rd   field_schemar   
field_infodetailsrE   rE   rF   r     sX   




r   modeltype[BaseModel]r   ModelField | Nonec                 C  sX   | j }|d dkrd S |d }|d dkrd S td|}|d |}|s'd S td|S )Nr   r   r   zmodel-fieldsr9   fieldsr8   )__pydantic_core_schema__r
   rl   )r   r   r   fields_schemard   rE   rE   rF   r     s   

r   type[_T]c                 C  s8   t | rt| tjrttt| |S ttt| |dS )z@Strict validation that the given value matches the expected typer   )	inspectisclassr   rS   r:   r
   r;   r1   _validate_non_model_typer   rE   rE   rF   r     s   r   c                   @  s   e Zd ZdS )r.   N)rA   rB   rC   rE   rE   rE   rF   r.     s    )TypeAdapterc                 C  s   t | |S rN   )r   validate_pythonr   rE   rE   rF   r     s   r   c                   @     e Zd ZU dZded< dS )	RootModelzUsed 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
        ```
        r;   __root__N)rA   rB   rC   __doc__rD   rE   rE   rE   rF   r     s   
 
r   c                 C  s   t | |}tt|jS rN   )_create_pydantic_modelvalidater
   r;   r   )r   rc   r   rE   rE   rF   r   ,  s   Type[RootModel[_T]]c                 C  s   t |  S rN   )r   r   rE   rE   rF   r   0  s   r   c                   @  s^   e Zd ZU ded< ded< ded< ded< ded	< d
ed< ded< ded< ded< ded< dS )FinalRequestOptionsInputzRequired[str]methodurlr   paramsr   headersr   max_retrieszfloat | Timeout | NonetimeoutzHttpxRequestFiles | NonefilesrV   idempotency_keyr   	json_datar    
extra_jsonNr@   rE   rE   rE   rF   r   4  s   
 r   F)totalc                      s   e Zd ZU ded< ded< i Zded< e Zded< e Zded	< e Zd
ed< dZ	ded< dZ
ded< e Zded< dZded< dZded< erSeddZded< n	G dd dejZd*dd Zd+d"d#Ze	d,d- fd(d)ZesyeZ  ZS   ZS ).FinalRequestOptionsrV   r   r   r   r   zUnion[Headers, NotGiven]r   zUnion[int, NotGiven]r   z%Union[float, Timeout, None, NotGiven]r   NzUnion[HttpxRequestFiles, None]r   zUnion[str, None]r   z%Union[Callable[[Any], Any], NotGiven]post_parserzUnion[Body, None]r   zUnion[AnyMapping, None]r   T)arbitrary_types_allowedrJ   rK   c                   @  r   )zFinalRequestOptions.ConfigTr>   r   N)rA   rB   rC   r   rD   rE   rE   rE   rF   rU   V  s   
 rU   r   rL   c                 C  s   t | jtr|S | jS rN   )rk   r   r   )rQ   r   rE   rE   rF   get_max_retriesY  s   z#FinalRequestOptions.get_max_retriesr   c                 C  s:   t | jsd S | jtri | j| _| jt d S d S rN   )r$   r   rl   r7   poprP   rE   rE   rF   _strip_raw_response_header^  s   
z.FinalRequestOptions._strip_raw_response_headerr^   r_   r`    Unpack[FinalRequestOptionsInput]c                   sD   dd |  D }trt j|fi |S ttt j|fi |S )Nc                 S  s   i | ]	\}}|t |qS rE   )r(   )r   re   rc   rE   rE   rF   r   r  s    z1FinalRequestOptions.construct.<locals>.<dictcomp>)rn   r,   r   r   r
   r   rz   )r\   r^   r`   kwargsr   rE   rF   rz   l  s   zFinalRequestOptions.construct)r   r   rL   r   )rL   r   rN   )r^   r_   r`   r   rL   r   )rA   rB   rC   rD   r   r   r   r   r   r   r   r   r   r   r,   r-   rK   rS   r   rU   r   r   r   rz   r   r   r   rE   rE   r   rF   r   A  s.   
 

r   )rc   ra   rd   r   re   rV   rL   ra   )r   r   rL   r>   )r   r   rL   r   )rc   ra   r   r   rL   ra   )r   r   r   r   rL   r   )r   r   r   rV   rL   r   )r   r   rc   ra   rL   r;   )r   r;   rL   r   )W
__future__r   r   typingr   r   r   r   r   r   r	   r
   r   r   typing_extensionsr   r   r   r   r   r   r   r   r   r   rS   pydantic.genericspydantic.fieldsr   _typesr   r   r   r   r   r   r   r    r!   _utilsr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   _compatr,   r-   r.   BaseGenericModelr/   r0   r1   r2   r3   r4   r5   r6   
_constantsr7   pydantic_core.core_schemar8   r9   __all__r;   r=   r:   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rE   rE   rE   rF   <module>   sV    (0,04 
;


f
)
;



