Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files2506 unmodified lines25072508250925102511251224 unmodified lines25372538253925402541254225432544177 unmodified lines27222723272427252726272727282729273027312732273327342735273627372506 unmodified linesif not cleaned or cleaned.startswith("AGENT ERROR:"):return cleanedjson_block = re.search(r'\{\s*["\']tool["\']\s*:\s*["\'][^"\']+["\']\s*,\s*["\']arguments["\']\s*:\s*\{.*?\}\s*\}',cleaned,24 unmodified lines):return ""if len(cleaned) > 160:return ""return cleaneddef __call__(self, question: str, task_id: str = "", file_name: str = "") -> str:177 unmodified lineslast_step = getattr(getattr(run_agent, "memory", None), "steps", None)if last_step:for st in reversed(last_step):obs_txt = getattr(st, "action_output", None)if obs_txt is not None and str(obs_txt).strip():fallback_clean = self._clean_exact_match_answer(str(obs_txt))if (fallback_cleanand not fallback_clean.startswith("AGENT ERROR:")and len(fallback_clean) <= 200and "\n" not in fallback_clean):return fallback_cleanblocked_models.add(model_name)breakexcept Exception as exc:2506 unmodified lines250725082509251025112512251325142515251624 unmodified lines254125422543254425452546177 unmodified lines27242725272627272728272927302731273227332734273527362737273827392740274127422506 unmodified linesif not cleaned or cleaned.startswith("AGENT ERROR:"):return cleanedcode_match = re.search(r"<code[^>]*>(.*?)</code>", cleaned, flags=re.DOTALL | re.IGNORECASE)if code_match:cleaned = code_match.group(1).strip()json_block = re.search(r'\{\s*["\']tool["\']\s*:\s*["\'][^"\']+["\']\s*,\s*["\']arguments["\']\s*:\s*\{.*?\}\s*\}',cleaned,24 unmodified lines):return ""return cleaneddef __call__(self, question: str, task_id: str = "", file_name: str = "") -> str:177 unmodified lineslast_step = getattr(getattr(run_agent, "memory", None), "steps", None)if last_step:for st in reversed(last_step):for attr in ("action_output", "model_output", "observations"):cand_val = getattr(st, attr, None)if cand_val is None:continuefallback_clean = self._clean_exact_match_answer(str(cand_val))if (fallback_cleanand not fallback_clean.startswith("AGENT ERROR:")and "\n" not in fallback_cleanand len(fallback_clean) <= 220):return fallback_cleanreturn "AGENT ERROR: All candidate models failed."blocked_models.add(model_name)breakexcept Exception as exc:
app.py+11-6