Spaces:
Sleeping
Sleeping
Update app.py
Browse files124 unmodified lines12512612712812913013113213313431 unmodified lines166167168165166169170171172169173174175176177178179180181182183184124 unmodified lines def _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 None
def _fetch_yt_html(self, url: str) -> str | None: try: r = requests.get(self._yt_mobile_url(url),31 unmodified lines return str(n) # EXACT MATCH wants bare number # Deterministic LLM fallback constrained to description only yt_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)." "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}") return format_final_answer(question, raw) num = _extract_bare_number(raw)
if num is None: # second attempt: ultra-strict raw2 = 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 math calc = self._maybe_calc(question)app.py+14-3