WikipediaPageLoadTool

WikipediaPageLoadTool(
    language: str = 'en',
    top_k: int = 3,
    truncate: int = 4000,
    verbose: bool = False
)

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.
Attributes:
language (str): Wikipedia language code (default: “en”).
top_k (int): Maximum number of pages to retrieve per query (default: 3).
truncate (int): Maximum number of characters of content per page (default: 4000).
verbose (bool): If True, prints debug information (default: False).
tool_name (str): Identifier used in User-Agent header.
wiki_cli (WikipediaClient): Client for interacting with the Wikipedia API.
Initializes the WikipediaPageLoadTool with configurable language, result count, and content length.

Parameters:
NameDescription
languageType: str

Default: ‘en’
top_kType: int

Default: 3
truncateType: int

Default: 4000
verboseType: bool

Default: False

Instance Attributes

description



func



function_schema


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.

name



realtime_tool_schema


Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.

tool_schema


Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.

Instance Methods

content_search(self, query: str) -> list[Document] | str

Executes a Wikipedia search and returns page content plus metadata.

Parameters:
NameDescription
queryThe search term to query Wikipedia.

Type: str
Returns:
TypeDescription
list[Document] | strUnion[list[Document], str]: - list[Document]: Documents with up to truncate characters of page text and metadata if pages are found. - str: Error message if the search fails or no pages are found. Notes: - Errors are caught internally and returned as strings. - If no matching pages have text content, returns “No good Wikipedia Search Result was found”.

register_for_execution

register_for_execution(self, agent: ConversableAgent) -> 

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.

Parameters:
NameDescription
agentThe agent to which the tool will be registered.

Type: ConversableAgent

register_for_llm

register_for_llm(self, agent: ConversableAgent) -> 

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.

Parameters:
NameDescription
agentThe agent to which the tool will be registered.

Type: ConversableAgent

register_tool

register_tool(self, agent: ConversableAgent) -> 

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.

Parameters:
NameDescription
agentThe agent to which the tool will be registered.

Type: ConversableAgent