Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions inference_worker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Settings:
# use the per-backend "modalities"/"vision" keys instead.
MODALITIES = os.getenv("GRID_MODALITIES", "").strip()
VISION = os.getenv("GRID_VISION", "").lower() in ("1", "true", "yes", "on")

# Streaming (WebSocket /v1) is the only live mode — the legacy /v2 poll
# queue is retired. Defaults ON; set "false" only knowingly (the worker
# refuses rather than poll the dead /v2 endpoint).
Expand Down Expand Up @@ -180,15 +180,11 @@ def _parse_modalities(s: dict) -> list[str]:
`"modalities": ["text","image"]` or the shorthand `"vision": true`. Text is
always included. (A validator can later VERIFY this claim and revoke a lie.)
"""
mods = s.get("modalities")
if isinstance(mods, list) and mods:
out = [m for m in mods if m in ("text", "image", "video")]
elif s.get("vision"):
out = ["text", "image"]
else:
out = ["text"]
out = s.get("modalities")
if "text" not in out:
out = ["text"] + out
out.append("text")
if s.get("vision"):
out.append("image")
return out


Expand Down Expand Up @@ -239,6 +235,6 @@ def load_backends() -> list[Backend]:
schedule=Settings.GRID_SCHEDULE,
# Honor GRID_MODALITIES / GRID_VISION as an explicit override; otherwise
# default to text-only and let connect() auto-detect.
modalities_declared=bool(_env_mods or Settings.VISION or (os.getenv("GRID_VISION", "").lower() not in ("1", "true", "yes", "on"))),
modalities=_parse_modalities({"modalities": _env_mods, "vision": Settings.VISION}),
modalities_declared=bool(_env_mods or Settings.VISION),
)]
4 changes: 2 additions & 2 deletions inference_worker/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def __init__(self, name: str | None = None, spec=None):
# model image-capable and the chat UI enables image upload. Either the
# operator declared them, or we auto-detect at connect() (see
# _detect_vision). Default text-only until then.
self.modalities: list[str] = list(getattr(spec, "modalities", None) or ["text"])
self.modalities_declared: bool = bool(getattr(spec, "modalities_declared", False))
self.modalities: list[str] = spec.modalities
self.modalities_declared: bool = spec.modalities_declared
self._signer = get_signer()
self.signer_address = self._signer.address if self._signer else ""
self._reconnect_delay = 1
Expand Down
Loading