Spaces:
Sleeping
Sleeping
File size: 1,402 Bytes
54ebcd4 3c27da6 d50799a 3c27da6 d50799a 3c27da6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from smolagents import PythonInterpreterTool, GoogleSearchTool, VisitWebpageTool, WikipediaSearchTool, SpeechToTextTool
import wikipedia
from wikipedia import WikipediaPage
from smolagents import tool
@tool
def search_wikipedia_page(query: str) -> list[str]:
"""
Search for Wikipedia pages.
Args:
query: The query to search for.
Returns:
A list of Wikipedia pages that match the query.
"""
return wikipedia.search(query)
@tool
def get_wikipedia_page(title: str) -> WikipediaPage:
"""
Get the content of a specific Wikipedia page.
Args:
title: The title of the Wikipedia page to get.
Returns:
A WikipediaPage object. The object includes the following attributes: 'content', 'summary', 'images', 'references', 'links', 'sections'
"""
return wikipedia.page(title)
@tool
def get_wikipedia_summary(title: str) -> str:
"""
Get a summary of a Wikipedia page.
Args:
title: The title of the Wikipedia page to get.
Returns:
The plain-text summary of the Wikipedia page.
"""
return wikipedia.summary(title)
python_wikipedia_tools = [search_wikipedia_page, get_wikipedia_page, get_wikipedia_summary]
smolagents_code_tools = [PythonInterpreterTool()]
smolagents_web_tools = [GoogleSearchTool(), VisitWebpageTool(), WikipediaSearchTool()]
smolagents_speech_tools = [SpeechToTextTool()] |