WebSearchPreviewTool - AG2
WebSearchPreviewTool
autogen.tools.experimental.WebSearchPreviewTool
WebSearchPreviewTool(*, llm_config, search_context_size='medium', user_location=None, instructions=None, text_format=None)
Bases: Tool
WebSearchPreviewTool is a tool that uses OpenAI's web_search_preview tool to perform a search.
Initialize the WebSearchPreviewTool.
| PARAMETER | DESCRIPTION |
|---|---|
llm_config |
The LLM configuration to use. This should be a dictionary containing the model name and other parameters. TYPE:`LLMConfig |
search_context_size |
The size of the search context. One of low, medium, or high. medium is the default.TYPE: Literal['low', 'medium', 'high']DEFAULT:'medium' |
user_location |
The location of the user. This should be a dictionary containing the city, country, region, and timezone. TYPE:`dict[str, str] |
instructions |
Inserts a system (or developer) message as the first item in the model's context. TYPE:`str |
text_format |
The format of the text to be returned. This should be a subclass of BaseModel. The default is None, which means the text will be returned as a string.TYPE:`type[BaseModel] |
Source code in autogen/tools/experimental/web_search_preview/web_search_preview.py
name property
name
description property
description
func property
func
tool_schema property
tool_schema
Get the schema for the tool.
function_schema property
function_schema
Get the schema for the function.
realtime_tool_schema property
realtime_tool_schema
Get the schema for the tool.
web_search_tool_param instance-attribute
web_search_tool_param = WebSearchToolParam(type='web_search_preview', search_context_size=search_context_size, user_location=UserLocation(**user_location) if user_location else None)
instructions instance-attribute
instructions = instructions
text_format instance-attribute
text_format = text_format
model instance-attribute
model = None
api_key instance-attribute
api_key = None
register_for_llm
register_for_llm(agent)
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: ConversableAgent |
Source code in autogen/tools/tool.py
register_for_execution
register_for_execution(agent)
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: ConversableAgent |
Source code in autogen/tools/tool.py
register_tool
register_tool(agent)
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: ConversableAgent |
Source code in autogen/tools/tool.py