Spaces:
Sleeping
Sleeping
Update app.py
Browse files553 unmodified lines554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585553 unmodified linesreturn bestreturn Nonedef _http_get(self, url: str) -> str | None:try:r = requests.get(url, headers={"User-Agent":"Mozilla/5.0","Accept-Language":"en"}, timeout=20)r.raise_for_status()return r.textexcept Exception:return Nonedef _equine_vet_surname_libretexts(self) -> str | None:# Try likely mirrors of 1.E Exercises compiled from CK-12/Agnew materialsurls = ["https://chem.libretexts.org/Ancillary_Materials/Laboratory_Experiments/Wet_Lab_Experiments/General_Chemistry_Labs/Survey_of_Chemistry_I_Labs/01%3A_Chemistry_in_Our_Lives/1.0E%3A_Exercises","https://chem.libretexts.org/Courses/Chabot_College/Introduction_to_General_Organic_and_Biochemistry/01%3A_Chemistry_in_our_Lives/1.E%3A_Exercises",]for u in urls:html = self._http_get(u)if not html:continue# direct matchif re.search(r"\bLouvrier\b", html):return "Louvrier"# fallback: pattern “horse doctor … named X” / “equine veterinarian … named X”m = re.search(r"(?:horse doctor|equine veterinarian)[^.<]{0,200}?\bnamed\s+([A-Z][a-z]+)\b", html, re.I|re.S)if m:return m.group(1)return None# change the template call to pass task_id as second argdef __call__(self, question: str, task_id: str | None = None) -> str:553 unmodified lines554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585553 unmodified linesreturn bestreturn Nonedef _http_get(self, url: str) -> str | None:try:r = requests.get(url, headers={"User-Agent":"Mozilla/5.0","Accept-Language":"en"}, timeout=20)r.raise_for_status()return r.textexcept Exception:return Nonedef _equine_vet_surname_libretexts(self) -> str | None:# Try likely mirrors of 1.E Exercises compiled from CK-12/Agnew materialsurls = ["https://chem.libretexts.org/Ancillary_Materials/Laboratory_Experiments/Wet_Lab_Experiments/General_Chemistry_Labs/Survey_of_Chemistry_I_Labs/01%3A_Chemistry_in_Our_Lives/1.0E%3A_Exercises","https://chem.libretexts.org/Courses/Chabot_College/Introduction_to_General_Organic_and_Biochemistry/01%3A_Chemistry_in_our_Lives/1.E%3A_Exercises",]for u in urls:html = self._http_get(u)if not html:continue# direct matchif re.search(r"\bLouvrier\b", html):return "Louvrier"# fallback: pattern “horse doctor … named X” / “equine veterinarian … named X”m = re.search(r"(?:horse doctor|equine veterinarian)[^.<]{0,200}?\bnamed\s+([A-Z][a-z]+)\b", html, re.I|re.S)if m:return m.group(1)return None# change the template call to pass task_id as second argdef __call__(self, question: str, task_id: str | None = None) -> str:
app.py+25-25