Spaces:
Running
Running
Download patch_auth_test7.py from Leon4gr45/llama-gemma: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/Leon4gr45/llama-gemma/resolve/main/patch_auth_test7.py
- Command line
-
hf download hf://spaces/Leon4gr45/llama-gemma/patch_auth_test7.py
-
curl -L -o patch_auth_test7.py https://huggingface.co/spaces/Leon4gr45/llama-gemma/resolve/main/patch_auth_test7.py
1.62 kB
| 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) | |