chattool 5.2.0__tar.gz → 5.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chattool-5.4.0/PKG-INFO +246 -0
- chattool-5.4.0/README.md +172 -0
- {chattool-5.2.0 → chattool-5.4.0}/pyproject.toml +21 -5
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/__init__.py +8 -2
- chattool-5.4.0/src/chattool/cli/__init__.py +11 -0
- chattool-5.4.0/src/chattool/cli/chatenv.py +467 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/client/__init__.py +10 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/client/cert_client.py +4 -2
- chattool-5.4.0/src/chattool/cli/client/github.py +261 -0
- chattool-5.4.0/src/chattool/cli/client/image.py +265 -0
- chattool-5.4.0/src/chattool/cli/client/lark.py +387 -0
- chattool-5.4.0/src/chattool/cli/client/mcp.py +80 -0
- chattool-5.4.0/src/chattool/cli/client/network.py +197 -0
- chattool-5.4.0/src/chattool/cli/client/tplogin.py +331 -0
- chattool-5.4.0/src/chattool/cli/client/zulip.py +368 -0
- chattool-5.4.0/src/chattool/cli/main.py +87 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/service/__init__.py +2 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/service/cert_server.py +3 -2
- chattool-5.4.0/src/chattool/cli/service/lark_serve.py +177 -0
- chattool-5.4.0/src/chattool/cli/skill.py +206 -0
- chattool-5.4.0/src/chattool/cli/test_cmd.py +28 -0
- chattool-5.4.0/src/chattool/config/__init__.py +25 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/config/elements.py +15 -1
- chattool-5.4.0/src/chattool/config/github.py +20 -0
- chattool-5.4.0/src/chattool/config/main.py +270 -0
- chattool-5.4.0/src/chattool/docker/__init__.py +3 -0
- chattool-5.4.0/src/chattool/docker/cli.py +26 -0
- chattool-5.4.0/src/chattool/docker/elements.py +111 -0
- chattool-5.4.0/src/chattool/docker/main.py +64 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/llm/chattype.py +7 -4
- chattool-5.4.0/src/chattool/mcp/catalog.py +48 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/mcp/server.py +5 -12
- chattool-5.4.0/src/chattool/serve/__init__.py +1 -0
- chattool-5.4.0/src/chattool/serve/chrome.py +84 -0
- chattool-5.4.0/src/chattool/setup/__init__.py +0 -0
- chattool-5.4.0/src/chattool/setup/chrome.py +148 -0
- chattool-5.4.0/src/chattool/setup/cli.py +4 -0
- chattool-5.4.0/src/chattool/setup/codex.py +72 -0
- chattool-5.4.0/src/chattool/setup/elements.py +83 -0
- chattool-5.4.0/src/chattool/setup/frp.py +224 -0
- chattool-5.4.0/src/chattool/setup/main.py +25 -0
- chattool-5.4.0/src/chattool/setup/nodejs.py +66 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/__init__.py +8 -2
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/cert/acme_dns_tiny.py +4 -4
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/cert/cert_updater.py +10 -5
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/base.py +1 -1
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/ip_updater.py +2 -2
- chattool-5.4.0/src/chattool/tools/github/__init__.py +3 -0
- chattool-5.2.0/src/chattool/tools/githubclient.py → chattool-5.4.0/src/chattool/tools/github/client.py +3 -8
- chattool-5.4.0/src/chattool/tools/image/__init__.py +40 -0
- chattool-5.4.0/src/chattool/tools/image/base.py +30 -0
- chattool-5.4.0/src/chattool/tools/image/huggingface.py +44 -0
- chattool-5.4.0/src/chattool/tools/image/liblib.py +150 -0
- chattool-5.4.0/src/chattool/tools/image/pollinations.py +56 -0
- chattool-5.4.0/src/chattool/tools/image/siliconflow.py +92 -0
- chattool-5.4.0/src/chattool/tools/image/tongyi.py +61 -0
- chattool-5.4.0/src/chattool/tools/lark/__init__.py +5 -0
- chattool-5.4.0/src/chattool/tools/lark/bot.py +660 -0
- chattool-5.4.0/src/chattool/tools/lark/context.py +128 -0
- chattool-5.4.0/src/chattool/tools/lark/elements.py +119 -0
- chattool-5.4.0/src/chattool/tools/lark/session.py +116 -0
- chattool-5.4.0/src/chattool/tools/network/link_check.py +168 -0
- chattool-5.4.0/src/chattool/tools/tplogin.py +242 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/zulip/client.py +13 -2
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/basic.py +1 -1
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/fastobj.py +6 -3
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/httpclient.py +23 -17
- chattool-5.4.0/src/chattool/utils/tui.py +91 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/urltool.py +6 -3
- chattool-5.4.0/src/chattool.egg-info/PKG-INFO +246 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool.egg-info/SOURCES.txt +40 -1
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool.egg-info/entry_points.txt +1 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool.egg-info/requires.txt +20 -4
- chattool-5.4.0/tests/test_import.py +5 -0
- chattool-5.2.0/PKG-INFO +0 -241
- chattool-5.2.0/README.md +0 -179
- chattool-5.2.0/src/chattool/cli/__init__.py +0 -5
- chattool-5.2.0/src/chattool/cli/chatenv.py +0 -234
- chattool-5.2.0/src/chattool/cli/client/mcp.py +0 -43
- chattool-5.2.0/src/chattool/cli/client/network.py +0 -49
- chattool-5.2.0/src/chattool/cli/main.py +0 -48
- chattool-5.2.0/src/chattool/cli/test_cmd.py +0 -76
- chattool-5.2.0/src/chattool/config/__init__.py +0 -12
- chattool-5.2.0/src/chattool/config/main.py +0 -45
- chattool-5.2.0/src/chattool.egg-info/PKG-INFO +0 -241
- chattool-5.2.0/tests/test_import.py +0 -1
- {chattool-5.2.0 → chattool-5.4.0}/LICENSE +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/setup.cfg +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/_all.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/application/kb/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/application/kb/cli.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/application/kb/ingest.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/application/kb/manager.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/application/kb/storage.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/client/cert_updater.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/client/dns_updater.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/cli/service/capture.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/const.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/llm/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/llm/response.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/mcp/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/mcp/dns.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/mcp/network.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/mcp/zulip.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/cert/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/cert/cert_server.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/aliyun.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/tencent.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/dns/utils.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/interact.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/network/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/network/scanner.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/zulip/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/tools/zulip/legacy.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/__init__.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool/utils/custom_logger.py +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool.egg-info/dependency_links.txt +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/src/chattool.egg-info/top_level.txt +0 -0
- {chattool-5.2.0 → chattool-5.4.0}/tests/test_chatenv.py +0 -0
chattool-5.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chattool
|
|
3
|
+
Version: 5.4.0
|
|
4
|
+
Summary: Toolkit for Chat API
|
|
5
|
+
Author-email: Rex Wang <1073853456@qq.com>
|
|
6
|
+
License: MIT license
|
|
7
|
+
Project-URL: Homepage, https://github.com/cubenlp/chattool
|
|
8
|
+
Project-URL: Repository, https://github.com/cubenlp/chattool
|
|
9
|
+
Keywords: chattool
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: Click>=7.0
|
|
22
|
+
Requires-Dist: questionary>=2.1.0
|
|
23
|
+
Requires-Dist: requests>=2.20
|
|
24
|
+
Requires-Dist: aiohttp>=3.8
|
|
25
|
+
Requires-Dist: tqdm>=4.60
|
|
26
|
+
Requires-Dist: python-dotenv>=0.17.0
|
|
27
|
+
Requires-Dist: loguru>=0.7
|
|
28
|
+
Requires-Dist: fastmcp; python_version >= "3.10"
|
|
29
|
+
Requires-Dist: batch_executor>=0.3.0
|
|
30
|
+
Requires-Dist: colorama
|
|
31
|
+
Requires-Dist: fastapi
|
|
32
|
+
Requires-Dist: uvicorn
|
|
33
|
+
Requires-Dist: platformdirs>=3.0
|
|
34
|
+
Requires-Dist: pydantic>=2.0.0
|
|
35
|
+
Requires-Dist: httpx
|
|
36
|
+
Requires-Dist: gitpython
|
|
37
|
+
Requires-Dist: PyGithub
|
|
38
|
+
Requires-Dist: filelock
|
|
39
|
+
Provides-Extra: dns
|
|
40
|
+
Requires-Dist: netifaces; extra == "dns"
|
|
41
|
+
Requires-Dist: alibabacloud_alidns20150109>=3.5.10; extra == "dns"
|
|
42
|
+
Requires-Dist: alibabacloud_tea_openapi>=0.3.0; extra == "dns"
|
|
43
|
+
Requires-Dist: tencentcloud-sdk-python; extra == "dns"
|
|
44
|
+
Provides-Extra: lark
|
|
45
|
+
Requires-Dist: lark-oapi==1.5.3; extra == "lark"
|
|
46
|
+
Requires-Dist: flask; extra == "lark"
|
|
47
|
+
Provides-Extra: images
|
|
48
|
+
Requires-Dist: dashscope; extra == "images"
|
|
49
|
+
Provides-Extra: screenshot
|
|
50
|
+
Requires-Dist: selenium; extra == "screenshot"
|
|
51
|
+
Requires-Dist: pillow; extra == "screenshot"
|
|
52
|
+
Requires-Dist: imageio; extra == "screenshot"
|
|
53
|
+
Provides-Extra: tools
|
|
54
|
+
Requires-Dist: chattool[dns,images,lark,screenshot]; extra == "tools"
|
|
55
|
+
Provides-Extra: tests
|
|
56
|
+
Requires-Dist: coverage; extra == "tests"
|
|
57
|
+
Requires-Dist: pytest>=3; extra == "tests"
|
|
58
|
+
Requires-Dist: pytest-asyncio; extra == "tests"
|
|
59
|
+
Requires-Dist: pytest-mock; extra == "tests"
|
|
60
|
+
Provides-Extra: docs
|
|
61
|
+
Requires-Dist: mkdocs>=1.4.0; extra == "docs"
|
|
62
|
+
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
|
|
63
|
+
Requires-Dist: mkdocs-minify-plugin>=0.6.0; extra == "docs"
|
|
64
|
+
Requires-Dist: mkdocs-static-i18n>=0.53; extra == "docs"
|
|
65
|
+
Requires-Dist: mkdocs-awesome-pages-plugin>=2.8.0; extra == "docs"
|
|
66
|
+
Requires-Dist: mkdocs-redirects>=1.2.0; extra == "docs"
|
|
67
|
+
Requires-Dist: mike>=1.1.2; extra == "docs"
|
|
68
|
+
Provides-Extra: dev
|
|
69
|
+
Requires-Dist: wheel; extra == "dev"
|
|
70
|
+
Requires-Dist: build; extra == "dev"
|
|
71
|
+
Requires-Dist: twine; extra == "dev"
|
|
72
|
+
Requires-Dist: chattool[docs,tests,tools]; extra == "dev"
|
|
73
|
+
Dynamic: license-file
|
|
74
|
+
|
|
75
|
+
<div align="center">
|
|
76
|
+
<a href="https://pypi.python.org/pypi/chattool">
|
|
77
|
+
<img src="https://img.shields.io/pypi/v/chattool.svg" alt="PyPI version" />
|
|
78
|
+
</a>
|
|
79
|
+
<a href="https://github.com/cubenlp/chattool/actions/workflows/ci.yml">
|
|
80
|
+
<img src="https://github.com/cubenlp/chattool/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
81
|
+
</a>
|
|
82
|
+
<a href="https://chattool.wzhecnu.cn">
|
|
83
|
+
<img src="https://img.shields.io/badge/docs-github_pages-blue.svg" alt="Documentation Status" />
|
|
84
|
+
</a>
|
|
85
|
+
<a href="https://codecov.io/gh/cubenlp/chattool">
|
|
86
|
+
<img src="https://codecov.io/gh/cubenlp/chattool/branch/master/graph/badge.svg" alt="Coverage" />
|
|
87
|
+
</a>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div align="center">
|
|
91
|
+
<img src="https://qiniu.wzhecnu.cn/PicBed6/picgo/chattool.jpeg" alt="ChatAPI Toolkit" width="360", style="border-radius: 20px;">
|
|
92
|
+
|
|
93
|
+
[English](README_en.md) | [简体中文](README.md)
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
集成 LLM 对话、飞书机器人、DNS 管理、SSL 证书等工具的 Python 开发套件。
|
|
97
|
+
|
|
98
|
+
## 安装
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install chattool --upgrade
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 功能概览
|
|
105
|
+
|
|
106
|
+
### 1. 环境变量管理 (`chatenv`)
|
|
107
|
+
|
|
108
|
+
集中式配置管理,密码类字段自动脱敏显示,交互模式隐藏敏感输入。
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# 交互式初始化(敏感字段自动隐藏输入)
|
|
112
|
+
chatenv init -i
|
|
113
|
+
|
|
114
|
+
# 仅初始化指定服务配置
|
|
115
|
+
chatenv init -i -t openai
|
|
116
|
+
chatenv init -i -t feishu
|
|
117
|
+
|
|
118
|
+
# 查看全部配置(敏感值自动打码)
|
|
119
|
+
chatenv cat
|
|
120
|
+
|
|
121
|
+
# 按类型过滤查看
|
|
122
|
+
chatenv cat -t feishu
|
|
123
|
+
|
|
124
|
+
# 设置 / 查看单项
|
|
125
|
+
chatenv set OPENAI_API_KEY=sk-xxx
|
|
126
|
+
chatenv get OPENAI_API_KEY
|
|
127
|
+
|
|
128
|
+
# 多配置 profile 管理
|
|
129
|
+
chatenv save work && chatenv use work
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. Chat 对话 (`chattool.Chat`)
|
|
133
|
+
|
|
134
|
+
基于 OpenAI API 的对话对象,支持多轮对话、批量处理、异步并发和流式输出。
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from chattool import Chat
|
|
138
|
+
|
|
139
|
+
# 多轮对话
|
|
140
|
+
chat = Chat("Hello!")
|
|
141
|
+
resp = chat.get_response()
|
|
142
|
+
chat.user("How are you?")
|
|
143
|
+
chat.get_response()
|
|
144
|
+
chat.save("chat.json", mode="w")
|
|
145
|
+
|
|
146
|
+
# 异步并发
|
|
147
|
+
import asyncio
|
|
148
|
+
base = Chat().system("你是一个有用的助手")
|
|
149
|
+
tasks = [base.copy().user(f"主题 {i}").async_get_response() for i in range(5)]
|
|
150
|
+
responses = asyncio.run(asyncio.gather(*tasks))
|
|
151
|
+
|
|
152
|
+
# 流式输出
|
|
153
|
+
async for chunk in Chat().user("写一首诗").async_get_response_stream():
|
|
154
|
+
if chunk.delta_content:
|
|
155
|
+
print(chunk.delta_content, end="", flush=True)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 3. 飞书/Lark 机器人 (`chattool lark`)
|
|
159
|
+
|
|
160
|
+
一行命令发消息、启动 Echo/AI 机器人,支持文本、图片、文件、富文本等消息类型。
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# 发送消息
|
|
164
|
+
chattool lark send -r USER_ID -m "Hello"
|
|
165
|
+
chattool lark send -r USER_ID --image photo.png
|
|
166
|
+
chattool lark send -r USER_ID --file report.pdf
|
|
167
|
+
|
|
168
|
+
# 启动 Echo 机器人(WebSocket)
|
|
169
|
+
chattool serve lark echo
|
|
170
|
+
|
|
171
|
+
# 启动 AI 对话机器人
|
|
172
|
+
chattool serve lark ai --model gpt-4o
|
|
173
|
+
|
|
174
|
+
# 查看机器人信息和权限
|
|
175
|
+
chattool lark info
|
|
176
|
+
chattool lark scopes
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from chattool.tools.lark import LarkBot
|
|
181
|
+
|
|
182
|
+
bot = LarkBot()
|
|
183
|
+
bot.send_text("ou_xxx", "open_id", "Hello!")
|
|
184
|
+
bot.send_image_file("ou_xxx", "open_id", "photo.png")
|
|
185
|
+
|
|
186
|
+
@bot.on_message
|
|
187
|
+
def handle(ctx):
|
|
188
|
+
ctx.reply_text(f"收到: {ctx.text}")
|
|
189
|
+
|
|
190
|
+
bot.start()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 4. DNS 管理 (`chattool dns`)
|
|
194
|
+
|
|
195
|
+
统一的 DNS 接口,支持阿里云和腾讯云,提供 DDNS 动态更新和 SSL 证书自动续期。
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# 查询 / 设置 DNS 记录
|
|
199
|
+
chattool dns get test.example.com
|
|
200
|
+
chattool dns set test.example.com -v 1.2.3.4
|
|
201
|
+
|
|
202
|
+
# DDNS 动态域名 (公网 / 局域网)
|
|
203
|
+
chattool dns ddns -d example.com -r home --monitor
|
|
204
|
+
chattool dns ddns -d example.com -r nas --ip-type local --local-ip-cidr 192.168.1.0/24
|
|
205
|
+
|
|
206
|
+
# SSL 证书自动更新
|
|
207
|
+
chattool dns cert-update -d example.com -e admin@example.com --cert-dir ./certs
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 5. AI 绘图 (`chattool image`)
|
|
211
|
+
|
|
212
|
+
支持 Tongyi、Hugging Face、LiblibAI、Pollinations.ai、SiliconFlow 等平台。
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# 安装图像依赖
|
|
216
|
+
pip install "chattool[images]"
|
|
217
|
+
|
|
218
|
+
# Pollinations(需配置 POLLINATIONS_API_KEY)
|
|
219
|
+
chattool image pollinations list-models
|
|
220
|
+
chattool image pollinations generate "a cat in space" -o cat.png
|
|
221
|
+
|
|
222
|
+
# SiliconFlow(需配置 SILICONFLOW_API_KEY)
|
|
223
|
+
chattool image siliconflow list-models
|
|
224
|
+
chattool image siliconflow generate "a cute dog" -o dog.png
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 6. 其他工具
|
|
228
|
+
|
|
229
|
+
| 工具 | 命令 | 说明 |
|
|
230
|
+
|------|------|------|
|
|
231
|
+
| 网络扫描 | `chattool network scan` | 扫描局域网活跃主机和 SSH 端口 |
|
|
232
|
+
| MCP 服务 | `chattool mcp info` / `chattool mcp inspect` | MCP Server 能力检查(支持 JSON 输出) |
|
|
233
|
+
| 截图服务 | `chattool serve capture` | 本地网页截图服务 |
|
|
234
|
+
| 证书分发 | `chattool serve cert` / `chattool client cert` | SSL 证书集中管理与客户端拉取 |
|
|
235
|
+
| Skills 管理 | `chattool skill install` / `chatskill install` | 安装 ChatTool skills 到 Codex / Claude Code |
|
|
236
|
+
|
|
237
|
+
## 开源协议
|
|
238
|
+
|
|
239
|
+
MIT License
|
|
240
|
+
|
|
241
|
+
## 更新日志
|
|
242
|
+
|
|
243
|
+
- `5.3.0` — 飞书机器人(消息收发、事件路由、AI 对话)、CLI 工具链(`chattool lark`、`chattool serve lark`)
|
|
244
|
+
- `5.0.0` — DNS 管理(阿里云/腾讯云)、DDNS、SSL 证书自动续期、环境变量集中管理
|
|
245
|
+
- `4.1.0` — 统一 `Chat` API(同步/异步/流式),默认环境变量配置
|
|
246
|
+
- 更早版本请参考仓库提交记录
|
chattool-5.4.0/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://pypi.python.org/pypi/chattool">
|
|
3
|
+
<img src="https://img.shields.io/pypi/v/chattool.svg" alt="PyPI version" />
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://github.com/cubenlp/chattool/actions/workflows/ci.yml">
|
|
6
|
+
<img src="https://github.com/cubenlp/chattool/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
7
|
+
</a>
|
|
8
|
+
<a href="https://chattool.wzhecnu.cn">
|
|
9
|
+
<img src="https://img.shields.io/badge/docs-github_pages-blue.svg" alt="Documentation Status" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://codecov.io/gh/cubenlp/chattool">
|
|
12
|
+
<img src="https://codecov.io/gh/cubenlp/chattool/branch/master/graph/badge.svg" alt="Coverage" />
|
|
13
|
+
</a>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
<img src="https://qiniu.wzhecnu.cn/PicBed6/picgo/chattool.jpeg" alt="ChatAPI Toolkit" width="360", style="border-radius: 20px;">
|
|
18
|
+
|
|
19
|
+
[English](README_en.md) | [简体中文](README.md)
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
集成 LLM 对话、飞书机器人、DNS 管理、SSL 证书等工具的 Python 开发套件。
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install chattool --upgrade
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 功能概览
|
|
31
|
+
|
|
32
|
+
### 1. 环境变量管理 (`chatenv`)
|
|
33
|
+
|
|
34
|
+
集中式配置管理,密码类字段自动脱敏显示,交互模式隐藏敏感输入。
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 交互式初始化(敏感字段自动隐藏输入)
|
|
38
|
+
chatenv init -i
|
|
39
|
+
|
|
40
|
+
# 仅初始化指定服务配置
|
|
41
|
+
chatenv init -i -t openai
|
|
42
|
+
chatenv init -i -t feishu
|
|
43
|
+
|
|
44
|
+
# 查看全部配置(敏感值自动打码)
|
|
45
|
+
chatenv cat
|
|
46
|
+
|
|
47
|
+
# 按类型过滤查看
|
|
48
|
+
chatenv cat -t feishu
|
|
49
|
+
|
|
50
|
+
# 设置 / 查看单项
|
|
51
|
+
chatenv set OPENAI_API_KEY=sk-xxx
|
|
52
|
+
chatenv get OPENAI_API_KEY
|
|
53
|
+
|
|
54
|
+
# 多配置 profile 管理
|
|
55
|
+
chatenv save work && chatenv use work
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Chat 对话 (`chattool.Chat`)
|
|
59
|
+
|
|
60
|
+
基于 OpenAI API 的对话对象,支持多轮对话、批量处理、异步并发和流式输出。
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from chattool import Chat
|
|
64
|
+
|
|
65
|
+
# 多轮对话
|
|
66
|
+
chat = Chat("Hello!")
|
|
67
|
+
resp = chat.get_response()
|
|
68
|
+
chat.user("How are you?")
|
|
69
|
+
chat.get_response()
|
|
70
|
+
chat.save("chat.json", mode="w")
|
|
71
|
+
|
|
72
|
+
# 异步并发
|
|
73
|
+
import asyncio
|
|
74
|
+
base = Chat().system("你是一个有用的助手")
|
|
75
|
+
tasks = [base.copy().user(f"主题 {i}").async_get_response() for i in range(5)]
|
|
76
|
+
responses = asyncio.run(asyncio.gather(*tasks))
|
|
77
|
+
|
|
78
|
+
# 流式输出
|
|
79
|
+
async for chunk in Chat().user("写一首诗").async_get_response_stream():
|
|
80
|
+
if chunk.delta_content:
|
|
81
|
+
print(chunk.delta_content, end="", flush=True)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. 飞书/Lark 机器人 (`chattool lark`)
|
|
85
|
+
|
|
86
|
+
一行命令发消息、启动 Echo/AI 机器人,支持文本、图片、文件、富文本等消息类型。
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 发送消息
|
|
90
|
+
chattool lark send -r USER_ID -m "Hello"
|
|
91
|
+
chattool lark send -r USER_ID --image photo.png
|
|
92
|
+
chattool lark send -r USER_ID --file report.pdf
|
|
93
|
+
|
|
94
|
+
# 启动 Echo 机器人(WebSocket)
|
|
95
|
+
chattool serve lark echo
|
|
96
|
+
|
|
97
|
+
# 启动 AI 对话机器人
|
|
98
|
+
chattool serve lark ai --model gpt-4o
|
|
99
|
+
|
|
100
|
+
# 查看机器人信息和权限
|
|
101
|
+
chattool lark info
|
|
102
|
+
chattool lark scopes
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from chattool.tools.lark import LarkBot
|
|
107
|
+
|
|
108
|
+
bot = LarkBot()
|
|
109
|
+
bot.send_text("ou_xxx", "open_id", "Hello!")
|
|
110
|
+
bot.send_image_file("ou_xxx", "open_id", "photo.png")
|
|
111
|
+
|
|
112
|
+
@bot.on_message
|
|
113
|
+
def handle(ctx):
|
|
114
|
+
ctx.reply_text(f"收到: {ctx.text}")
|
|
115
|
+
|
|
116
|
+
bot.start()
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 4. DNS 管理 (`chattool dns`)
|
|
120
|
+
|
|
121
|
+
统一的 DNS 接口,支持阿里云和腾讯云,提供 DDNS 动态更新和 SSL 证书自动续期。
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 查询 / 设置 DNS 记录
|
|
125
|
+
chattool dns get test.example.com
|
|
126
|
+
chattool dns set test.example.com -v 1.2.3.4
|
|
127
|
+
|
|
128
|
+
# DDNS 动态域名 (公网 / 局域网)
|
|
129
|
+
chattool dns ddns -d example.com -r home --monitor
|
|
130
|
+
chattool dns ddns -d example.com -r nas --ip-type local --local-ip-cidr 192.168.1.0/24
|
|
131
|
+
|
|
132
|
+
# SSL 证书自动更新
|
|
133
|
+
chattool dns cert-update -d example.com -e admin@example.com --cert-dir ./certs
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 5. AI 绘图 (`chattool image`)
|
|
137
|
+
|
|
138
|
+
支持 Tongyi、Hugging Face、LiblibAI、Pollinations.ai、SiliconFlow 等平台。
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# 安装图像依赖
|
|
142
|
+
pip install "chattool[images]"
|
|
143
|
+
|
|
144
|
+
# Pollinations(需配置 POLLINATIONS_API_KEY)
|
|
145
|
+
chattool image pollinations list-models
|
|
146
|
+
chattool image pollinations generate "a cat in space" -o cat.png
|
|
147
|
+
|
|
148
|
+
# SiliconFlow(需配置 SILICONFLOW_API_KEY)
|
|
149
|
+
chattool image siliconflow list-models
|
|
150
|
+
chattool image siliconflow generate "a cute dog" -o dog.png
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 6. 其他工具
|
|
154
|
+
|
|
155
|
+
| 工具 | 命令 | 说明 |
|
|
156
|
+
|------|------|------|
|
|
157
|
+
| 网络扫描 | `chattool network scan` | 扫描局域网活跃主机和 SSH 端口 |
|
|
158
|
+
| MCP 服务 | `chattool mcp info` / `chattool mcp inspect` | MCP Server 能力检查(支持 JSON 输出) |
|
|
159
|
+
| 截图服务 | `chattool serve capture` | 本地网页截图服务 |
|
|
160
|
+
| 证书分发 | `chattool serve cert` / `chattool client cert` | SSL 证书集中管理与客户端拉取 |
|
|
161
|
+
| Skills 管理 | `chattool skill install` / `chatskill install` | 安装 ChatTool skills 到 Codex / Claude Code |
|
|
162
|
+
|
|
163
|
+
## 开源协议
|
|
164
|
+
|
|
165
|
+
MIT License
|
|
166
|
+
|
|
167
|
+
## 更新日志
|
|
168
|
+
|
|
169
|
+
- `5.3.0` — 飞书机器人(消息收发、事件路由、AI 对话)、CLI 工具链(`chattool lark`、`chattool serve lark`)
|
|
170
|
+
- `5.0.0` — DNS 管理(阿里云/腾讯云)、DDNS、SSL 证书自动续期、环境变量集中管理
|
|
171
|
+
- `4.1.0` — 统一 `Chat` API(同步/异步/流式),默认环境变量配置
|
|
172
|
+
- 更早版本请参考仓库提交记录
|
|
@@ -25,6 +25,7 @@ keywords = ["chattool"]
|
|
|
25
25
|
license = {text = "MIT license"}
|
|
26
26
|
dependencies = [
|
|
27
27
|
"Click>=7.0",
|
|
28
|
+
"questionary>=2.1.0",
|
|
28
29
|
"requests>=2.20",
|
|
29
30
|
"aiohttp>=3.8",
|
|
30
31
|
"tqdm>=4.60",
|
|
@@ -45,11 +46,26 @@ dependencies = [
|
|
|
45
46
|
]
|
|
46
47
|
|
|
47
48
|
[project.optional-dependencies]
|
|
48
|
-
|
|
49
|
+
dns = [
|
|
50
|
+
"netifaces",
|
|
49
51
|
"alibabacloud_alidns20150109>=3.5.10",
|
|
50
52
|
"alibabacloud_tea_openapi>=0.3.0",
|
|
51
53
|
"tencentcloud-sdk-python",
|
|
52
|
-
|
|
54
|
+
]
|
|
55
|
+
lark = [
|
|
56
|
+
"lark-oapi==1.5.3",
|
|
57
|
+
"flask",
|
|
58
|
+
]
|
|
59
|
+
images = [
|
|
60
|
+
"dashscope"
|
|
61
|
+
]
|
|
62
|
+
screenshot = [
|
|
63
|
+
"selenium",
|
|
64
|
+
"pillow",
|
|
65
|
+
"imageio"
|
|
66
|
+
]
|
|
67
|
+
tools = [
|
|
68
|
+
"chattool[dns, lark, images, screenshot]",
|
|
53
69
|
]
|
|
54
70
|
tests = [
|
|
55
71
|
"coverage",
|
|
@@ -72,7 +88,6 @@ dev = [
|
|
|
72
88
|
"twine",
|
|
73
89
|
"chattool[docs,tests,tools]",
|
|
74
90
|
]
|
|
75
|
-
|
|
76
91
|
[project.urls]
|
|
77
92
|
Homepage = "https://github.com/cubenlp/chattool"
|
|
78
93
|
Repository = "https://github.com/cubenlp/chattool"
|
|
@@ -81,6 +96,7 @@ Repository = "https://github.com/cubenlp/chattool"
|
|
|
81
96
|
chattool = "chattool.cli:main_cli"
|
|
82
97
|
chatenv = "chattool.cli.chatenv:cli"
|
|
83
98
|
mcp-server-chattool = "chattool.mcp:main"
|
|
99
|
+
chatskill = "chattool.cli.skill:main"
|
|
84
100
|
|
|
85
101
|
[tool.setuptools.dynamic]
|
|
86
102
|
version = {attr = "chattool.__version__"}
|
|
@@ -95,7 +111,8 @@ include-package-data = true
|
|
|
95
111
|
markers = [
|
|
96
112
|
"integration: mark test as integration test",
|
|
97
113
|
"dns: mark test as dns test",
|
|
98
|
-
"mcp: mark test as mcp test"
|
|
114
|
+
"mcp: mark test as mcp test",
|
|
115
|
+
"lark: mark test as lark test"
|
|
99
116
|
]
|
|
100
117
|
filterwarnings = [
|
|
101
118
|
"ignore::DeprecationWarning:alibabacloud_tea_openapi.*",
|
|
@@ -104,4 +121,3 @@ filterwarnings = [
|
|
|
104
121
|
"ignore:websockets.legacy is deprecated:DeprecationWarning",
|
|
105
122
|
"ignore:websockets.server.WebSocketServerProtocol is deprecated:DeprecationWarning"
|
|
106
123
|
]
|
|
107
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
__author__ = """Rex Wang"""
|
|
4
4
|
__email__ = '1073853456@qq.com'
|
|
5
|
-
__version__ = '5.
|
|
5
|
+
__version__ = '5.4.0'
|
|
6
6
|
|
|
7
7
|
from dotenv import load_dotenv
|
|
8
8
|
|
|
@@ -14,6 +14,7 @@ from .utils import (
|
|
|
14
14
|
)
|
|
15
15
|
from .const import CHATTOOL_REPO_DIR
|
|
16
16
|
from .config import OpenAIConfig, AzureConfig, AliyunConfig, TencentConfig, ZulipConfig
|
|
17
|
+
from .tools import LarkBot, AliyunDNSClient, TencentDNSClient, DynamicIPUpdater, SSLCertUpdater
|
|
17
18
|
|
|
18
19
|
setup_jupyter_async()
|
|
19
20
|
load_dotenv(CHATTOOL_REPO_DIR / '.env')
|
|
@@ -34,4 +35,9 @@ __all__ = [
|
|
|
34
35
|
"AliyunConfig",
|
|
35
36
|
"TencentConfig",
|
|
36
37
|
"ZulipConfig",
|
|
37
|
-
|
|
38
|
+
"LarkBot",
|
|
39
|
+
"AliyunDNSClient",
|
|
40
|
+
"TencentDNSClient",
|
|
41
|
+
"DynamicIPUpdater",
|
|
42
|
+
"SSLCertUpdater",
|
|
43
|
+
]
|