Spaces:
Sleeping
Sleeping
Update app.py
Browse files124 unmodified lines12512612712812913031 unmodified lines162163164165166167168169170171172173124 unmodified linesdef _yt_mobile_url(self, url: str) -> str:return re.sub(r"^https://www\.youtube\.com", "https://m.youtube.com", url)def _fetch_yt_html(self, url: str) -> str | None:try:r = requests.get(self._yt_mobile_url(url),31 unmodified linesreturn str(n) # EXACT MATCH wants bare number# Deterministic LLM fallback constrained to description onlyyt_sys = ("Answer with ONLY the final number. Use only the official video description text. ""Count distinct bird species explicitly mentioned (e.g., Emperor penguin, Adélie penguin, Giant petrel).")raw = self._llm(f"{yt_sys}\n\nQuestion: {question}")return format_final_answer(question, raw)# 1) quick mathcalc = self._maybe_calc(question)124 unmodified lines12512612712812913013113213313431 unmodified lines166167168169170171172173174175176177178179180181182183184124 unmodified linesdef _yt_mobile_url(self, url: str) -> str:return re.sub(r"^https://www\.youtube\.com", "https://m.youtube.com", url)def _extract_video_id(url: str) -> str | None:m = re.search(r"[?&]v=([\w-]{6,})", url)return m.group(1) if m else Nonedef _fetch_yt_html(self, url: str) -> str | None:try:r = requests.get(self._yt_mobile_url(url),31 unmodified linesreturn str(n) # EXACT MATCH wants bare number# Deterministic LLM fallback constrained to description onlyyt_sys = ("Return ONLY the number (digits only, no words, no punctuation). ""Count the distinct bird species explicitly mentioned in the official video description (e.g., Emperor penguin, Adélie penguin, Giant petrel).")raw = self._llm(f"{yt_sys}\n\nQuestion: {question}")num = _extract_bare_number(raw)if num is None:# second attempt: ultra-strictraw2 = self._llm("Output only a single integer with no other text.\n" + question)num = _extract_bare_number(raw2)if num is not None:return num# 1) quick mathcalc = self._maybe_calc(question)
app.py+14-3