Metadata-Version: 2.4
Name: chattool
Version: 6.0.0
Summary: Toolkit for Chat API
Author-email: Rex Wang <1073853456@qq.com>
License: MIT license
Project-URL: Homepage, https://github.com/cubenlp/chattool
Project-URL: Repository, https://github.com/cubenlp/chattool
Keywords: chattool
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Click>=7.0
Requires-Dist: questionary>=2.1.0
Requires-Dist: requests>=2.20
Requires-Dist: aiohttp>=3.8
Requires-Dist: tqdm>=4.60
Requires-Dist: python-dotenv>=0.17.0
Requires-Dist: loguru>=0.7
Requires-Dist: fastmcp; python_version >= "3.10"
Requires-Dist: batch_executor>=0.3.0
Requires-Dist: colorama
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: platformdirs>=3.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: httpx
Requires-Dist: gitpython
Requires-Dist: PyGithub
Requires-Dist: filelock
Requires-Dist: pillow
Provides-Extra: dns
Requires-Dist: netifaces; extra == "dns"
Requires-Dist: alibabacloud_alidns20150109>=3.5.10; extra == "dns"
Requires-Dist: alibabacloud_tea_openapi>=0.3.0; extra == "dns"
Requires-Dist: tencentcloud-sdk-python; extra == "dns"
Provides-Extra: lark
Requires-Dist: lark-oapi==1.5.3; extra == "lark"
Requires-Dist: flask; extra == "lark"
Provides-Extra: images
Requires-Dist: dashscope; extra == "images"
Provides-Extra: screenshot
Requires-Dist: selenium; extra == "screenshot"
Requires-Dist: pillow; extra == "screenshot"
Requires-Dist: imageio; extra == "screenshot"
Provides-Extra: browser
Requires-Dist: selenium; extra == "browser"
Requires-Dist: pillow; extra == "browser"
Requires-Dist: imageio; extra == "browser"
Requires-Dist: playwright; extra == "browser"
Provides-Extra: tools
Requires-Dist: chattool[dns,images,lark,screenshot]; extra == "tools"
Provides-Extra: tests
Requires-Dist: coverage; extra == "tests"
Requires-Dist: pytest>=3; extra == "tests"
Requires-Dist: pytest-asyncio; extra == "tests"
Requires-Dist: pytest-mock; extra == "tests"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.4.0; extra == "docs"
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
Requires-Dist: mkdocs-minify-plugin>=0.6.0; extra == "docs"
Requires-Dist: mkdocs-static-i18n>=0.53; extra == "docs"
Requires-Dist: mkdocs-awesome-pages-plugin>=2.8.0; extra == "docs"
Requires-Dist: mkdocs-redirects>=1.2.0; extra == "docs"
Requires-Dist: mike>=1.1.2; extra == "docs"
Provides-Extra: dev
Requires-Dist: wheel; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: chattool[docs,tests,tools]; extra == "dev"
Dynamic: license-file

<div align="center">
    <a href="https://pypi.python.org/pypi/chattool">
        <img src="https://img.shields.io/pypi/v/chattool.svg" alt="PyPI version" />
    </a>
    <a href="https://github.com/cubenlp/chattool/actions/workflows/ci.yml">
        <img src="https://github.com/cubenlp/chattool/actions/workflows/ci.yml/badge.svg" alt="Tests" />
    </a>
    <a href="https://chattool.wzhecnu.cn">
        <img src="https://img.shields.io/badge/docs-github_pages-blue.svg" alt="Documentation Status" />
    </a>
    <a href="https://codecov.io/gh/cubenlp/chattool">
        <img src="https://codecov.io/gh/cubenlp/chattool/branch/master/graph/badge.svg" alt="Coverage" />
    </a>
</div>

<div align="center">
    <img src="https://qiniu.wzhecnu.cn/PicBed6/picgo/chattool.jpeg" alt="ChatAPI Toolkit" width="360" style="border-radius: 20px;">

[English](README_en.md) | [简体中文](README.md)
</div>

以 CLI 为核心的 Python 开发套件，集成 LLM 对话、工具箱（DNS、飞书、绘图等）、MCP 服务和环境管理。

## 安装

```bash
pip install chattool --upgrade
pip install "chattool[images]"   # 含图像工具
pip install "chattool[dev]"      # 含 MCP 等开发依赖
```

## 功能概览

### 环境变量管理 (`chatenv`)

```bash
chatenv init -i                  # 交互式初始化（敏感字段自动隐藏）
chatenv init -i -t openai        # 仅初始化指定服务
chatenv cat                      # 查看配置（敏感值打码）
chatenv set OPENAI_API_KEY=sk-xxx
chatenv save work && chatenv use work   # 多 profile 管理
```

### LLM 对话 (`chattool.Chat`)

```python
from chattool import Chat

# 多轮对话
chat = Chat("Hello!")
chat.get_response()
chat.user("How are you?").get_response()

# 异步并发
import asyncio
base = Chat().system("你是助手")
tasks = [base.copy().user(f"主题 {i}").async_get_response() for i in range(5)]
responses = asyncio.run(asyncio.gather(*tasks))

# 流式输出
async for chunk in Chat().user("写一首诗").async_get_response_stream():
    if chunk.delta_content:
        print(chunk.delta_content, end="", flush=True)
```

### 飞书机器人 (`chattool lark`)

```bash
chattool lark send USER_ID "Hello"
chattool lark send USER_ID --image photo.png
chattool serve lark echo                        # 回显机器人
chattool serve lark ai --system "你是工作助手"  # AI 对话机器人
```

```python
from chattool.tools.lark import LarkBot, ChatSession

bot = LarkBot()
session = ChatSession(system="你是助手")

@bot.on_message
def chat(ctx):
    ctx.reply(session.chat(ctx.sender_id, ctx.text))

bot.start()
```

### DNS 管理 (`chattool dns`)

```bash
chattool dns get home.example.com
chattool dns set home.example.com -v 1.2.3.4
chattool dns ddns home.example.com --monitor
chattool dns cert-update -d example.com -e admin@example.com
```

### AI 绘图 (`chattool image`)

```bash
chattool image pollinations generate "a cat in space" -o cat.png
chattool image siliconflow generate "a cute dog" -o dog.png
```

### 其他工具

| 工具 | 命令 | 说明 |
|------|------|------|
| 网络扫描 | `chattool network` | 扫描局域网主机和端口 |
| MCP 服务 | `chattool mcp start` | 标准 MCP Server，供 Claude/Cursor 调用 |
| 环境安装 | `chattool setup codex/claude` | 安装 Codex / Claude Code 并写入配置 |
| Skills | `chattool skill install` | 安装 ChatTool skills 到 Codex / Claude Code |

## 文档

完整文档见 [chattool.wzhecnu.cn](https://chattool.wzhecnu.cn)

## 开源协议

MIT License
