o
    /if                   
   @   sL   d Z ddlZddlmZmZmZ 		ddee deded	ee fd
dZdS )zAsync utils.    N)Any	CoroutineListFRunning async taskstasksshow_progressprogress_bar_descreturnc              
      s   | zt  }zddl}W n ty   tdw |  W n ty+   t  }Y nw |rBddlm dt	t
 f fdd}ndt	t
 ffdd}z	|| }W |S  tyh } ztd	||d}~ww )
zRun a list of async tasks.r   Nzinest_asyncio is required to run async tasks in jupyter. Please install it via `pip install nest_asyncio`.)tqdmr	   c                      s   j d iI dH S )z"gather tasks and show progress bardescN)gather r   tasks_to_executer
   r   J/var/www/html/corbot_env/lib/python3.10/site-packages/ragas/async_utils.py_gather    s   z run_async_tasks.<locals>._gatherc                      s   t j  I d H S )N)asyncior   r   )r   r   r   r   &   s   z/Fatal error occurred while running async tasks.)r   get_running_loopnest_asyncioImportErrorRuntimeErrorapplynew_event_looptqdm.asyncior
   r   r   run_until_complete	Exception)r   r   r   loopr   r   outputser   r   r   run_async_tasks   s2   r   )Fr   )	__doc__r   typingr   r   r   boolstrr   r   r   r   r   <module>   s    