feat : Supporting Multiple Pipeline Uploads via Automation to OpenWebUI #95

Open
opened 2026-02-15 19:15:47 -05:00 by yindo · 0 comments
Owner

Originally created by @wooandrich on GitHub (Aug 10, 2024).

Is your feature request related to a problem? Please describe.
I want to create an automation where, instead of manually uploading a pipeline on the OpenWebUI website, developers can upload a pipeline Python file to GitHub or GitLab, and the pipeline is automatically uploaded to OpenWebUI via the /api/pipelines/upload API. Currently, this API only allows uploading a single pipeline at a time, so it is not possible to upload multiple pipeline files simultaneously.

Describe the solution you'd like
It would be nice to upload several files at once using the array.

Describe alternatives you've considered
If it's another alternative, I can call api as many files, but I don't think it's an efficient alternative.

Additional context
This is the current api code.

@app.post("/api/pipelines/upload")
async def upload_pipeline(
    urlIdx: int = Form(...), file: UploadFile = File(...), user=Depends(get_admin_user)
):
    print("upload_pipeline", urlIdx, file.filename)
    # Check if the uploaded file is a python file
    if not file.filename.endswith(".py"):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Only Python (.py) files are allowed.",
        )

    upload_folder = f"{CACHE_DIR}/pipelines"
    os.makedirs(upload_folder, exist_ok=True)
    file_path = os.path.join(upload_folder, file.filename)

    r = None
    try:
        # Save the uploaded file
        with open(file_path, "wb") as buffer:
            shutil.copyfileobj(file.file, buffer)

        url = openai_app.state.config.OPENAI_API_BASE_URLS[urlIdx]
        key = openai_app.state.config.OPENAI_API_KEYS[urlIdx]

        headers = {"Authorization": f"Bearer {key}"}

        with open(file_path, "rb") as f:
            files = {"file": f}
            r = requests.post(f"{url}/pipelines/upload", headers=headers, files=files)

        r.raise_for_status()
        data = r.json()

        return {**data}
    except Exception as e:
        # Handle connection error here
        print(f"Connection error: {e}")

        detail = "Pipeline not found"
        status_code = status.HTTP_404_NOT_FOUND
        if r is not None:
            status_code = r.status_code
            try:
                res = r.json()
                if "detail" in res:
                    detail = res["detail"]
            except Exception:
                pass

        raise HTTPException(
            status_code=status_code,
            detail=detail,
        )
    finally:
        # Ensure the file is deleted after the upload is completed or on failure
        if os.path.exists(file_path):
            os.remove(file_path)

Originally created by @wooandrich on GitHub (Aug 10, 2024). **Is your feature request related to a problem? Please describe.** I want to create an automation where, instead of manually uploading a pipeline on the OpenWebUI website, developers can upload a pipeline Python file to GitHub or GitLab, and the pipeline is automatically uploaded to OpenWebUI via the /api/pipelines/upload API. Currently, this API only allows uploading a single pipeline at a time, so it is not possible to upload multiple pipeline files simultaneously. **Describe the solution you'd like** It would be nice to upload several files at once using the array. **Describe alternatives you've considered** If it's another alternative, I can call api as many files, but I don't think it's an efficient alternative. **Additional context** This is the current api code. ```python @app.post("/api/pipelines/upload") async def upload_pipeline( urlIdx: int = Form(...), file: UploadFile = File(...), user=Depends(get_admin_user) ): print("upload_pipeline", urlIdx, file.filename) # Check if the uploaded file is a python file if not file.filename.endswith(".py"): raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail="Only Python (.py) files are allowed.", ) upload_folder = f"{CACHE_DIR}/pipelines" os.makedirs(upload_folder, exist_ok=True) file_path = os.path.join(upload_folder, file.filename) r = None try: # Save the uploaded file with open(file_path, "wb") as buffer: shutil.copyfileobj(file.file, buffer) url = openai_app.state.config.OPENAI_API_BASE_URLS[urlIdx] key = openai_app.state.config.OPENAI_API_KEYS[urlIdx] headers = {"Authorization": f"Bearer {key}"} with open(file_path, "rb") as f: files = {"file": f} r = requests.post(f"{url}/pipelines/upload", headers=headers, files=files) r.raise_for_status() data = r.json() return {**data} except Exception as e: # Handle connection error here print(f"Connection error: {e}") detail = "Pipeline not found" status_code = status.HTTP_404_NOT_FOUND if r is not None: status_code = r.status_code try: res = r.json() if "detail" in res: detail = res["detail"] except Exception: pass raise HTTPException( status_code=status_code, detail=detail, ) finally: # Ensure the file is deleted after the upload is completed or on failure if os.path.exists(file_path): os.remove(file_path)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/pipelines#95