Sixparticle commited on
Commit ·
6000b90
1
Parent(s): 911c674
Fix Gradio launch for Spaces runtime changes
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import re
|
| 2 |
from typing import Dict, Any, List
|
| 3 |
|
|
@@ -10,6 +11,21 @@ MODEL_ID = "microsoft/unixcoder-base-nine"
|
|
| 10 |
MAX_TOKENS = 512
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def _safe_float(v: float, ndigits: int = 4) -> float:
|
| 14 |
return float(round(float(v), ndigits))
|
| 15 |
|
|
@@ -204,4 +220,4 @@ with gr.Blocks(title="UniXcoder Code Analyzer") as demo:
|
|
| 204 |
|
| 205 |
|
| 206 |
if __name__ == "__main__":
|
| 207 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import re
|
| 3 |
from typing import Dict, Any, List
|
| 4 |
|
|
|
|
| 11 |
MAX_TOKENS = 512
|
| 12 |
|
| 13 |
|
| 14 |
+
def _ensure_localhost_no_proxy() -> None:
|
| 15 |
+
local_hosts = ["localhost", "127.0.0.1", "::1"]
|
| 16 |
+
for key in ("NO_PROXY", "no_proxy"):
|
| 17 |
+
current = [item.strip() for item in os.environ.get(key, "").split(",") if item.strip()]
|
| 18 |
+
merged = current[:]
|
| 19 |
+
for host in local_hosts:
|
| 20 |
+
if host not in merged:
|
| 21 |
+
merged.append(host)
|
| 22 |
+
if merged:
|
| 23 |
+
os.environ[key] = ",".join(merged)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
_ensure_localhost_no_proxy()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
def _safe_float(v: float, ndigits: int = 4) -> float:
|
| 30 |
return float(round(float(v), ndigits))
|
| 31 |
|
|
|
|
| 220 |
|
| 221 |
|
| 222 |
if __name__ == "__main__":
|
| 223 |
+
demo.launch(server_name="0.0.0.0", ssr_mode=False)
|