smolagents documentation

Built-in Tools

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v1.19.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

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:

ApiWebSearchTool

class smolagents.ApiWebSearchTool

< >

( 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

< >

( max_results = 10 rate_limit: float | None = 1.0 **kwargs )

FinalAnswerTool

class smolagents.FinalAnswerTool

< >

( *args **kwargs )

GoogleSearchTool

class smolagents.GoogleSearchTool

< >

( provider: str = 'serpapi' )

PythonInterpreterTool

class smolagents.PythonInterpreterTool

< >

( *args authorized_imports = None **kwargs )

SpeechToTextTool

class smolagents.SpeechToTextTool

< >

( *args **kwargs )

UserInputTool

class smolagents.UserInputTool

< >

( *args **kwargs )

VisitWebpageTool

class smolagents.VisitWebpageTool

< >

( max_output_length: int = 40000 )

WebSearchTool

class smolagents.WebSearchTool

< >

( max_results: int = 10 engine: str = 'duckduckgo' )

WikipediaSearchTool

class smolagents.WikipediaSearchTool

< >

( user_agent: str = 'Smolagents (myemail@example.com)' language: str = 'en' content_type: str = 'text' extract_format: str = 'WIKI' )

Parameters

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)“)

< > Update on GitHub