Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files2196 unmodified lines219721982199220022002201220222032204220522062207220822092210220822112212221022112213221422152213221622172215221822192220222122192222222322212224222522262227137 unmodified lines23652366236723652366236723682369237023712372237323742375237623772378237923802381238223832384236823692370237123722373237423752376136 unmodified lines251325142515251625172518251925202521252225232524252525262196 unmodified lines
if model_name.startswith("gemini/"): if "gemma" not in model_name.lower(): kwargs.setdefault("reasoning_effort", "low") kwargs.setdefault("reasoning_effort", "none") else: kwargs.pop("reasoning_effort", None) if "gemini-3" in model_name.lower(): kwargs.pop("temperature", None) if isinstance(getattr(self, "kwargs", None), dict): self.kwargs.pop("temperature", None) kwargs["max_tokens"] = 512 if isinstance(getattr(self, "kwargs", None), dict): self.kwargs["max_tokens"] = 512 if model_name.startswith("openrouter/"): kwargs["max_tokens"] = 1536 kwargs["max_tokens"] = 512 if isinstance(getattr(self, "kwargs", None), dict): self.kwargs["max_tokens"] = 1536 kwargs["reasoning_effort"] = "low" self.kwargs["max_tokens"] = 512 kwargs["reasoning_effort"] = "none" if model_name.startswith("groq/"): kwargs["max_tokens"] = 1024 kwargs["max_tokens"] = 384 if isinstance(getattr(self, "kwargs", None), dict): self.kwargs["max_tokens"] = 1024 self.kwargs["max_tokens"] = 384 if "qwen3" in model_name.lower(): kwargs["reasoning_effort"] = "none" if model_name.startswith("nvidia_nim/"): kwargs["max_tokens"] = 800 kwargs["max_tokens"] = 450 if isinstance(getattr(self, "kwargs", None), dict): self.kwargs["max_tokens"] = 800 self.kwargs["max_tokens"] = 450
kwargs["num_retries"] = 0 kwargs["max_retries"] = 0137 unmodified lines model = self._build_model(self.model_id)
exact_match_rule = ( "CRITICAL OUTPUT RULES FOR EXACT MATCH EVALUATION:\n" f"- Always write valid Python code inside {code_open_tag} and {code_close_tag} tags. " "NEVER put 'Thought:' or extra markdown fences inside the code block.\n" "- NEVER import or call 'subprocess', 'os.system', 'os.popen', or shell commands, and NEVER import from 'tools'. " "Use the provided tools and allowed Python modules only.\n" "- Always call provided tools directly as Python functions inside the code block " "(e.g. web_search(query=...), search_wikipedia(query=...), fetch_url_text(url=...), " "read_local_file(file_path=...), inspect_image(image_path=..., question=...), " "inspect_youtube(url=..., question=...), transcribe_audio(audio_path=..., question=...)).\n" "- Never assign variables named 'log', 'print', or any tool name.\n" "- Keep each Python code block fast (under 15 seconds) and avoid nested network loops.\n" "- If inspect_youtube returns 'Transcript/Video Analysis Status: unavailable', do NOT call inspect_youtube again; immediately use web_search or search_wikipedia.\n" "- If the prompt includes a Task ID and mentions an image, board, diagram, or attached file, FIRST call path = download_task_file(task_id=...) and inspect it.\n" "- Never call built-in open(); use read_local_file(file_path) for text/PDF/ZIP/spreadsheet files, " "inspect_image(image_path, question) for images, and transcribe_audio(audio_path, question) for audio files (.mp3, .wav).\n" "- If web_search returns no results, use search_wikipedia(query) or fetch_url_text(url).\n" "- Return ONLY the concise exact answer value itself " "(e.g. a number, date, name, or short phrase) via final_answer().\n" "- NEVER include introductory text, explanations, markdown formatting, or the phrase 'FINAL ANSWER'.\n" "- Do not wrap the answer in a dictionary like {'answer': ...}; pass the plain answer string directly." f"Write Python inside {code_open_tag} and {code_close_tag} only. No 'Thought:' or markdown fences. " "Use only provided tools and allowed Python modules; never use subprocess/os.system/open() or import tools. " "Never name variables 'log' or 'print'. Keep code fast (<15s), no nested network loops. " "If inspect_youtube returns 'Transcript/Video Analysis Status: unavailable', switch immediately to web_search or search_wikipedia. " "If Task ID has an attachment, use download_task_file, read_local_file, inspect_image, or transcribe_audio. " "Call final_answer(value) with ONLY the plain answer value (number, date, name, short phrase, or comma-separated list) — no units, no sentences, no dict, no 'FINAL ANSWER'." )
accepted_params = set(sig.parameters) | set(inspect.signature(MultiStepAgent.__init__).parameters)136 unmodified lines ): cleaned = cleaned[2:-2].strip() if cleaned.startswith(("**", "__")) else cleaned[1:-1].strip()
num_only = re.fullmatch( r"(?:there\s+(?:are|is)\s+|a\s+total\s+of\s+|total\s*:\s*)?(\d+)(?:\s+(?:studio\s+albums?|albums?|bird\s+species|species|items?))?[.!]?", cleaned.strip(), flags=re.IGNORECASE, ) if num_only: return num_only.group(1)
if had_prefix and cleaned.endswith(".") and not re.search(r"\b(?:Mr|Mrs|Ms|Dr|St|Jr|Sr|Inc|Ltd|vs|etc)\.$", cleaned): cleaned = cleaned[:-1].strip()
app.py+25-28