Ejemplo n.º 1
0
async def download_file(current_user: User = Depends(auth.get_current_user), ):
    """Download latest trained model file"""
    try:
        model_path = AgentProcessor.get_latest_model(current_user.get_bot())
        return FileResponse(model_path)
    except Exception as e:
        return AppException(str(e))
Ejemplo n.º 2
0
async def download_model(
        background_tasks: BackgroundTasks,
        current_user: User = Depends(auth.get_current_user),
):
    """Download latest trained model file"""
    try:
        model_path = AgentProcessor.get_latest_model(current_user.get_bot())
        response = FileResponse(model_path,
                                filename=os.path.basename(model_path),
                                background=background_tasks)
        response.headers[
            "Content-Disposition"] = "attachment; filename=" + os.path.basename(
                model_path)
        return response
    except Exception as e:
        raise AppException(str(e))