Toolkit for Chat API
Project description
以 CLI 为核心的 Python 开发套件,集成 LLM 对话、工具箱(DNS、飞书、绘图等)、MCP 服务和环境管理。
安装
pip install chattool --upgrade
pip install "chattool[images]" # 含图像工具
pip install "chattool[dev]" # 含 MCP 等开发依赖
功能概览
环境变量管理 (chatenv)
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)
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)
chattool lark send USER_ID "Hello"
chattool lark send USER_ID --image photo.png
chattool serve lark echo # 回显机器人
chattool serve lark ai --system "你是工作助手" # AI 对话机器人
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)
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)
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
开源协议
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chattool-6.0.0.tar.gz
(145.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
chattool-6.0.0-py3-none-any.whl
(179.7 kB
view details)
File details
Details for the file chattool-6.0.0.tar.gz.
File metadata
- Download URL: chattool-6.0.0.tar.gz
- Upload date:
- Size: 145.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ddc3e8a735de9a0089625a039f333fa3c9032a6530e1adc13b4bd60050e8be4
|
|
| MD5 |
6b57bef7f6b03946c186aeeef2d69f67
|
|
| BLAKE2b-256 |
a3d93f3a7c354ada7243ee7a63712ea0cd87372a8284dc63a6699b90b424ab2d
|
File details
Details for the file chattool-6.0.0-py3-none-any.whl.
File metadata
- Download URL: chattool-6.0.0-py3-none-any.whl
- Upload date:
- Size: 179.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60dd31b3ec3823104fd144134dd263b34426b9021f4ccc34fca4392dccc1fc72
|
|
| MD5 |
2ee2d3daf3b3785930ce21539033e502
|
|
| BLAKE2b-256 |
8475e7434810794aba0b8fcf9ffd47bb27a2b07f92780866a5b60ed9c4a2a70a
|