llm-toolforge 0.3.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.
Files changed (29) hide show
  1. llm_toolforge-0.3.0/LICENSE +21 -0
  2. llm_toolforge-0.3.0/PKG-INFO +195 -0
  3. llm_toolforge-0.3.0/README.md +137 -0
  4. llm_toolforge-0.3.0/pyproject.toml +51 -0
  5. llm_toolforge-0.3.0/setup.cfg +4 -0
  6. llm_toolforge-0.3.0/src/llm_toolforge/__init__.py +47 -0
  7. llm_toolforge-0.3.0/src/llm_toolforge/cli.py +403 -0
  8. llm_toolforge-0.3.0/src/llm_toolforge/config.py +88 -0
  9. llm_toolforge-0.3.0/src/llm_toolforge/core/__init__.py +11 -0
  10. llm_toolforge-0.3.0/src/llm_toolforge/core/ai_client.py +670 -0
  11. llm_toolforge-0.3.0/src/llm_toolforge/core/base.py +120 -0
  12. llm_toolforge-0.3.0/src/llm_toolforge/core/load_monitor.py +269 -0
  13. llm_toolforge-0.3.0/src/llm_toolforge/core/log_store.py +1125 -0
  14. llm_toolforge-0.3.0/src/llm_toolforge/core/oss_client.py +146 -0
  15. llm_toolforge-0.3.0/src/llm_toolforge/core/redis_client.py +220 -0
  16. llm_toolforge-0.3.0/src/llm_toolforge/discovery.py +94 -0
  17. llm_toolforge-0.3.0/src/llm_toolforge/fonts/NotoSansSC-Regular.ttf +0 -0
  18. llm_toolforge-0.3.0/src/llm_toolforge/server/__init__.py +1 -0
  19. llm_toolforge-0.3.0/src/llm_toolforge/server/api.py +653 -0
  20. llm_toolforge-0.3.0/src/llm_toolforge/server/mcp_server.py +223 -0
  21. llm_toolforge-0.3.0/src/llm_toolforge/server/runner.py +107 -0
  22. llm_toolforge-0.3.0/src/llm_toolforge/static/favicon.ico +0 -0
  23. llm_toolforge-0.3.0/src/llm_toolforge/static/index.html +3116 -0
  24. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/PKG-INFO +195 -0
  25. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/SOURCES.txt +27 -0
  26. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/dependency_links.txt +1 -0
  27. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/entry_points.txt +2 -0
  28. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/requires.txt +36 -0
  29. llm_toolforge-0.3.0/src/llm_toolforge.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kuon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-toolforge
3
+ Version: 0.3.0
4
+ Summary: LLM工具调用框架,同时提供 HTTP API 和 MCP Server 两种接入方式
5
+ License: MIT License
6
+
7
+ Copyright (c) 2026 kuon
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: fastapi
31
+ Requires-Dist: uvicorn
32
+ Requires-Dist: aiofiles
33
+ Requires-Dist: pydantic
34
+ Requires-Dist: loguru
35
+ Requires-Dist: pyyaml
36
+ Requires-Dist: mcp[cli]
37
+ Requires-Dist: tzdata
38
+ Provides-Extra: ai
39
+ Requires-Dist: openai; extra == "ai"
40
+ Requires-Dist: volcengine-python-sdk[ark]; extra == "ai"
41
+ Provides-Extra: aliyun
42
+ Requires-Dist: oss2; extra == "aliyun"
43
+ Provides-Extra: tencent
44
+ Requires-Dist: cos-python-sdk-v5; extra == "tencent"
45
+ Provides-Extra: mysql
46
+ Requires-Dist: aiomysql; extra == "mysql"
47
+ Provides-Extra: sqlite
48
+ Requires-Dist: aiosqlite; extra == "sqlite"
49
+ Provides-Extra: redis
50
+ Requires-Dist: redis>=5.0; extra == "redis"
51
+ Provides-Extra: all-storage
52
+ Requires-Dist: llm-toolforge[aliyun,tencent]; extra == "all-storage"
53
+ Provides-Extra: all-infra
54
+ Requires-Dist: llm-toolforge[mysql,redis,sqlite]; extra == "all-infra"
55
+ Provides-Extra: all
56
+ Requires-Dist: llm-toolforge[ai,all-infra,all-storage]; extra == "all"
57
+ Dynamic: license-file
58
+
59
+ # llm-toolforge
60
+
61
+ 用语大模型的工具的框架,同时提供 **HTTP API**(FastAPI)和 **MCP Server**(SSE transport)两种接入方式。
62
+
63
+ ---
64
+
65
+ ## 快速开始
66
+
67
+ ### 安装框架
68
+
69
+ ```bash
70
+ pip install llm-toolforge[all]
71
+
72
+ # 如果是克隆的代码安装,则在根目录执行
73
+ pip install -e ".[all]"
74
+
75
+ # 验证
76
+ toolforge --help
77
+ ```
78
+
79
+ ### 安装示例工具环境
80
+ ```bash
81
+ cd examples
82
+ pip install -r requirements.txt
83
+ ```
84
+
85
+ * 编辑示例工具的配置文件
86
+ ```
87
+ cp config.example.yaml config.yaml
88
+ # 根据注释填写配置即可
89
+ ```
90
+
91
+ * 运行:
92
+ ```bash
93
+ toolforge run
94
+ ```
95
+ 打开页面`http://localhost:12345`进行测试。
96
+
97
+ ### 部署
98
+
99
+ `toolforge new project` 会在项目目录下生成 `Dockerfile`
100
+
101
+ ```bash
102
+ docker build -t llm-toolforge-example:v0.1.0 .
103
+
104
+ docker run --rm \
105
+ -v "$(pwd)/config.yaml:/app/config.yaml" \
106
+ -e SERVICE_NAME=my-toolset \
107
+ -p 12345:12345 \
108
+ -p 12346:12346 \
109
+ llm-toolforge-example:v0.1.0
110
+ ```
111
+
112
+ 同一套基础设施(Redis / MySQL)跑多个 toolset 时,**必须**为每个 Deployment 设置唯一的 `SERVICE_NAME`,否则日志、统计、心跳会串在一起。
113
+
114
+ **优先级:环境变量 > config.yaml**,两者都缺失时启动直接报错。
115
+
116
+ **方式 1(推荐):环境变量**
117
+
118
+ ```yaml
119
+ env:
120
+ - name: SERVICE_NAME
121
+ value: my-toolset
122
+ - name: SERVICE_VERSION
123
+ value: v1.0.0
124
+ ```
125
+
126
+ **方式 2:config.yaml**
127
+
128
+ ```yaml
129
+ service:
130
+ name: my-toolset
131
+ version: v1.0.0
132
+ ```
133
+
134
+
135
+
136
+ ## 框架安装说明
137
+
138
+ 命令`llm-toolforge[all]`将会安装包含的所以组件
139
+ ```bash
140
+ pip install llm-toolforge[all]
141
+ ```
142
+ 如果想指定组件,可以先安装基础核心
143
+ ```bash
144
+ pip install llm-toolforge
145
+ ```
146
+ 然后根据需要安装下列依赖
147
+ ```bash
148
+ # 日志后端(与 config.yaml 的 logging.storage 对应)
149
+ pip install llm-toolforge[mysql] # MySQL
150
+ pip install llm-toolforge[sqlite] # SQLite
151
+ pip install llm-toolforge[redis] # Redis(心跳 / 实时流 / 统计缓存)
152
+
153
+ # AI 模型渠道
154
+ pip install llm-toolforge[ai] # 所有支持的 AI 渠道(OpenAI / 豆包 /千问)
155
+
156
+ # 对象存储(工具上传文件时用)
157
+ pip install llm-toolforge[aliyun] # 阿里云 OSS
158
+ pip install llm-toolforge[tencent] # 腾讯云 COS
159
+ ```
160
+
161
+ ## 框架命令
162
+
163
+ ```bash
164
+ toolforge run # 启动 HTTP API + MCP 服务
165
+ toolforge run --api-only # 只起 HTTP API
166
+ toolforge run --mcp-only # 只起 MCP SSE
167
+ toolforge list # 列出已发现的工具
168
+ toolforge new project . # 初始化项目
169
+ toolforge new tool <name> # 生成工具骨架
170
+ ```
171
+
172
+
173
+ ---
174
+
175
+ ## 文档
176
+
177
+ | 文档 | 内容 |
178
+ |---|---|
179
+ | [工具开发指南](docs/plugin-authoring.md) | 从零创建工具 + Generator / Plugin / InputField 完整说明 |
180
+ | [接口参考](docs/api-reference.md) | HTTP API / MCP 协议 |
181
+ | [部署指南](docs/deployment.md) | Docker / K8s / 多实例 |
182
+ | [运行观测](docs/observability.md) | 日志 / 统计 / 负载监控 / 并发调优 |
183
+
184
+ ## 环境变量
185
+
186
+ 少量字段可由环境变量覆盖(**优先级高于 `config.yaml`**):
187
+
188
+ | 变量 | 覆盖字段 |
189
+ |---|---|
190
+ | `SERVICE_NAME` | `service.name` |
191
+ | `SERVICE_VERSION` | `service.version` |
192
+
193
+ K8s 多实例部署时推荐通过 Deployment 注入 `SERVICE_NAME`,避免镜像里写死。
194
+
195
+ ---
@@ -0,0 +1,137 @@
1
+ # llm-toolforge
2
+
3
+ 用语大模型的工具的框架,同时提供 **HTTP API**(FastAPI)和 **MCP Server**(SSE transport)两种接入方式。
4
+
5
+ ---
6
+
7
+ ## 快速开始
8
+
9
+ ### 安装框架
10
+
11
+ ```bash
12
+ pip install llm-toolforge[all]
13
+
14
+ # 如果是克隆的代码安装,则在根目录执行
15
+ pip install -e ".[all]"
16
+
17
+ # 验证
18
+ toolforge --help
19
+ ```
20
+
21
+ ### 安装示例工具环境
22
+ ```bash
23
+ cd examples
24
+ pip install -r requirements.txt
25
+ ```
26
+
27
+ * 编辑示例工具的配置文件
28
+ ```
29
+ cp config.example.yaml config.yaml
30
+ # 根据注释填写配置即可
31
+ ```
32
+
33
+ * 运行:
34
+ ```bash
35
+ toolforge run
36
+ ```
37
+ 打开页面`http://localhost:12345`进行测试。
38
+
39
+ ### 部署
40
+
41
+ `toolforge new project` 会在项目目录下生成 `Dockerfile`
42
+
43
+ ```bash
44
+ docker build -t llm-toolforge-example:v0.1.0 .
45
+
46
+ docker run --rm \
47
+ -v "$(pwd)/config.yaml:/app/config.yaml" \
48
+ -e SERVICE_NAME=my-toolset \
49
+ -p 12345:12345 \
50
+ -p 12346:12346 \
51
+ llm-toolforge-example:v0.1.0
52
+ ```
53
+
54
+ 同一套基础设施(Redis / MySQL)跑多个 toolset 时,**必须**为每个 Deployment 设置唯一的 `SERVICE_NAME`,否则日志、统计、心跳会串在一起。
55
+
56
+ **优先级:环境变量 > config.yaml**,两者都缺失时启动直接报错。
57
+
58
+ **方式 1(推荐):环境变量**
59
+
60
+ ```yaml
61
+ env:
62
+ - name: SERVICE_NAME
63
+ value: my-toolset
64
+ - name: SERVICE_VERSION
65
+ value: v1.0.0
66
+ ```
67
+
68
+ **方式 2:config.yaml**
69
+
70
+ ```yaml
71
+ service:
72
+ name: my-toolset
73
+ version: v1.0.0
74
+ ```
75
+
76
+
77
+
78
+ ## 框架安装说明
79
+
80
+ 命令`llm-toolforge[all]`将会安装包含的所以组件
81
+ ```bash
82
+ pip install llm-toolforge[all]
83
+ ```
84
+ 如果想指定组件,可以先安装基础核心
85
+ ```bash
86
+ pip install llm-toolforge
87
+ ```
88
+ 然后根据需要安装下列依赖
89
+ ```bash
90
+ # 日志后端(与 config.yaml 的 logging.storage 对应)
91
+ pip install llm-toolforge[mysql] # MySQL
92
+ pip install llm-toolforge[sqlite] # SQLite
93
+ pip install llm-toolforge[redis] # Redis(心跳 / 实时流 / 统计缓存)
94
+
95
+ # AI 模型渠道
96
+ pip install llm-toolforge[ai] # 所有支持的 AI 渠道(OpenAI / 豆包 /千问)
97
+
98
+ # 对象存储(工具上传文件时用)
99
+ pip install llm-toolforge[aliyun] # 阿里云 OSS
100
+ pip install llm-toolforge[tencent] # 腾讯云 COS
101
+ ```
102
+
103
+ ## 框架命令
104
+
105
+ ```bash
106
+ toolforge run # 启动 HTTP API + MCP 服务
107
+ toolforge run --api-only # 只起 HTTP API
108
+ toolforge run --mcp-only # 只起 MCP SSE
109
+ toolforge list # 列出已发现的工具
110
+ toolforge new project . # 初始化项目
111
+ toolforge new tool <name> # 生成工具骨架
112
+ ```
113
+
114
+
115
+ ---
116
+
117
+ ## 文档
118
+
119
+ | 文档 | 内容 |
120
+ |---|---|
121
+ | [工具开发指南](docs/plugin-authoring.md) | 从零创建工具 + Generator / Plugin / InputField 完整说明 |
122
+ | [接口参考](docs/api-reference.md) | HTTP API / MCP 协议 |
123
+ | [部署指南](docs/deployment.md) | Docker / K8s / 多实例 |
124
+ | [运行观测](docs/observability.md) | 日志 / 统计 / 负载监控 / 并发调优 |
125
+
126
+ ## 环境变量
127
+
128
+ 少量字段可由环境变量覆盖(**优先级高于 `config.yaml`**):
129
+
130
+ | 变量 | 覆盖字段 |
131
+ |---|---|
132
+ | `SERVICE_NAME` | `service.name` |
133
+ | `SERVICE_VERSION` | `service.version` |
134
+
135
+ K8s 多实例部署时推荐通过 Deployment 注入 `SERVICE_NAME`,避免镜像里写死。
136
+
137
+ ---
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "llm-toolforge"
7
+ version = "0.3.0"
8
+ description = "LLM工具调用框架,同时提供 HTTP API 和 MCP Server 两种接入方式"
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "fastapi",
14
+ "uvicorn",
15
+ "aiofiles",
16
+ "pydantic",
17
+ "loguru",
18
+ "pyyaml",
19
+ "mcp[cli]",
20
+ "tzdata",
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ # AI 模型渠道(按需安装)
25
+ ai = ["openai", "volcengine-python-sdk[ark]"]
26
+ # 对象存储(按需安装)
27
+ aliyun = ["oss2"]
28
+ tencent = ["cos-python-sdk-v5"]
29
+ # 日志后端(按需安装,与 config.yaml 里的 mysql/sqlite/redis 配置对应)
30
+ mysql = ["aiomysql"]
31
+ sqlite = ["aiosqlite"]
32
+ redis = ["redis>=5.0"]
33
+ # 常用组合
34
+ all-storage = ["llm-toolforge[aliyun,tencent]"]
35
+ all-infra = ["llm-toolforge[mysql,sqlite,redis]"]
36
+ all = ["llm-toolforge[ai,all-storage,all-infra]"]
37
+
38
+ [project.scripts]
39
+ toolforge = "llm_toolforge.cli:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+ include = ["llm_toolforge*"]
44
+ exclude = ["llm_toolforge.templates*"] # templates 是文本资源,通过 package_data 包含
45
+
46
+ [tool.setuptools.package-data]
47
+ llm_toolforge = [
48
+ "static/**/*",
49
+ "fonts/**/*",
50
+ "templates/**/*",
51
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ """
2
+ llm-toolforge
3
+
4
+ 工具开发只需从这里导入:
5
+
6
+ from llm_toolforge import (
7
+ Plugin, InputField, BaseGenerator,
8
+ GenerateResult, GenerateProgress, ResultStatus,
9
+ LLMServiceError, UploadError,
10
+ AIClient, OSSClient,
11
+ load_tool_config,
12
+ )
13
+ """
14
+
15
+ from .core.base import (
16
+ BaseGenerator,
17
+ GenerateProgress,
18
+ GenerateResult,
19
+ GeneratorError,
20
+ InputField,
21
+ LLMServiceError,
22
+ Plugin,
23
+ ResultStatus,
24
+ UploadError,
25
+ )
26
+ from .core.ai_client import AIClient
27
+ from .core.oss_client import OSSClient
28
+ from .config import load_tool_config, load_config, find_config
29
+ from .discovery import discover_plugins
30
+
31
+ __all__ = [
32
+ "Plugin",
33
+ "BaseGenerator",
34
+ "InputField",
35
+ "GenerateResult",
36
+ "GenerateProgress",
37
+ "ResultStatus",
38
+ "GeneratorError",
39
+ "LLMServiceError",
40
+ "UploadError",
41
+ "AIClient",
42
+ "OSSClient",
43
+ "load_tool_config",
44
+ "load_config",
45
+ "find_config",
46
+ "discover_plugins",
47
+ ]