WikipediaQueryRunTool
autogen.tools.experimental.wikipedia.wikipedia.WikipediaQueryRunTool #
Bases: Tool
A tool for executing Wikipedia queries and returning summarized page results.
This tool requires the optional wikipediaapi
package to be installed. Provides controlled access to Wikipedia content with configurable result limits.
ATTRIBUTE | DESCRIPTION |
---|---|
language | Wikipedia language edition to use (e.g., 'en', 'es') TYPE: |
top_k | Maximum number of page summaries to return (capped at MAX_PAGE_RETRIEVE) TYPE: |
verbose | Flag to enable debug logging TYPE: |
wiki_cli | Internal client for Wikipedia API interactions TYPE: |
Initialize the Wikipedia query tool.
PARAMETER | DESCRIPTION |
---|---|
language | Language code for Wikipedia edition. Defaults to 'en'. TYPE: |
top_k | Maximum number of page summaries to return. Will be capped at MAX_PAGE_RETRIEVE constant. Defaults to 3. TYPE: |
verbose | Enable operational logging. Defaults to 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.
query_run #
Execute a Wikipedia search and return processed page summaries.
Args:
query (str): Search term(s) to look up in Wikipedia. Will be truncated to
MAX_QUERY_LENGTH characters if too long.
Returns:
Union[list[str], str]:
- List of formatted page summaries ("Page: <title>
Summary:
Note:
Automatically handles API exceptions and returns error strings for robust operation
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: |