U
    ‡ÀÂh±  ã                   @  s¨   d dl mZ d dlmZmZmZ d dlZddlmZ ddl	m
Z
 ddlmZ dd	lmZ G d
d„ deeef ƒZG dd„ deeef ƒZdddœdddddœdd„ZdS )é    )Úannotations)ÚAnyÚDictÚcastNé   )Úto_strict_json_schemaé   )ÚChatCompletionFunctionToolParam)ÚFunctionDefinition)ÚFunctionToolParamc                      sB   e Zd ZU dZded< ddddœ‡ fdd„Zdd	œd
d„Z‡  ZS )ÚPydanticFunctionToolzŠDictionary wrapper so we can pass the given base model
    throughout the entire request stack without having to special
    case it.
    útype[pydantic.BaseModel]Úmodelr
   ÚNone)Údefnr   Úreturnc                   s   t ƒ  |¡ || _d S ©N©ÚsuperÚ__init__r   )Úselfr   r   ©Ú	__class__© ú5/tmp/pip-unpacked-wheel-dms8d3uv/openai/lib/_tools.pyr      s    zPydanticFunctionTool.__init__©r   c                 C  s
   t t| ƒS r   )r   r
   ©r   r   r   r   r      s    zPydanticFunctionTool.cast)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   Ú__classcell__r   r   r   r   r      s   
r   c                      s>   e Zd ZU ded< ddddœ‡ fdd„Zddœd	d
„Z‡  ZS )ÚResponsesPydanticFunctionToolr   r   ÚResponsesFunctionToolParamr   )Útoolr   r   c                   s   t ƒ  |¡ || _d S r   r   )r   r%   r   r   r   r   r       s    z&ResponsesPydanticFunctionTool.__init__r   c                 C  s
   t t| ƒS r   )r   r$   r   r   r   r   r   $   s    z"ResponsesPydanticFunctionTool.cast)r   r   r   r!   r   r   r"   r   r   r   r   r#      s   
r#   )ÚnameÚdescriptionr   z
str | Noner	   )r   r&   r'   r   c                C  sH   |d kr| j }t|p| jdt| ƒdœ| ƒ ¡ }|d k	r>||d< d|dœS )NT)r&   ÚstrictÚ
parametersr'   Úfunction)Útyper*   )r    r   r   r   r   )r   r&   r'   r*   r   r   r   Úpydantic_function_tool(   s    ýú	þr,   )Ú
__future__r   Útypingr   r   r   ZpydanticZ	_pydanticr   Z
types.chatr	   Ztypes.shared_paramsr
   Z#types.responses.function_tool_paramr   r$   Ústrr   r#   r,   r   r   r   r   Ú<module>   s   ü