U
    	f0@                     @  sN  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 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, dd
l-m.Z.m/Z/m0Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z; ddgZ<e	dZ=eG dd deZ>G dd dej?Z?dddddddZ@dddddZAddddddZBd ddd!d"d#ZCere?Z0nG d$d de1e?Z0e.rd d%lmDZD d ddd!d&d'ZEn>es G d(d) d)e0ee= ZFd ddd!d*d'ZEdd+dd,d-ZGG d.d/ d/ed0d1ZHeG d2d3 d3ej?ZIdS )4    )annotationsN)TYPE_CHECKINGAnyTypeUnionGenericTypeVarCallablecast)datedatetime)	UnpackLiteralClassVarProtocolRequired	TypedDictfinaloverrideruntime_checkable)	FieldInfo   )	BodyIncExQueryModelTHeadersTimeoutNotGiven
AnyMappingHttpxRequestFiles)is_listis_given
is_mapping
parse_dateparse_datetimestrip_not_given)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	BaseModelr)   _Tc                   @  s   e Zd ZU ded< dS )_ConfigProtocolboolallow_population_by_field_nameN__name__
__module____qualname____annotations__ r=   r=   O/var/www/html/apigroqsegura/apigroq/lib/python3.8/site-packages/groq/_models.pyr5   6   s   
r5   c                      s  e Zd ZU er"eddZded< n(eeddddZ	G d	d
 d
e
jZeddddZeed&dddddddZeseZesedddddddddd	ddddddddddd
 fdd Zedddddddddd!	d"dddddddddd#
 fd$d%Z  ZS )'r3   allow)extraClassVar[ConfigDict]model_configzset[str]returnc                 C  s   | j S N)__fields_set__selfr=   r=   r>   model_fields_set@   s    zBaseModel.model_fields_setc                   @  s   e Zd ZU ejjZded< dS )zBaseModel.Configr   r@   N)r9   r:   r;   pydanticExtrar?   r@   r<   r=   r=   r=   r>   ConfigF   s   
rL   strc                 C  s   |    d| d dS )N(z, ))__repr_name____repr_str__rG   r=   r=   r>   __str__I   s    zBaseModel.__str__NzType[ModelT]set[str] | Noneobjectr   )cls_fields_setvaluesrD   c                 K  sD  |  | }i }t| }t|tr&|jn|d}|d kr>t }t| }| D ]\\}}	|	j	}
|
d ksp|
|krt|rt|}
|
|krt
||
 |	|
d||< || qNt|	||< qNi }| D ]0\}
}|
|krtr|||
< q||
 |||
< qt|d| tr*t|dd  t|d| t|d| n|  t|d| |S )Npopulate_by_name)valuefieldkey__dict____pydantic_private____pydantic_extra____pydantic_fields_set__rF   )__new__r/   
isinstancer5   r7   getsetr0   itemsalias_construct_fieldaddr1   r'   rT   __setattr__Z_init_private_attributes)rU   rV   rW   mfields_valuesconfigrX   model_fieldsnamerZ   r[   _extrarY   r=   r=   r>   	constructP   sB    



zBaseModel.constructpythonFT)	modeincludeexcludeby_aliasexclude_unsetexclude_defaultsexclude_none
round_tripwarningsz!Literal[('json', 'python')] | strr   r6   zdict[str, Any])
rq   rr   rs   rt   ru   rv   rw   rx   ry   rD   c       	   
        sH   |dkrt d|dkr t d|	dkr0t 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.
            rp   z%mode is only supported in Pydantic v2F+round_trip is only supported in Pydantic v2T)warnings is only supported in Pydantic v2)rr   rs   rt   ru   rv   rw   )
ValueErrorsuperdict)
rH   rq   rr   rs   rt   ru   rv   rw   rx   ry   	__class__r=   r>   
model_dump   s    "zBaseModel.model_dump)	indentrr   rs   rt   ru   rv   rw   rx   ry   z
int | None)
r   rr   rs   rt   ru   rv   rw   rx   ry   rD   c       	   
   	     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.
            Frz   Tr{   )r   rr   rs   rt   ru   rv   rw   )r|   r}   json)
rH   r   rr   rs   rt   ru   rv   rw   rx   ry   r   r=   r>   model_dump_json   s     zBaseModel.model_dump_json)N)r9   r:   r;   r'   r(   rB   r<   propertyr   rI   rJ   
BaseConfigrL   rR   classmethodro   r   model_constructr   r   __classcell__r=   r=   r   r>   r3   ;   sJ   
 7*0rT   r   rM   )rY   rZ   r[   rD   c                 C  sJ   | d krt |S tr|j}ntt|j}|d kr>td| t| |dS )Nz"Unexpected field type is None for rY   type_)r1   r'   
annotationr
   typeZouter_type_RuntimeErrorconstruct_type)rY   rZ   r[   r   r=   r=   r>   rf      s    rf   r   r6   )r   rD   c                 C  sH   t | p
| }t| r4t| D ]}t|r dS qdS t|tpFt|tS )zWReturns whether or not the given type is either a `BaseModel` or a union of `BaseModel`TF)r-   r+   r*   is_basemodel
issubclassr3   r)   )r   originvariantr=   r=   r>   r     s    r   )rY   r   rD   c              	     s  t p
}t}t|rzttd| dW S  tk
rD   Y nX |D ]0}zt| |dW   S  tk
rx   Y qJY qJX qJtd |tkrt	| s| S t\}fdd| 
 D S ts0t|tst|tr0t|  rfdd| D S t	| r0ttrjf | S ttjf | S |tkrbt| sH| S |d	   fd
d| D S |tkrt| trt| }|| kr| S |S | S tkrz
t| W S  tk
r   |  Y S X tkrz
t| W S  tk
r   |  Y S X | 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.
    ztype[object]r   rY   r   z0Could not convert data into a valid instance of c                   s   i | ]\}}|t | d qS r   r   ).0r[   item)
items_typer=   r>   
<dictcomp>0  s      z"construct_type.<locals>.<dictcomp>c                   s*   g | ]"}t |r"tt jf |n|qS r=   )r#   r
   r   ro   r   entryr   r=   r>   
<listcomp>4  s     z"construct_type.<locals>.<listcomp>r   c                   s   g | ]}t | d qS r   r   r   )
inner_typer=   r>   r   A  s     )r-   r*   r+   validate_typer
   	Exceptionr   r   r~   r#   rd   r.   r   r3   r)   r!   ro   r   listfloatra   intr   r%   r   r$   )rY   r   r   argsr   _Zcoercedr=   )r   r   r   r>   r     s`     











r   ztype[_T])r   rY   rD   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   rJ   r3   r
   r4   r,   _validate_non_model_typer   r=   r=   r>   r   [  s    r   c                   @  s   e Zd ZdS )r)   N)r9   r:   r;   r=   r=   r=   r>   r)   i  s   )TypeAdapterc                 C  s   t | |S rE   )r   validate_pythonr   r=   r=   r>   r   p  s    r   c                   @  s   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
        ```
        r4   __root__N)r9   r:   r;   __doc__r<   r=   r=   r=   r>   r   u  s   

r   c                 C  s   t | |}tt|jS rE   )_create_pydantic_modelvalidater
   r4   r   )r   rY   modelr=   r=   r>   r     s    zType[RootModel[_T]]c                 C  s   t |  S rE   )r   r   r=   r=   r>   r     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filesrM   idempotency_keyr   	json_datar   
extra_jsonNr8   r=   r=   r=   r>   r     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reddZded< nG dd dejZddddd Zd!d"d#d$Zed*d%d&d d' fd(d)ZeseZ  ZS )+FinalRequestOptionsrM   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_allowedrA   rB   c                   @  s   e Zd ZU dZded< dS )zFinalRequestOptions.ConfigTr6   r   N)r9   r:   r;   r   r<   r=   r=   r=   r>   rL     s   
rL   r   )r   rD   c                 C  s   t | jtr|S | jS rE   )ra   r   r   )rH   r   r=   r=   r>   get_max_retries  s    z#FinalRequestOptions.get_max_retriesNonerC   c                 C  s4   t | jsd S | jtr0| j| _| jt d S rE   )r"   r   rb   r2   poprG   r=   r=   r>   _strip_raw_response_header  s
    

z.FinalRequestOptions._strip_raw_response_headerrS   z Unpack[FinalRequestOptionsInput])rV   rW   rD   c                   s<   dd |  D }tr&t j|f|S ttt j|f|S )Nc                 S  s   i | ]\}}|t |qS r=   )r&   )r   r[   rY   r=   r=   r>   r     s    z1FinalRequestOptions.construct.<locals>.<dictcomp>)rd   r'   r}   r   r
   r   ro   )rU   rV   rW   kwargsr   r=   r>   ro     s    zFinalRequestOptions.construct)N)r9   r:   r;   r<   r   r   r   r   r   r   r   r   r   r   r'   r(   rB   rJ   r   rL   r   r   r   ro   r   r   r   r=   r=   r   r>   r     s*   
 r   )J
__future__r   r   typingr   r   r   r   r   r   r	   r
   r   r   typing_extensionsr   r   r   r   r   r   r   r   r   rJ   Zpydantic.genericspydantic.fieldsr   _typesr   r   r   r   r   r   r   r   r    _utilsr!   r"   r#   r$   r%   r&   _compatr'   r(   r)   ZBaseGenericModelr*   r+   r,   r-   r.   r/   r0   r1   
_constantsr2   __all__r4   r5   r3   rf   r   r   r   r   r   r   r   r   r   r=   r=   r=   r>   <module>   sD   (,, 4 ;J
