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:
( endpoint: str = '' api_key: str = '' api_key_name: str = '' headers: dict = None params: dict = None rate_limit: float | None = 1.0 )
Parameters
str) — API endpoint URL. Defaults to Brave Search API. str) — API key for authentication. str) — Environment variable name containing the API key. Defaults to “BRAVE_API_KEY”. dict, optional) — Headers for API requests. dict, optional) — Parameters for API requests. float, default 1.0) — Maximum queries per second. Set to None to disable rate limiting. Web search tool that performs API-based searches. By default, it uses the Brave Search API.
This tool implements a rate limiting mechanism to ensure compliance with API usage policies. By default, it limits requests to 1 query per second.
( max_results: int = 10 rate_limit: float | None = 1.0 **kwargs )
Web search tool that performs searches using the DuckDuckGo search engine.
( user_agent: str = 'Smolagents (myemail@example.com)' language: str = 'en' content_type: str = 'text' extract_format: str = 'WIKI' )
Parameters
str) — Custom user-agent string to identify the project. This is required as per Wikipedia API policies.
See: https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy str, default "en") — Language in which to retrieve Wikipedia article.
See: http://meta.wikimedia.org/wiki/List_of_Wikipedias Literal["summary", "text"], default "text") — Type of content to fetch. Can be “summary” for a short summary or “text” for the full article. Literal["HTML", "WIKI"], default "WIKI") — Extraction format of the output. Can be "WIKI" or "HTML". Search Wikipedia and return the summary or full text of the requested article, 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)")