feat(api): add health check and models endpoints with documentation
- Add /health endpoint to check service status for orchestration systems - Add /models endpoint with OpenAI API compatible format - Document new endpoints in both English and Chinese API docs - Include example usage and response formats in documentation - Add comprehensive test coverage for health and models endpoints - Refactor model storage to include type information alongside instance - Move model ID and type methods to WhichModel implementation - Update API calls to access model instance through stored wrapper
This commit is contained in:
@@ -57,6 +57,92 @@ Content-Type: application/json
|
||||
|
||||
## 端点
|
||||
|
||||
### 健康检查
|
||||
|
||||
检查服务健康状态。此端点适用于容器编排(Kubernetes)、负载均衡器和监控系统。
|
||||
|
||||
#### 端点
|
||||
```
|
||||
GET /health
|
||||
```
|
||||
|
||||
#### 响应
|
||||
|
||||
**健康 (HTTP 200):**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "ok"
|
||||
}
|
||||
```
|
||||
|
||||
**不健康 (HTTP 503):**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "unhealthy",
|
||||
"error": "model not initialized"
|
||||
}
|
||||
```
|
||||
|
||||
#### 示例
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:10100/health
|
||||
```
|
||||
|
||||
### 模型列表
|
||||
|
||||
获取当前加载的模型信息(OpenAI API 兼容格式)。
|
||||
|
||||
#### 端点
|
||||
```
|
||||
GET /models
|
||||
```
|
||||
|
||||
#### 响应
|
||||
|
||||
**成功 (HTTP 200):**
|
||||
|
||||
```json
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "qwen3-0.6b",
|
||||
"object": "model",
|
||||
"created": null,
|
||||
"owned_by": "Qwen"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**未初始化 (HTTP 503):**
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "model not initialized"
|
||||
}
|
||||
```
|
||||
|
||||
#### 字段
|
||||
|
||||
| 字段 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `object` | string | 固定值:"list" |
|
||||
| `data` | array | 模型对象数组(当前仅包含一个已加载的模型) |
|
||||
| `id` | string | 模型标识符(kebab-case,如 "qwen3-0.6b") |
|
||||
| `object` | string | 固定值:"model" |
|
||||
| `created` | integer\|null | Unix 时间戳(当前为 null) |
|
||||
| `owned_by` | string | 模型所有者/组织名称 |
|
||||
|
||||
#### 示例
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:10100/models
|
||||
```
|
||||
|
||||
### 对话补全
|
||||
|
||||
生成对话补全或文本响应。
|
||||
|
||||
Reference in New Issue
Block a user