用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ag2ai/resource-hub --skill integrate-web-search命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
Architecture, directory layout, communication protocol, and conventions for the full-stack multi-agent application
Step-by-step guide to add a new REST or WebSocket endpoint to the backend
基于 SOC 职业分类
| name | integrate-web-search |
| description | Register and use web search tools with AG2 agents to search the web and extract page content |
| version | 1.0.0 |
| authors | ["ag2ai"] |
| tags | ["web","search","tools","ag2"] |
The web-search tool provides two functions for AG2 agents:
web_search(query, max_results) — Search the web via DuckDuckGo (no API key needed) and return formatted results with titles, URLs, and snippets.fetch_page(url) — Fetch a web page and extract clean, readable text content using BeautifulSoup.Install the required dependencies:
pip install httpx>=0.27 beautifulsoup4>=4.12
import autogen
from tools.web_search import fetch_page, web_search
# Configure the LLM
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
assistant = autogen.AssistantAgent(
name="research_assistant",
llm_config={"config_list": config_list},
)
user_proxy = autogen.UserProxyAgent(
name="user",
human_input_mode="NEVER",
code_execution_config=False,
)
# Register both tools with the agent
assistant.register_for_llm(description="Search the web using DuckDuckGo")(web_search)
assistant.register_for_llm(description="Fetch and extract text from a URL")(fetch_page)
user_proxy.register_for_execution()(web_search)
user_proxy.register_for_execution()(fetch_page)
import autogen
from tools.web_search import fetch_page, web_search
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
assistant = autogen.AssistantAgent(
name="web_researcher",
system_message=(
"You are a helpful research assistant. Use the web_search tool to "
"find information, then use fetch_page to read the most relevant "
"results. Summarize your findings clearly."
),
llm_config={"config_list": config_list},
)
user_proxy = autogen.UserProxyAgent(
name="user",
human_input_mode="NEVER",
max_consecutive_auto_reply=10,
code_execution_config=False,
)
# Register tools
assistant.register_for_llm(description="Search the web using DuckDuckGo")(web_search)
assistant.register_for_llm(description="Fetch and extract text from a URL")(fetch_page)
user_proxy.register_for_execution()(web_search)
user_proxy.register_for_execution()(fetch_page)
# Start the conversation
user_proxy.initiate_chat(
assistant,
message="Search the web for 'AG2 multi-agent framework' and summarize what you find.",
)
import autogen
from autogen import register_function
from tools.web_search import fetch_page, web_search
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
assistant = autogen.ConversableAgent(
name="assistant",
llm_config={"config_list": config_list},
)
user_proxy = autogen.ConversableAgent(
name="user",
human_input_mode="NEVER",
code_execution_config=False,
)
register_function(
web_search,
caller=assistant,
executor=user_proxy,
name="web_search",
description="Search the web using DuckDuckGo and return results",
)
register_function(
fetch_page,
caller=assistant,
executor=user_proxy,
name="fetch_page",
description="Fetch a web page and extract its text content",
)
web_search| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | — | The search query string |
max_results | int | 5 | Maximum results to return (1–20) |
Returns a formatted string with numbered results including title, URL, and snippet.
fetch_page| Parameter | Type | Default | Description |
|---|---|---|---|
url | str | — | The URL of the page to fetch |
Returns extracted text content (up to ~8000 characters). Strips scripts, styles, navigation, headers, and footers for clean output.
fetch_page respects a 15-second timeout and follows redirects.