Spaces:
Sleeping
Sleeping
Upload research_fallback.py
Browse files5 unmodified lines6789101113 unmodified lines2526272829305 unmodified linesfrom __future__ import annotationsimport osimport threadingimport time13 unmodified linesreturn any(signal in text for signal in signals)def llama_circuit_open() -> bool:with _LOCK:return time.monotonic() < _UNAVAILABLE_UNTIL5 unmodified lines67891011121313 unmodified lines27282930313233343536373839404142434445464748495 unmodified linesfrom __future__ import annotationsimport osimport jsonimport loggingimport threadingimport time13 unmodified linesreturn any(signal in text for signal in signals)def is_gradio_transport_json_error(exc: Exception) -> bool:"""Classify only malformed JSON returned while contacting the Llama Space.Never treat JSON parsing failures in publication retrieval or our ownapplication data as an infrastructure outage."""if not isinstance(exc, json.JSONDecodeError):return Falsetb = exc.__traceback__while tb is not None:module = str(tb.tb_frame.f_globals.get("__name__", ""))if module == "gradio_client" or module.startswith("gradio_client."):return Truetb = tb.tb_nextreturn Falsedef llama_circuit_open() -> bool:with _LOCK:return time.monotonic() < _UNAVAILABLE_UNTIL
backend/research_fallback.py+19