Files
bot042/README.md
T

73 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# bot042
基于 [deepagents](https://github.com/langchain-ai/deepagents) 的自主行动机器人原型:理解任务、自主规划(todo)、调用机器人工具在模拟环境中行动。
## 特性
- 深度智能体:内置任务规划 / 子智能体 / 工具调用循环(deepagents)
- 机器人工具:感知 `perceive`、移动 `move`、播报 `speak`,附带简易虚拟世界状态
- uv 管理依赖与 Python,国内镜像加速(见 `uv.toml`)
- CLI 入口:单次任务 / 交互模式
## 快速开始
```bash
uv sync
$env:OPENAI_API_KEY = "sk-..." # PowerShell;bash 用 export
uv run bot042 "感知环境,然后向北移动 2 步并播报状态"
```
交互模式:
```bash
uv run bot042 -i
```
## 配置(环境变量)
| 变量 | 说明 | 默认值 |
| --- | --- | --- |
| `BOT042_MODEL` | langchain 模型标识(`provider:model`) | `openai:gpt-4o-mini` |
| `OPENAI_API_KEY` | OpenAI 兼容 API Key | — |
| `OPENAI_BASE_URL` | 兼容网关地址(DeepSeek / Kimi 等均可) | 官方地址 |
| `BOT042_MAX_STEPS` | 单次任务最大步数(recursion_limit) | `50` |
| `BOT042_LOG_LEVEL` | 日志级别 | `INFO` |
使用 DeepSeek 等 OpenAI 兼容服务示例:
```bash
$env:OPENAI_BASE_URL = "https://api.deepseek.com/v1"
$env:OPENAI_API_KEY = "sk-..."
$env:BOT042_MODEL = "openai:deepseek-chat"
```
## 目录结构
```
src/bot042/
__main__.py # CLI 入口(uv run bot042)
config.py # 环境变量配置
agent/ # 智能体:组装(agent.py)、提示词(prompts.py)、工具(tools.py)
channels/ # 通道:与外部世界交互,base.py 定义协议,cli.py 为 CLI 实现
flows/ # 编排:单任务流程(task.py)、交互会话流程(session.py)
tests/ # 冒烟测试
uv.toml # 国内镜像配置(TUNA PyPI + npmmirror Python)
```
分层关系:`channels`(收/发消息)→ `flows`(组织流程)→ `agent`(智能体与工具)。新增通道实现 `channels.base.Channel` 协议即可复用现有 flows。
## 开发
```bash
uv run pytest # 运行测试
uv run ruff check # 代码检查
uv run ruff format # 格式化
```
## 镜像源
`uv.toml` 已配置国内镜像,`uv sync` / `uv python install` 均自动生效:
- PyPI 包:清华大学 TUNA — `https://pypi.tuna.tsinghua.edu.cn/simple`
- Python(python-build-standalone):npmmirror — `https://registry.npmmirror.com/-/binary/python-build-standalone`