U
    —ÀÂhç  ã                   @   sN   d dl mZmZ eeeef edœdd„Zeedœdd„Zeedœd	d
„ZdS )é    )ÚAnyÚDict)ÚschemaÚdefinitionsÚreturnc                 C   sŽ   t | tƒr,t| ƒD ]\}}t||ƒ| |< qn^t | tƒrŠd| krj|  d¡ d¡d }| |i ¡}|  |¡ n |  	¡ D ]\}}t||ƒ| |< qr| S )zW
    Resolve the $ref keys in a JSON schema object using the provided definitions.
    z$refú/éÿÿÿÿ)
Ú
isinstanceÚlistÚ	enumerateÚ_resolve_schema_referencesÚdictÚpopÚsplitÚgetÚupdateÚitems)r   r   ÚiÚitemZref_keyÚrefÚkeyÚvalue© r   úK/tmp/pip-unpacked-wheel-bo69hh5q/langchain/chains/openai_functions/utils.pyr      s    

r   )r   r   c                 C   s*   dd„ | d   ¡ D ƒ}d||  dg ¡dœS )Nc                 S   s   i | ]\}}|d |i|–“qS )Útitler   )Ú.0ÚkÚvr   r   r   Ú
<dictcomp>   s      z#_convert_schema.<locals>.<dictcomp>Ú
propertiesÚobjectÚrequired)Útyper   r!   )r   r   )r   Úpropsr   r   r   Ú_convert_schema   s
    
ýr$   )Úfunctionr   c                 C   s   | gd| d idœS )z¥Return the kwargs for the LLMChain constructor.

    Args:
        function: The function to use.

    Returns:
        The kwargs for the LLMChain constructor.
    Úname)Z	functionsZfunction_callr   )r%   r   r   r   Úget_llm_kwargs   s    	r'   N)Útypingr   r   Ústrr   r   r$   r'   r   r   r   r   Ú<module>   s   	