Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files1440 unmodified lines1441144214431444144414451446144714481449145014511452145314541455145614572 unmodified lines1460146114621453145414631464146514661467372 unmodified lines1840184118421843184418451846184718488 unmodified lines18571858185918601861186218631864115 unmodified lines1980198119821983198419851986159 unmodified lines21462147214821332149215021512152215321542139215521562157215862 unmodified lines2221222222232208222422252226222722282229223022312232223322342235223622372238221522392240224122421440 unmodified lines g_id = str(item.get("id", "")).strip() if g_id and not any( bad in g_id.lower() for bad in ("whisper", "tts", "orpheus", "guard", "safeguard", "embed", "compound") for bad in ( "whisper", "tts", "orpheus", "guard", "safeguard", "embed", "compound", "gpt-oss", "allam", ) ): live_groq.append(f"groq/{g_id}") except Exception as groq_exc:2 unmodified lines if live_groq: live_groq.sort( key=lambda name: ( 0 if ("llama-3.3-70b" in name.lower() or "gpt-oss-120b" in name.lower()) else 1, 0 if ("70b" in name.lower() or "32b" in name.lower() or "120b" in name.lower()) else 1, 0 if "llama-3.3-70b" in name.lower() else 1, 0 if ("70b" in name.lower() or "32b" in name.lower()) else 1, name, ) )372 unmodified lines litellm.request_timeout = timeout if model_name.startswith("openrouter/"): kwargs["max_tokens"] = 4096 if "generativelanguage.googleapis.com" in str(api_base or ""): kwargs.pop("tools", None) kwargs.pop("tool_choice", None) return kwargs self._model_cls = SafeLiteLLMModel8 unmodified lines "api_base": "https://generativelanguage.googleapis.com/v1beta/openai/", "api_key": api_key, "max_tokens": 8192, "temperature": 0.1, "reasoning_effort": "low", **common, } elif model_name.startswith("huggingface/"):115 unmodified lines transcribe_audio, ], "additional_authorized_imports": [ "os", "json", "csv", "pandas",159 unmodified lines rem_now = deadline - time.monotonic() if rem_now <= 4.0: break call_timeout = max(4.0, min(16.0, rem_now - 2.0)) call_timeout = max(4.0, min(9.0, rem_now - 2.0)) self.model_id = model_name built_model = self._build_model(model_name) built_model.timeout = call_timeout built_model.deadline = deadline run_agent = self._create_code_agent(built_model) run_agent.max_steps = 4 run_agent.max_steps = 8 if rem_now > 20.0 else 5 result = run_agent.run(prompt) raw_result = "" if result is None else str(result).strip() if raw_result.lower().startswith("error in generating"):62 unmodified lines for marker in ( "timeout", "timed out", "connection error", ) ): blocked_models.add(model_name) if hasattr(self, "working_models"): try: self.working_models.remove(model_name) self.working_models.append(model_name) except ValueError: pass break if "connection error" in err_lower: if transient_retries < 1 and (deadline - time.monotonic()) > 6.0: transient_retries += 1 time.sleep(0.5) continue rate_limited_models.add(model_name) blocked_models.add(model_name) break blocked_models.add(model_name) breakapp.py+31-7