> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olostep.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Olostep + Nanobot 集成

> 使用 Olostep 作为 nanobot 的 web_search 工具的网络搜索后端。

Olostep 为 nanobot 的 `web_search` 工具添加了一个搜索后端，为代理提供 AI 友好的网络答案和来源链接，无需你构建自定义检索管道。

## 功能

<CardGroup cols={2}>
  <Card title="AI 答案" icon="sparkles">
    返回简洁答案及支持的来源链接。
  </Card>

  <Card title="简单设置" icon="plug">
    通过一个配置值和一个 API 密钥启用提供者。
  </Card>

  <Card title="可选依赖" icon="boxes-stacked">
    仅在需要时安装 Olostep。
  </Card>

  <Card title="代理支持" icon="network-wired">
    在需要时通过 `tools.web.proxy` 路由请求。
  </Card>

  <Card title="安全回退" icon="shield-halved">
    当没有 Olostep 密钥时回退到 DuckDuckGo。
  </Card>

  <Card title="标准化输出" icon="list">
    使用与其他提供者相同的网络搜索输出格式。
  </Card>
</CardGroup>

## 安装

<CodeGroup>
  ```bash pip theme={null}
  pip install "nanobot-ai[olostep]"
  ```

  ```bash poetry theme={null}
  poetry add "nanobot-ai[olostep]"
  ```
</CodeGroup>

<Note>
  如果你手动管理依赖，底层包是 `olostep>=0.1.0`。
</Note>

## 设置

通过环境变量或 nanobot 配置设置你的 API 密钥。

### 环境变量

```bash theme={null}
export OLOSTEP_API_KEY="your-api-key"
```

### 配置文件

将以下内容添加到 `~/.nanobot/config.json`：

```json theme={null}
{
  "tools": {
    "web": {
      "search": {
        "provider": "olostep",
        "apiKey": "YOUR_OLOSTEP_API_KEY"
      }
    }
  }
}
```

### 可选代理

如果你的环境需要代理，在 `tools.web.proxy` 下配置一次：

```json theme={null}
{
  "tools": {
    "web": {
      "proxy": "http://127.0.0.1:7890"
    }
  }
}
```

## 可用工具 / 方法

### `web_search`

通过将 `tools.web.search.provider` 设置为 `olostep` 使用 Olostep。

#### 参数

<ParamField path="provider" type="string">
  设置为 `olostep` 以启用此集成。默认值：`duckduckgo`
</ParamField>

<ParamField path="apiKey" type="string">
  Olostep API 密钥。你也可以使用 `OLOSTEP_API_KEY` 环境变量。
</ParamField>

<ParamField path="baseUrl" type="string">
  Olostep 不使用。保留以保持配置一致性。
</ParamField>

<ParamField path="maxResults" type="integer" default="5">
  每次搜索的结果数量，范围为 1–10。
</ParamField>

<ParamField path="timeout" type="integer" default="30">
  搜索超时时间，以秒为单位。
</ParamField>

<ParamField path="proxy" type="string or null">
  在 `tools.web` 下配置的代理 URL。
</ParamField>

<CodeGroup>
  ```json Basic Setup theme={null}
  {
    "tools": {
      "web": {
        "search": {
          "provider": "olostep",
          "apiKey": "YOUR_OLOSTEP_API_KEY"
        }
      }
    }
  }
  ```

  ```json With Environment Variable theme={null}
  {
    "tools": {
      "web": {
        "search": {
          "provider": "olostep"
        }
      }
    }
  }
  ```

  ```bash theme={null}
  export OLOSTEP_API_KEY="your-api-key"
  ```

  ```json With Proxy theme={null}
  {
    "tools": {
      "web": {
        "proxy": "http://127.0.0.1:7890",
        "search": {
          "provider": "olostep",
          "apiKey": "YOUR_OLOSTEP_API_KEY"
        }
      }
    }
  }
  ```
</CodeGroup>

## 完整代理示例

### 示例 1：快速研究助手

```python theme={null}
import asyncio

from nanobot import Nanobot


async def main() -> None:
    bot = Nanobot.from_config()
    result = await bot.run(
        "Use web search to summarize the latest Olostep SDK capabilities and cite sources.",
        session_key="olostep-research",
    )
    print(result.content)


asyncio.run(main())
```

### 示例 2：工作区中的研究工作流

```python theme={null}
import asyncio

from nanobot import Nanobot


async def main() -> None:
    bot = Nanobot.from_config(workspace="/home/user/projects/research")
    result = await bot.run(
        "Find recent documentation for programmatic web access tools and list the key tradeoffs.",
        session_key="olostep-workspace-demo",
    )
    print(result.content)


asyncio.run(main())
```

### 示例 3：支持代理的搜索设置

```python theme={null}
import asyncio

from nanobot import Nanobot


async def main() -> None:
    bot = Nanobot.from_config(workspace="/home/user/projects/research")
    result = await bot.run(
        "Search for implementation notes about web-scraping SDKs and summarize the differences.",
        session_key="olostep-proxy-demo",
    )
    print(result.content)


asyncio.run(main())
```

## 配置 / 选项

* 将 `tools.web.search.provider` 设置为 `olostep` 以启用集成。
* 如果你希望同时使用 `web_search` 和 `web_fetch`，保持 `tools.web.enable` 为 `true`。
* 将 `tools.web.enable` 设置为 `false` 以禁用所有内置网络工具。
* 如果你的环境需要通过代理进行外部流量，设置 `tools.web.proxy`。
* 如果你想要默认的 DuckDuckGo 回退行为，请不要设置 `provider`。

### 回退行为

如果选择了 Olostep 但没有可用的 API 密钥，nanobot 会回退到 DuckDuckGo 而不是直接失败。

## 专用功能

* **源感知答案** — Olostep 返回响应和来源链接。
* **共享格式** — 结果以其他提供者使用的相同标准化搜索输出呈现。
* **无硬依赖** — 提供者在 `try/except` 保护下导入，因此即使没有安装 Olostep，nanobot 仍然可以工作。
* **代理感知传输** — `tools.web.proxy` 应用于集成使用的底层 HTTP 客户端。

## 定价

Olostep 的定价由 Olostep 直接管理，可能会随时间变化。请检查你的 Olostep 账户仪表板以获取当前计划、配额和使用成本。

## 支持

* **PyPI**: [pypi.org/project/olostep](https://pypi.org/project/olostep/)
* **文档**: [docs.olostep.com](https://docs.olostep.com)
* **主页**: [olostep.com](https://www.olostep.com)
* **GitHub 仓库**: [github.com/olostep-api/olostep-py](https://github.com/olostep-api/olostep-py)
* **GitHub 问题**: [github.com/olostep-api/olostep-py/issues](https://github.com/olostep-api/olostep-py/issues)
* **电子邮件**: [team@olostep.com](mailto:team@olostep.com)

## 相关资源

<CardGroup cols={2}>
  <Card title="答案 API" icon="question" href="/features/answers/answers">
    了解支持此集成的答案端点
  </Card>

  <Card title="Python SDK" icon="python" href="/sdks/python">
    探索 Olostep Python SDK
  </Card>

  <Card title="搜索结果" icon="magnifying-glass" href="/searches/searches">
    了解网络搜索功能
  </Card>

  <Card title="API 文档" icon="book" href="/get-started/authentication">
    浏览完整的 API 参考
  </Card>
</CardGroup>
