Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files752 unmodified lines753754755756757758759760761762763764765766767768151 unmodified lines9209219229139149159169239249259269279289291267 unmodified lines219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235752 unmodified lines text = body_text[:4200] + "\n...\n" + body_text[-4200:] else: text = body_text display_title = resolved_title or title header_lines = [f"Wikipedia: {display_title}"] if rev_id: header_lines[0] += f" (2022 revision {rev_id})" if other_titles: header_lines.append(f"Other search matches: {', '.join(other_titles[:4])}") body_out = text if text else "No readable article text found." result_str = "\n".join(header_lines) + "\n\n" + body_out wiki_cache[cache_key] = result_str return result_str except Exception as e: return f"Wikipedia error for '{query}': {str(e)}"
151 unmodified lines "openrouter/google/gemma-4-31b-it:free", "openrouter/google/gemma-3-27b-it:free", ]) if self.provider_keys.get("nvidia_nim"): candidate_models.extend([ "nvidia_nim/nvidia/nemotron-3-ultra-550b-a55b", "nvidia_nim/moonshotai/kimi-k2-instruct", if self.provider_keys.get("nvidia_nim") or self.provider_key_pools.get("nvidia_nim"): vision_candidates.extend([ "nvidia_nim/meta/llama-3.2-90b-vision-instruct", "nvidia_nim/nvidia/nemotron-nano-12b-v2-vl", "nvidia_nim/moonshotai/kimi-k2.5", ])
1267 unmodified lines 'the code block calling a tool or final_answer(...).")' )
tag_matches = re.findall( rf"{re.escape(open_t)}(.*?){re.escape(close_t)}", text, flags=re.DOTALL, ) if not tag_matches and open_t != "```py": tag_matches = re.findall( r"```(?:py|python)?\s*\n(.*?)```", text, flags=re.DOTALL | re.IGNORECASE, )
if tag_matches: raw_block = tag_matches[-1].strip() converted = _convert_xml_tool_calls(raw_block) inner = converted if converted is not None else raw_block inner = _guard_unbound_lines(inner) inner = _ensure_observable_output(inner) if "Invalid non-code output." not in inner: inner = _ensure_final_answer_call(inner) try: tree = ast.parse(inner) if not tree.body: inner = _extract_valid_python(raw_block) except SyntaxError: inner = _extract_valid_python(raw_block) return f"{open_t}\n{inner}\n{close_t}"
extracted = _extract_valid_python(text) if "Invalid non-code output." not in extracted: extracted = _ensure_final_answer_call(extracted) return f"{open_t}\n{extracted}\n{close_t}"
@classmethod def _validate_message(cls, msg): import jsonapp.py+47-4