Openclaw Cn 百度搜索

v1.0.0

通过百度 AI 搜索 API 进行网页搜索,获取实时信息和搜索结果。

0· 142·2 current·2 all-time
byiDOTOOLS@yky3489
MIT-0
Download zip
LicenseMIT-0 · Free to use, modify, and redistribute. No attribution required.
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description describe a Baidu web-search proxy and the package contains a FastAPI app that calls Baidu's qianfan web_search endpoint. The single required secret (BAIDU_API_KEY) is appropriate and declared as the primary credential. Requiring a 'uv' CLI is plausible given the SKILL.md uses that tool to manage venv and run uvicorn.
Instruction Scope
SKILL.md instructs creating a .env with BAIDU_API_KEY, building a venv, and running a local FastAPI server; the runtime steps and example curl calls match the service purpose. Minor notes: the validation error handler logs request bodies/errors (may record user queries to logs), and several example commands embed an absolute workspace path (/home/node/...), which is environment-specific but not harmful.
Install Mechanism
Install uses a Homebrew formula named 'uv' to provide the 'uv' binary. This is unusual for a Python FastAPI app (users often use pip/venv directly), but not inherently malicious. Users should verify the 'uv' formula source before installing (especially on non-macOS systems) to ensure it is the expected tool.
Credentials
Only BAIDU_API_KEY is required and used. No other credentials, system config paths, or unrelated environment variables are requested. The code reads OPENAPI_SERVER_URL for FastAPI server metadata but does not treat it as a secret.
Persistence & Privilege
The skill does not request always: true, does not modify other skills or system settings, and only runs a local server when the user elects to start it. Autonomous invocation defaults are unchanged (normal).
Assessment
This skill appears to do what it claims, but take these precautions before installing: (1) Only provide a Baidu API key you trust—treat BAIDU_API_KEY like any secret. (2) Verify the 'uv' Homebrew formula/source before installing (it is an unusual install path for a Python service). (3) When running the service, bind it to localhost and avoid exposing it publicly; example defaults use 127.0.0.1 but double-check any deployment. (4) Logs may include request bodies (queries/errors), so avoid sending sensitive secrets or PII in search queries or secure your logs. (5) If you plan to deploy to a server, store the API key in a secure secret store and restrict network access to Baidu endpoints only.

Like a lobster shell, security has layers — review code before you run it.

latestvk97cc28jwxra1t583t93vj1yed830dgx

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

Runtime requirements

🔍 Clawdis
Binsuv
EnvBAIDU_API_KEY
Primary envBAIDU_API_KEY

Install

Install uv via Homebrew
Bins: uv
brew install uv

SKILL.md

🔍 百度搜索

Search the web with Baidu AI

通过百度 AI 搜索 API 进行网页搜索,获取中文互联网的实时信息。

Setup

cd {baseDir}
echo "BAIDU_API_KEY=your-api-key" > .env
uv venv && uv pip install -e ".[dev]"
uv run --env-file .env uvicorn baidu_search.main:app --host 127.0.0.1 --port 8001

需要在 .env 或环境变量中设置 BAIDU_API_KEY

获取 API Key

  1. 访问 百度智能云控制台
  2. 创建应用获取 API Key

启动服务 (推荐)

# 方法1: 直接使用 python -m uvicorn (推荐)
cd /home/node/.openclaw/workspace/skills/openclaw-cn-百度搜索
PYTHONPATH=src .venv/bin/python -m uvicorn baidu_search.main:app --host 127.0.0.1 --port 8001

# 后台运行
PYTHONPATH=src .venv/bin/python -m uvicorn baidu_search.main:app --host 127.0.0.1 --port 8001 &

快速启动 (已验证)

cd /home/node/.openclaw/workspace/skills/openclaw-cn-百度搜索
PYTHONPATH=src .venv/bin/python -m uvicorn baidu_search.main:app --host 127.0.0.1 --port 8001

⚠️ 注意:不要使用 source .venv/bin/activate (sh 环境不支持),直接用绝对路径调用 .venv/bin/python

  1. 带时间过滤的搜索:
curl -X POST http://127.0.0.1:8001/search \
  -H "Content-Type: application/json" \
  -d '{
    "query": "最新科技新闻",
    "top_k": 5,
    "recency_filter": "week"
  }'
  1. 限定网站搜索:
curl -X POST http://127.0.0.1:8001/search \
  -H "Content-Type: application/json" \
  -d '{
    "query": "天气预报",
    "top_k": 5,
    "site_filter": ["www.weather.com.cn"]
  }'

API 参数

参数类型默认值说明
querystring必填搜索关键词
top_kint10返回结果数量 (1-20)
recency_filterstringnull时间过滤: day, week, month, year
site_filterlistnull限定搜索的网站列表

Response Format

{
  "results": [
    {
      "title": "北京十大必去景点",
      "url": "https://example.com/beijing-attractions",
      "snippet": "北京作为中国的首都,拥有众多著名景点...",
      "site_name": "旅游网"
    }
  ],
  "total": 10
}

Conversation Flow

  1. 用户提问需要搜索的内容
  2. 判断是否需要时间过滤(如"最新"、"今天"等)
  3. 调用搜索 API 获取结果
  4. 整理并展示相关信息
  5. 可根据需要深入查看某个结果

使用场景

  • 查询实时信息(新闻、天气、股票等)
  • 搜索中文互联网内容
  • 获取特定网站的信息
  • 时效性要求高的查询

已修复问题

  • 响应解析: 百度 API 返回数据在 references 字段而非 search_results
  • 启动方式: 使用 PYTHONPATH=src .venv/bin/python -m uvicorn 而非直接调用 uvicorn

Files

6 total
Select a file
Select a file to preview.

Comments

Loading comments…