Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files2105 unmodified lines2106210721082109210921102111211278 unmodified lines2191219221932194219421952196219726 unmodified lines2224222522262227222822282229223022312231223222332234223526 unmodified lines2262226322642265226622672268226922702271227022722273227422752276227222732274227522762277227822792280228131 unmodified lines23132314231523142316231723182105 unmodified lines if isinstance(getattr(self, "kwargs", None), dict): self.kwargs["api_key"] = key
default_cap = 18.0 default_cap = 45.0 timeout = min(float(getattr(self, "timeout", None) or default_cap), default_cap) task_deadline = getattr(self, "deadline", None) if task_deadline is not None:78 unmodified lines } return self._model_cls(**kwargs)
def _probe_candidate(model_name: str) -> tuple[str, str, str]: ef _probe_candidate(model_name: str) -> tuple[str, str, str]: import time
api_key = self._get_api_key(model_name)26 unmodified lines text = f"{type(exc).__name__}: {exc}" low = text.lower() short = " ".join(text.split())[:220] is_hard_quota = "exceeded your current quota" in low or "billing" in low busy_markers = ( "429", "rate limit", "quota", "resource_exhausted", "429", "rate limit", "resource_exhausted", "timeout", "timed out", "connection", "503", "overloaded", "unavailable", ) if any(m in low for m in busy_markers): if not is_hard_quota and any(m in low for m in busy_markers): return (model_name, "busy", short) return (model_name, "dead", short)
26 unmodified lines self.provider_key_pools[prov] = [] self._sync_provider_env(prov, "")
dead_models = {m for m, st in probe_status.items() if st == "dead"} ok_models = [m for m in self.working_models if probe_status.get(m) == "ok"] untested_non_or = [ m for m in self.working_models if m not in probe_status and not m.startswith("openrouter/") ] busy_models = [m for m in self.working_models if probe_status.get(m) == "busy"] openrouter_models = [m for m in self.working_models if m.startswith("openrouter/")] openrouter_models = [ m for m in self.working_models if m.startswith("openrouter/") and m not in dead_models ]
# Jeśli działają szybkie modele Groq/Gemini, nie wrzucaj wolnych modeli openrouter:free przed busy_models if ok_models: reordered = (ok_models + untested_non_or + busy_models + openrouter_models)[:4] else: reordered = (untested_non_or + openrouter_models + busy_models)[:4] # OpenRouter wchodzi przed chwilowo przeciążone (busy) modele, a martwe (dead) są całkowicie odrzucane reordered = (ok_models + untested_non_or + openrouter_models + busy_models)[:4] if reordered: self.working_models = reordered
31 unmodified lines "tools": [ web_search, search_wikipedia, ask_web, fetch_url_text, download_task_file, read_local_file,app.py+12-11