Ryanhub - file viewer
filename: __pycache__/server.cpython-310.pyc
branch: main
back to repo
o

hQ�i&�@s�ddlmZddlmZddlmZddlZddlZddlZe�Z	e	j
dedd�dd�e	j
d	ed
d�d
d�e	�d�dd
��Zdd�Z
dd�Ze	�d�defdd��ZdS)�)�FastAPI��FileResponse)�StaticFilesNz/staticZstatic)�	directory)�namez/promptsZprompts�/cCstd�S)Nzstatic/index.htmlr�r	r	�;C:\Users\Ralpo\OneDrive\Desktop\research-frontend\server.py�rootsrcCs8tdd��
}t�|�Wd�S1swYdS)Nzconfig.json�r)�open�json�load)�fr	r	r
�load_configs$�rc
�s��|d}|d}|d}|�d|��}zQ|jd|�d�||dd�d	d
�4IdH�,}|��d}|��2z3dHW}	|	rIt�|	�}
||
�dd�7}q46Wd�IdHn1IdHs[wY||d
�WSty~}z
|t|�d�WYd}~Sd}~ww)N�urlrZnotez

MODEL NOTE: �POSTz
/api/generateT)�model�prompt�stream�x)r�timeout��response)r�output)r�error)rZraise_for_statusZaiter_linesr�loads�get�	Exception�str)�clientZmodel_config�full_promptZ	model_urlZ
model_nameZ
model_noteZaugmented_promptrr�line�data�er	r	r
�	run_modelsD���	
��(�����r&z/api/run-all�payloadc	�s��|�dd�}tdd��}|��}Wd�n1swYd|�d|���t�}|�dg�}t��4IdH����fdd	�|D�}tj|�IdH}Wd�IdH|S1IdHs]wY|S)
Nrrzprompts/motion-description.txtrzSYSTEM:
z

USER:
�modelscsg|]}t�|���qSr	)r&)�.0r�r!r"r	r
�
<listcomp>Ls
��zrun_all.<locals>.<listcomp>)rr
�readr�httpxZAsyncClient�asyncio�gather)r'rr�context�configr(�tasks�resultsr	r*r
�run_all>s"�
����r4)ZfastapirZfastapi.responsesrZfastapi.staticfilesrr-r.r�appZmountrrrr&Zpost�dictr4r	r	r	r
�<module>s
&