# 网页搜索

代理可以自行搜索实时网页。默认情况下，这由服务器端代理（Parallel）提供支持，因此你无需携带搜索 API 密钥。如果你运行自己的 [SearXNG](https://docs.searxng.org/) 实例，你可以启用 `searxng_search` 作为一个私有、自托管的搜索工具。

## 它适合做什么

* 研究 - “X 的最新情况是什么”。
* 引用搜集 - “给我找出 Y 的三个来源”。
* 回答前进行事实核查 - 如果代理没有把握，它会快速搜索一下。

## 自托管 SearXNG

SearXNG 搜索是可选启用的。启用后，OpenHuman 会为 `searxng_search` 代理和 MCP 客户端注册。该工具会调用你配置的 SearXNG `/search?format=json` 端点，并返回规范化的 `{ 标题, URL, 摘要, 来源 }` 结果。

在 `config.toml`:

```toml
[searxng]
enabled = true
base_url = "http://localhost:8080"
max_results = 10
default_language = "en"
timeout_seconds = 10
```

或者通过环境变量：

```bash
OPENHUMAN_SEARXNG_ENABLED=true
OPENHUMAN_SEARXNG_BASE_URL=http://localhost:8080
OPENHUMAN_SEARXNG_MAX_RESULTS=10
OPENHUMAN_SEARXNG_DEFAULT_LANGUAGE=en
OPENHUMAN_SEARXNG_TIMEOUT_SECONDS=10
```

每次调用时，该工具接受 `query`，可选的 `categories` (`web`, `news`, `images`），可选的 `language`，以及可选的 `max_results` 最多 50。空查询、不受支持的类别、非 2xx 的 SearXNG 响应以及超时失败都会返回结构化的工具错误，而不会静默回退到云端搜索提供商。

## 它与通用 HTTP 的区别

纯粹的 `http_request` 工具可以获取一个 URL，但不能 *发现* 一个。Web Search 是发现层：它为代理挑选合适的 URL，然后再把这些 URL 交给 [网页抓取器](/openhuman/zh/gong-neng/native-tools/web-scraper.md) 用于实际阅读。

## 另见

* [MCP 服务器](https://github.com/tinyhumansai/openhuman/blob/main/gitbooks/developing/mcp-server.md) - 如何 `searxng_search` 在 MCP 客户端中显示。
* [网页抓取器](/openhuman/zh/gong-neng/native-tools/web-scraper.md) - 获取并清理特定 URL。
* [智能 Token 压缩](/openhuman/zh/gong-neng/token-compression.md) - 搜索摘要在送入模型之前会被压缩。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tinyhumans.gitbook.io/openhuman/zh/gong-neng/native-tools/web-search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
