Spaces:
Running
Running
# tools/wikipedia_tool.py | |
import wikipedia | |
wikipedia.set_lang("en") | |
def wiki_search(query: str) -> str: | |
""" | |
Search Wikipedia and return a short summary of the topic. | |
Args: | |
query (str): The search query. | |
Returns: | |
str: Summary text or error message. | |
""" | |
try: | |
# Try to fetch a summary of the most relevant page | |
return wikipedia.summary(query, sentences=3, auto_suggest=True, redirect=True) | |
except wikipedia.DisambiguationError as e: | |
# If multiple results, return options | |
pass |