Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files2025 unmodified lines2026202720282029202920302031203220332034203520362031203220372038203920402041179 unmodified lines222122222223221822242225222622272228222922302231222122322233223422352236223722272238223922402241224213 unmodified lines2256225722582247225922602261226222632264226522662250226722682269227022712272225622732274227522762277723 unmodified lines300130023003298629872988298929902991299229932994299529962997299829993000300130023004300530062025 unmodified lines plain, ) if fa_match and fa_match[-1].strip(): return f"final_answer({json.dumps(fa_match[-1].strip(), ensure_ascii=False)})" safe_ans = ( json.dumps(fa_match[-1].strip(), ensure_ascii=False) .replace("<", "\\u003c") .replace(">", "\\u003e") .replace("```", "\\x60\\x60\\x60") ) return f"final_answer({safe_ans})" return ( f'print("Invalid non-code output. Write valid Python code inside ' f'{open_t}...{close_t} calling a tool or final_answer(...).")' 'print("Invalid non-code output. Write valid Python code inside ' 'the code block calling a tool or final_answer(...).")' )
converted_top = _convert_xml_tool_calls(text)179 unmodified lines reasoning_str, ) if fa_matches and fa_matches[-1].strip(): ans_val = fa_matches[-1].strip() ans_val = ( json.dumps(fa_matches[-1].strip(), ensure_ascii=False) .replace("<", "\\u003c") .replace(">", "\\u003e") .replace("```", "\\x60\\x60\\x60") ) content_str = ( f"{cls.open_tag}\n" f"final_answer({json.dumps(ans_val, ensure_ascii=False)})\n" f"final_answer({ans_val})\n" f"{cls.close_tag}" ) else: content_str = ( f"{cls.open_tag}\n" f'print("No Python code block produced. Write valid Python code inside {cls.open_tag}...{cls.close_tag} to call a tool or final_answer(...).")\n' 'print("No Python code block produced. Write valid Python code inside ' 'the code block to call a tool or final_answer(...).")\n' f"{cls.close_tag}" )
13 unmodified lines cleaned, ) if fa_direct and fa_direct[-1].strip(): ans_val = fa_direct[-1].strip() ans_val = ( json.dumps(fa_direct[-1].strip(), ensure_ascii=False) .replace("<", "\\u003c") .replace(">", "\\u003e") .replace("```", "\\x60\\x60\\x60") ) cleaned = ( f"{cls.open_tag}\n" f"final_answer({json.dumps(ans_val, ensure_ascii=False)})\n" f"final_answer({ans_val})\n" f"{cls.close_tag}" ) else: cleaned = ( f"{cls.open_tag}\n" f'print("Invalid non-code output. Write valid Python code inside {cls.open_tag}...{cls.close_tag} to call a tool or final_answer(...).")\n' 'print("Invalid non-code output. Write valid Python code inside ' 'the code block to call a tool or final_answer(...).")\n' f"{cls.close_tag}" )
723 unmodified lines return cleaned blocked_models.add(model_name) break last_step = getattr(getattr(run_agent, "memory", None), "steps", None) if last_step: for st in reversed(last_step): cand_val = getattr(st, "action_output", None) if cand_val is None: continue fallback_clean = self._clean_exact_match_answer(str(cand_val)) if ( fallback_clean and not fallback_clean.startswith( ("AGENT ERROR:", "Error ", "No attachment", "No web results", "No Wikipedia") ) and len(fallback_clean) <= 600 ): return " ".join(fallback_clean.splitlines()).strip() blocked_models.add(model_name) continue except Exception as exc: llm_err = getattr(built_model, "_last_llm_error", None) if llm_err is not None and llm_err is not exc:app.py+27-26