Metadata-Version: 2.4
Name: llm-toolforge
Version: 0.7.0
Summary: LLM工具调用框架，同时提供 HTTP API 和 MCP Server 两种接入方式
License: MIT License
        
        Copyright (c) 2026 kuon
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.139.2
Requires-Dist: uvicorn>=0.29.0
Requires-Dist: aiofiles
Requires-Dist: pydantic>=2.0
Requires-Dist: loguru
Requires-Dist: pyyaml
Requires-Dist: ruamel.yaml
Requires-Dist: mcp[cli]>=1.28.1
Requires-Dist: starlette>=1.3.1
Requires-Dist: tzdata
Requires-Dist: psutil
Requires-Dist: aiomysql
Requires-Dist: PyMySQL
Requires-Dist: aiosqlite
Requires-Dist: redis==6.2.0
Requires-Dist: oss2
Requires-Dist: cos-python-sdk-v5
Requires-Dist: boto3
Provides-Extra: mysql
Provides-Extra: sqlite
Provides-Extra: redis
Provides-Extra: all
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.23; extra == "test"
Requires-Dist: httpx>=0.27; extra == "test"
Dynamic: license-file

# llm-toolforge

用于大模型工具调用的框架，同时提供 **HTTP API**（同步、流式、异步）和**MCP Server**两种接入方式。
---

## 安装

任选一种方式安装：

### 从 PyPI 安装（推荐）
```bash
pip install llm-toolforge
```

### 从源码安装（开发）
```bash
pip install -e .
```

### 验证
```
toolforge --help
```


## 使用

### 从零开始
1. 创建项目
```bash
toolforge new project my-app   # 创建 ./my-app/ 并生成项目初始文件
# 或者
toolforge new project .        # 在当前目录初始化项目（目录已存在时使用）
```
2. 创建工具
```bash
toolforge new tool <name> 
```
默认工具代码是获取当前时间，可以根据示例代码进行修改。详细说明见[工具开发指南](docs/plugin-authoring.md)

3. 编辑配置文件
配置文件位于项目根目录下的 `config.yaml`，默认配置即可运行。各字段含义见文件内注释。

4. 启动
在项目根目录执行，可以在页面`http://localhost:12345`进行测试。
```bash
toolforge run 
```

### 使用示例工程

1. 安装环境
```bash
cd examples
pip install -r requirements.txt
```

2. 编辑 `config.yaml`，按注释填写配置

3. 运行
```bash
toolforge run
```
打开页面`http://localhost:12345`进行测试。



## 部署

`toolforge new project` 会在项目目录下生成 `Dockerfile`

```bash
docker build -t llm-toolforge-example:v0.1.0 .

docker run --rm \
  -v "$(pwd)/config.yaml:/app/config.yaml" \
  -e SERVICE_NAME=llm-toolforge-example \
  -p 12345:12345 \
  -p 12346:12346 \ 
  llm-toolforge-example:v0.1.0
```

## 运行自动化测试

参与框架开发时，先在项目根目录安装源码及测试依赖：
```bash
python -m pip install -e ".[test]"
```
以后每次修改代码后，在项目根目录运行：
```bash
python -m pytest
```


## 环境变量

少量字段可由环境变量覆盖（**优先级高于 `config.yaml`**）：

| 变量 | 覆盖字段 |
|---|---|
| `SERVICE_NAME` | `service.name` |
| `SERVICE_VERSION` | `service.version` |

K8s 多实例部署时推荐通过 Deployment 注入 `SERVICE_NAME`，避免镜像里写死。

---
