Download SCIBOT from DGRDN/SCIIBOTT: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/DGRDN/SCIIBOTT/resolve/main/SCIBOT
- Command line
-
hf download hf://spaces/DGRDN/SCIIBOTT/SCIBOT
-
curl -L -o SCIBOT https://huggingface.co/spaces/DGRDN/SCIIBOTT/resolve/main/SCIBOT
1.03 kB
| !pip install wikipedia | |
| import wikipedia | |
| wikipedia.set_lang("en") | |
| def science_bot(user_input): | |
| topic = user_input.lower().strip() | |
| for prefix in ["what is", "define", "explain", "tell me about"]: | |
| if topic.startswith(prefix): | |
| topic = topic.replace(prefix, "").strip() | |
| try: | |
| return wikipedia.summary(topic, sentences=3) | |
| except wikipedia.exceptions.DisambiguationError as e: | |
| return f"⚠️ That topic is ambiguous. Try one of these:\n{', '.join(e.options[:5])}" | |
| except wikipedia.exceptions.PageError: | |
| try: | |
| return wikipedia.summary(topic.title(), sentences=3) | |
| except: | |
| try: | |
| return wikipedia.summary(f"{topic} (physics)", sentences=3) | |
| except: | |
| return f"❌ I couldn't find anything on '{topic}'. Try a different science topic." | |
| while True: | |
| user_input = input("Ask a science question (or type 'exit'): ") | |
| if user_input.lower() == "exit": | |
| break | |
| print(science_bot(user_input)) |