CoolFace
Apppublic

vineyard03/Code-Repair-With-LLMs

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
initiate_pipeline_call.py34 linesDownload Raw Back to api
1import requests2import os3import mimetypes4 5API_URL = "http://localhost:8000/api/initiate_pipeline"6 7def initiate_pipeline_call(files, pipeline_steps):8    """9    Initiate the pipeline with multiple files.10    11    Args:12        files: List of tuples containing file information (name, content, type)13        pipeline_steps: Integer representing selected pipeline steps14    """15 16    file_data = []17    18    for file in files:19        mime_type = mimetypes.guess_type(file.name)[0] or "application/octet-stream"20        21        # Ensure we send the actual file content22        with open(file.name, "rb") as f:23            file_data.append(("files", (file.name, f.read(), mime_type)))  24 25    try:26        response = requests.post(27            f"{API_URL}?pipeline_steps={pipeline_steps}", 28            files=file_data29        )30        31        response.raise_for_status()  # Raise exception for bad status codes32        return response.json()33    except requests.exceptions.RequestException as e:34        return f"Error: {str(e)}"