o
    @Bi:
                     @  sj   d dl mZ d dlmZ d dlmZ d dlZddlmZ	m
Z
 ddlmZ dddZdddZdddZdS )    )annotations)Any)	TypeGuardN   )is_dictis_list)model_json_schemamodeltype[pydantic.BaseModel]returndict[str, Any]c                 C  s   t t| ddS )N path)_ensure_strict_json_schemar   )r	   r   r   T/var/www/html/Trade-python/venv/lib/python3.10/site-packages/openai/lib/_pydantic.pyto_strict_json_schema   s   r   json_schemaobjectr   tuple[str, ...]c                   s  t | std|  d  | d}|dkrd| vrd| d< | d}t |r@dd	 | D | d
<  fdd| D | d< | d}t |rVt|g  dR d| d< | d}t|rl fdd	t|D | d< | d}t|r fdd	t|D | d< | d}t |r| D ]\}}	t|	g  d|R d q| d}
t |
r|
 D ]\}}t|g  d|R d q| 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=typer   additionalPropertiesF
propertiesc                 S  s   g | ]}|qS r   r   ).0propr   r   r   
<listcomp>"   s    z._ensure_strict_json_schema.<locals>.<listcomp>requiredc                   s,   i | ]\}}|t |g  d |R dqS )r   r   )r   )r   keyprop_schemar   r   r   
<dictcomp>#   s    z._ensure_strict_json_schema.<locals>.<dictcomp>itemsr   anyOfc                   .   g | ]\}}t |g  d t|R dqS r!   r   r   str)r   ivariantr   r   r   r   1       "allOfc                   r"   r#   r$   )r   r&   entryr   r   r   r   8   r(   z$defsdefinitions)r   	TypeErrorgetkeysr    r   r   	enumerate)r   r   typr   r    any_ofall_ofdefsdef_name
def_schemar+   definition_namedefinition_schemar   r   r   r      sB   












r   objTypeGuard[dict[str, object]]c                 C  s   t | S )N)_is_dict)r8   r   r   r   r   I   s   r   )r	   r
   r   r   )r   r   r   r   r   r   )r8   r   r   r9   )
__future__r   typingr   typing_extensionsr   pydantic_utilsr   r:   r   _compatr   r   r   r   r   r   r   <module>   s    

9