specimba commited on
Commit
2ef5999
·
verified ·
1 Parent(s): c6efda1

Deploy PR5 public demo head 6b58763

Browse files
src/nexus_visual_weaver/exporter.py CHANGED
@@ -23,7 +23,7 @@ def export_root() -> Path:
23
  try:
24
  candidate.mkdir(parents=True, exist_ok=True)
25
  return candidate
26
- except PermissionError:
27
  continue
28
  fallback = Path("outputs/exports")
29
  fallback.mkdir(parents=True, exist_ok=True)
 
23
  try:
24
  candidate.mkdir(parents=True, exist_ok=True)
25
  return candidate
26
+ except OSError:
27
  continue
28
  fallback = Path("outputs/exports")
29
  fallback.mkdir(parents=True, exist_ok=True)
src/nexus_visual_weaver/provider_runtime.py CHANGED
@@ -44,12 +44,15 @@ def _image_data_url(path: str | None) -> str | None:
44
  if not path:
45
  return None
46
  target = Path(path)
47
- if not target.exists() or not target.is_file():
 
 
 
 
 
 
 
48
  return None
49
- suffix = target.suffix.lower()
50
- mime = "image/png" if suffix == ".png" else "image/jpeg" if suffix in {".jpg", ".jpeg"} else "image/webp"
51
- data = base64.b64encode(target.read_bytes()).decode("ascii")
52
- return f"data:{mime};base64,{data}"
53
 
54
 
55
  def _post_json(url: str, token: str, payload: dict[str, Any], timeout: float) -> dict[str, Any]:
@@ -64,7 +67,7 @@ def _post_json(url: str, token: str, payload: dict[str, Any], timeout: float) ->
64
  method="POST",
65
  )
66
  with urllib.request.urlopen(request, timeout=timeout) as response: # noqa: S310 - URL comes from Space secret/config.
67
- return json.loads(response.read().decode("utf-8"))
68
 
69
 
70
  def _extract_content(response: dict[str, Any]) -> str:
@@ -160,7 +163,7 @@ def judge_with_minicpm(
160
  evidence=evidence or {"raw_summary": content[:1200]},
161
  latency_seconds=round(time.perf_counter() - started, 2),
162
  )
163
- except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError) as exc:
164
  return ProviderJudgeResult(
165
  status="failed",
166
  provider_state="failed",
@@ -224,7 +227,7 @@ def judge_with_nemotron(
224
  evidence=evidence or {"raw_summary": content[:1200]},
225
  latency_seconds=round(time.perf_counter() - started, 2),
226
  )
227
- except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError) as exc:
228
  return ProviderJudgeResult(
229
  status="failed",
230
  provider_state="failed",
 
44
  if not path:
45
  return None
46
  target = Path(path)
47
+ try:
48
+ if not target.exists() or not target.is_file():
49
+ return None
50
+ suffix = target.suffix.lower()
51
+ mime = "image/png" if suffix == ".png" else "image/jpeg" if suffix in {".jpg", ".jpeg"} else "image/webp"
52
+ data = base64.b64encode(target.read_bytes()).decode("ascii")
53
+ return f"data:{mime};base64,{data}"
54
+ except OSError:
55
  return None
 
 
 
 
56
 
57
 
58
  def _post_json(url: str, token: str, payload: dict[str, Any], timeout: float) -> dict[str, Any]:
 
67
  method="POST",
68
  )
69
  with urllib.request.urlopen(request, timeout=timeout) as response: # noqa: S310 - URL comes from Space secret/config.
70
+ return json.loads(response.read().decode("utf-8", errors="replace"))
71
 
72
 
73
  def _extract_content(response: dict[str, Any]) -> str:
 
163
  evidence=evidence or {"raw_summary": content[:1200]},
164
  latency_seconds=round(time.perf_counter() - started, 2),
165
  )
166
+ except Exception as exc:
167
  return ProviderJudgeResult(
168
  status="failed",
169
  provider_state="failed",
 
227
  evidence=evidence or {"raw_summary": content[:1200]},
228
  latency_seconds=round(time.perf_counter() - started, 2),
229
  )
230
+ except Exception as exc:
231
  return ProviderJudgeResult(
232
  status="failed",
233
  provider_state="failed",
src/nexus_visual_weaver/render.py CHANGED
@@ -603,7 +603,7 @@ def render_provider_cards(relay_status: dict | None = None, adult_mode: bool = F
603
  <strong>{escape(provider.title())}</strong>
604
  <span>off by default / secrets required</span>
605
  <i class="nw-provider-meter" style="--health:{'74' if state == 'configured' else '18'}"></i>
606
- <div>{badge(state.upper(), "pass" if state == "configured" else "warn")}{badge("SPONSOR LANE" if provider in {"openbmb", "nvidia"} else "NOT MVP DEFAULT", "muted")}</div>
607
  </div>
608
  """
609
  )
 
603
  <strong>{escape(provider.title())}</strong>
604
  <span>off by default / secrets required</span>
605
  <i class="nw-provider-meter" style="--health:{'74' if state == 'configured' else '18'}"></i>
606
+ <div>{badge(state.upper(), "pass" if state == "configured" else "warn")}{badge("SPONSOR LANE" if provider in {"openbmb", "nvidia", "hf_nvidia"} else "NOT MVP DEFAULT", "muted")}</div>
607
  </div>
608
  """
609
  )