Ë
    Fü´j5  ã                  ó˜   — d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
Z
d dlZd dlZ
 ed«      Z e	d«      Z	 	 	 	 	 	 	 	 d	d„Zd
d„Zy)é    )ÚannotationsN)ÚTypeVarÚCallableÚ	Awaitable)Ú	ParamSpecÚT_RetvalÚT_ParamSpecc             �  óþ   K  — t        j                  «       dk(  r!t        j                  | g|¢­i |¤Žƒ d {  –—† S t        j                  j                  t        j                  | g|¢­i |¤Ž«      ƒ d {  –—† S 7 ŒB7 Œ­w)NÚasyncio)ÚsniffioÚcurrent_async_libraryr   Ú	to_threadÚanyioÚrun_syncÚ	functoolsÚpartial)ÚfuncÚargsÚkwargss      úQ/root/workspace/ytshorts/venv/lib/python3.12/site-packages/openai/_utils/_sync.pyr   r      sv   è ø€ ô ×$Ñ$Ó&¨)Ò3Ü×&Ñ& tÐ=¨dÒ=°fÑ=×=Ð=ä—‘×)Ñ)Ü×Ñ˜$Ð0 Ò0¨Ñ0ó÷ ð ð >øðús!   ‚4A=¶A9·=A=Á4A;Á5A=Á;A=c                ó   ‡ — dˆ fd„}|S )ac  
    Take a blocking function and create an async one that receives the same
    positional and keyword arguments.

    Usage:

    ```python
    def blocking_func(arg1, arg2, kwarg1=None):
        # blocking code
        return result


    result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
    ```

    ## Arguments

    `function`: a blocking regular callable (e.g. a function)

    ## Return

    An async function that takes the same positional and keyword arguments as the
    original one, that when called runs the same original function in a thread worker
    and returns the result.
    c               Ÿ  ó>   •K  — t        ‰g| ¢­i |¤Žƒ d {  –—† S 7 Œ­w)N)r   )r   r   Úfunctions     €r   Úwrapperzasyncify.<locals>.wrapper7   s"   øè ø€ Ü˜xÐ9¨$Ò9°&Ñ9×9Ð9Ð9ús   ƒ–—)r   úT_ParamSpec.argsr   úT_ParamSpec.kwargsÚreturnr   © )r   r   s   ` r   Úasyncifyr      s   ø€ õ6:ð €Nó    )r   úCallable[T_ParamSpec, T_Retval]r   r   r   r   r   r   )r   r!   r   z*Callable[T_ParamSpec, Awaitable[T_Retval]])Ú
__future__r   r   r   Útypingr   r   r   Útyping_extensionsr   r   r   Úanyio.to_threadr   r	   r   r   r   r    r   ú<module>r&      s^   ðÝ "ã Û ß /Ñ /Ý 'ã Û Û á�:Ó€Ù˜Ó&€ðØ
)ðØ5EðØQcðàóôr    