Files
model-eval-site/API.md
T

124 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 模型评测网站 API 文档
Base: `http://<IP>:16066`(端口 16066)。后台管理接口需先登录(session cookie)。
## 1. 接收提交(llm-speed-tester 一键发送)
`POST /api/submit`
Header: `Content-Type: application/json``X-Token: meval16066`
```bash
curl -X POST http://127.0.0.1:16066/api/submit \
-H "Content-Type: application/json" \
-H "X-Token: meval16066" \
-d '{
"account": "性能评测组", # 账号,不存在自动创建
"source_test_id": 25,
"source_site": "llm-speed-tester",
"provider": "openai",
"model": "nvidia/Qwen3.6-35B-A3B-NVFP4",
"hardware": "NVIDIA A100 80G x8", # 硬件/GPU 描述(随提交展示)
"test_name": "我的测试",
"summary": { "samples_ok":2, "samples_total":2, "avg_ttft_ms":180,
"avg_prefill_speed":320.5, "avg_decode_speed":88.2,
"avg_output_tokens":128, "avg_total_ms":2500,
"concurrency_levels":[1],
"by_length": {...}, "by_concurrency": {} },
"gen": {"context_lengths":[2048,8192], "max_tokens":128, "samples":2, "concurrency_levels":[1]},
"runs": []
}'
```
响应:
```json
{ "ok": true, "id": 22, "account_id": 2, "account": "性能评测组",
"model": "nvidia/Qwen3.6-35B-A3B-NVFP4",
"url": "/model.html?provider=openai&model=nvidia/Qwen3.6-35B-A3B-NVFP4" }
```
## 2. 后台登录
```bash
POST /api/admin/login {"username":"admin","password":"admin123"} # 成功后下发 session cookie
GET /api/admin/session # {"admin":true}
POST /api/admin/logout
```
## 3. 排行 / 统计 / 对比
```bash
# 模型速度排行(含硬件);models 可指定对比哪些(provider|model 逗号分隔)
GET /api/leaderboard?sort=avg_decode_speed&order=desc&limit=200
GET /api/leaderboard?models=openai|qwen3.5-plus,autodl|glm-5.3-flash
# sort 可选: avg_decode_speed / avg_prefill_speed / avg_ttft_ms / best_decode / cnt / accounts / last_tested
# 模型对比(默认全部模型);chart_metric: avg_decode_speed|avg_prefill_speed|avg_ttft_ms|best_decodechart_type: bar|line
GET /api/compare?models=openai|qwen3.5-plus,google|gemini-2.0-flash&chart_metric=avg_ttft_ms&chart_type=bar
GET /api/stats # 统计(模型/提交/账号/采样/能力测试数)
GET /api/health
```
## 4. 模型详情
```bash
GET /api/model?provider=openai&model=nvidia/Qwen3.6-35B-A3B-NVFP4
```
返回该模型全部提交(含账号、硬件)+ 按上下文长度聚合 + 折线图数据。
## 5. 提交(前台只读;增删改走后端)
```bash
GET /api/submissions?page=1&page_size=20&q=关键词&account_id=2&model=xxx&provider=xxx
GET /api/submissions/<id>
DELETE /api/submissions/<id> # 后台
PUT /api/submissions/<id>/hardware {"hardware":"NVIDIA A100"} # 后台,改硬件
GET /api/submissions/<id>/chart # 长度→速度折线图 PNG
```
## 6. 账号管理(后台)
```bash
GET /api/accounts
POST /api/accounts {"name":"xxx","remark":"yyy"}
PUT /api/accounts/<id> {"name":"xxx","remark":"yyy"}
DELETE /api/accounts/<id>
```
## 7. 模型能力测试(前台只读;内容后台编辑)
```bash
# 前台:只返回 status=1 启用的能力测试
GET /api/capabilities
# 后台:全部(含停用)+ 增删改
GET /api/admin/capabilities
POST /api/admin/capabilities
PUT /api/admin/capabilities/<id>
DELETE /api/admin/capabilities/<id>
# 能力测试对象:{name, category, icon, description, sort, status,
# items: [ {title, prompt, expect}, ... ]}
```
## 8. 演示数据(后台)
```bash
POST /api/seed-demo # 🎲 评测演示数据(含硬件)
POST /api/seed-capabilities # 🎲 能力测试演示数据
```
## 9. 其他
```bash
POST /api/chart # 图表代理(转发 data-chart-tool 16016,返回 PNG
```
## 错误
所有接口失败返回 `{"ok": false, "error": "..."}` + 对应 HTTP 状态码;
后台接口未登录返回 401。