import re with open("gateway.py", "r") as f: code = f.read() # Let's inspect the headers sent new_execute_completion = """async def execute_completion(payload: dict[str, Any], is_authenticated: bool = False, priority_override: int | None = None) -> dict[str, Any]: await wait_for_llama() async with inference_lock.context(is_authenticated, priority_override): async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as client: headers = llama_auth_headers() print(f"Sending to {LLAMA_URL}/v1/chat/completions with headers: {headers}", flush=True) response = await client.post( f"{LLAMA_URL}/v1/chat/completions", json=ensure_language_guard(payload), headers=headers, ) response.raise_for_status() return response.json()""" old_execute_completion = """async def execute_completion(payload: dict[str, Any], is_authenticated: bool = False, priority_override: int | None = None) -> dict[str, Any]: await wait_for_llama() async with inference_lock.context(is_authenticated, priority_override): async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as client: response = await client.post( f"{LLAMA_URL}/v1/chat/completions", json=ensure_language_guard(payload), headers=llama_auth_headers(), ) response.raise_for_status() return response.json()""" code = code.replace(old_execute_completion, new_execute_completion) with open("gateway.py", "w") as f: f.write(code)