Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files2196 unmodified lines2197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224137 unmodified lines23622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387136 unmodified lines2524252525262527252825292196 unmodified linesif model_name.startswith("gemini/"):if "gemma" not in model_name.lower():kwargs.setdefault("reasoning_effort", "low")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)if model_name.startswith("openrouter/"):kwargs["max_tokens"] = 1536if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 1536kwargs["reasoning_effort"] = "low"if model_name.startswith("groq/"):kwargs["max_tokens"] = 1024if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 1024if "qwen3" in model_name.lower():kwargs["reasoning_effort"] = "none"if model_name.startswith("nvidia_nim/"):kwargs["max_tokens"] = 800if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 800kwargs["num_retries"] = 0kwargs["max_retries"] = 0137 unmodified linesmodel = 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.")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()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()2196 unmodified lines2197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227137 unmodified lines236523662367236823692370237123722373237423752376136 unmodified lines251325142515251625172518251925202521252225232524252525262196 unmodified linesif model_name.startswith("gemini/"):if "gemma" not in model_name.lower():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"] = 512if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 512if model_name.startswith("openrouter/"):kwargs["max_tokens"] = 512if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 512kwargs["reasoning_effort"] = "none"if model_name.startswith("groq/"):kwargs["max_tokens"] = 384if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 384if "qwen3" in model_name.lower():kwargs["reasoning_effort"] = "none"if model_name.startswith("nvidia_nim/"):kwargs["max_tokens"] = 450if isinstance(getattr(self, "kwargs", None), dict):self.kwargs["max_tokens"] = 450kwargs["num_retries"] = 0kwargs["max_retries"] = 0137 unmodified linesmodel = self._build_model(self.model_id)exact_match_rule = (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