smolagents documentation
Built-in Tools
Built-in Tools
Ready-to-use tool implementations provided by the smolagents
library.
These built-in tools are concrete implementations of the Tool base class, each designed for specific tasks such as web searching, Python code execution, webpage retrieval, and user interaction. You can use these tools directly in your agents without having to implement the underlying functionality yourself. Each tool handles a particular capability and follows a consistent interface, making it easy to compose them into powerful agent workflows.
The built-in tools can be categorized by their primary functions:
- Information Retrieval: Search and retrieve information from the web and specific knowledge sources.
- Web Interaction: Fetch and process content from specific web pages.
- Code Execution: Dynamic execution of Python code for computational tasks.
- User Interaction: Enable Human-in-the-Loop collaboration between agents and users.
- UserInputTool: Collect input from users.
- Speech Processing: Convert audio to textual data.
- Workflow Control: Manage and direct the flow of agent operations.
- FinalAnswerTool: Conclude agent workflow with final response.
ApiWebSearchTool
class smolagents.ApiWebSearchTool
< source >( endpoint: str = '' api_key: str = '' api_key_name: str = '' headers: dict = None params: dict = None rate_limit: float | None = 1.0 )
DuckDuckGoSearchTool
class smolagents.DuckDuckGoSearchTool
< source >( max_results = 10 rate_limit: float | None = 1.0 **kwargs )
FinalAnswerTool
GoogleSearchTool
PythonInterpreterTool
SpeechToTextTool
UserInputTool
VisitWebpageTool
WebSearchTool
WikipediaSearchTool
class smolagents.WikipediaSearchTool
< source >( user_agent: str = 'Smolagents (myemail@example.com)' language: str = 'en' content_type: str = 'text' extract_format: str = 'WIKI' )
Parameters
- user_agent (str) — A custom user-agent string to identify the project. This is required as per Wikipedia API policies, read more here: http://github.com/martin-majlis/Wikipedia-API/blob/master/README.rst
- language (str) — The language in which to retrieve Wikipedia articles. http://meta.wikimedia.org/wiki/List_of_Wikipedias
- content_type (str) — Defines the content to fetch. Can be “summary” for a short summary or “text” for the full article.
- extract_format (str) — Defines the output format. Can be
"WIKI"
or"HTML"
.
WikipediaSearchTool searches Wikipedia and returns a summary or full text of the given topic, along with the page URL.
Example:
from smolagents import CodeAgent, InferenceClientModel, WikipediaSearchTool agent = CodeAgent( tools=[ WikipediaSearchTool( user_agent=“MyResearchBot (myemail@example.com)”, language=“en”, content_type=“summary”, # or “text” extract_format=“WIKI”, ) ], model=InferenceClientModel(), ) agent.run(“Python_(programming_language)“)