WikipediaPageLoadTool
autogen.tools.experimental.wikipedia.wikipedia.WikipediaPageLoadTool #
Bases: Tool
A tool to load up to N characters of Wikipedia page content along with metadata.
This tool uses a language-specific Wikipedia client to search for relevant articles and returns a list of Document objects containing truncated page content and metadata (source URL, title, page ID, timestamp, word count, and size). Ideal for agents requiring structured Wikipedia data for research, summarization, or contextual enrichment.
ATTRIBUTE | DESCRIPTION |
---|---|
language | Wikipedia language code (default: "en"). TYPE: |
top_k | Maximum number of pages to retrieve per query (default: 3). TYPE: |
truncate | Maximum number of characters of content per page (default: 4000). TYPE: |
verbose | If True, prints debug information (default: False). TYPE: |
tool_name | Identifier used in User-Agent header. TYPE: |
wiki_cli | Client for interacting with the Wikipedia API. TYPE: |
Initializes the WikipediaPageLoadTool with configurable language, result count, and content length.
PARAMETER | DESCRIPTION |
---|---|
language | The language code for the Wikipedia edition (default is "en"). TYPE: |
top_k | The maximum number of pages to retrieve per query (default is 3; capped at MAX_PAGE_RETRIEVE). TYPE: |
truncate | The maximum number of characters to extract from each page (default is 4000; capped at MAX_ARTICLE_LENGTH). TYPE: |
verbose | If True, enables verbose/debug logging (default is False). TYPE: |
Source code in autogen/tools/experimental/wikipedia/wikipedia.py
tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
function_schema property
#
Get the schema for the function.
This is the old way of handling function calls with OpenAI and compatible frameworks. It is provided for backward compatibility.
realtime_tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
content_search #
Executes a Wikipedia search and returns page content plus metadata.
PARAMETER | DESCRIPTION |
---|---|
query | The search term to query Wikipedia. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Union[list[Document], str] | Union[list[Document], str]: - list[Document]: Documents with up to |
Notes
- Errors are caught internally and returned as strings.
- If no matching pages have text content, returns "No good Wikipedia Search Result was found".
Source code in autogen/tools/experimental/wikipedia/wikipedia.py
register_for_llm #
Registers the tool for use with a ConversableAgent's language model (LLM).
This method registers the tool so that it can be invoked by the agent during interactions with the language model.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_for_execution #
Registers the tool for direct execution by a ConversableAgent.
This method registers the tool so that it can be executed by the agent, typically outside of the context of an LLM interaction.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_tool #
Register a tool to be both proposed and executed by an agent.
Equivalent to calling both register_for_llm
and register_for_execution
with the same agent.
Note: This will not make the agent recommend and execute the call in the one step. If the agent recommends the tool, it will need to be the next agent to speak in order to execute the tool.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |