有什么想问的?
关于公路治超的任何问题 — 法规、技术标准、执法流程、政策文件,都可以从这里查询。
嵌入知识库到你的系统
复制下方代码到任意网页中,即可在页面右下角获得治超知识库问答浮窗。
嵌入代码
将以下 <script> 标签粘贴到 HTML 的 </body> 之前即可。
常用问题
有两种方式设置常用问题:
- 推荐:在浮窗内设置 — 展开浮窗后,点击标题栏右侧的齿轮图标,可以自由增删常用问题。设置会自动保存在当前网站,下次打开仍然有效。
- 预设默认值 — 在嵌入代码中加
data-presets属性,用|分隔问题。用户在浮窗里修改后会覆盖此默认值。
效果预览
加载后页面右下角出现绿色按钮,点击展开问答浮窗。标题栏右侧有齿轮图标可配置常用问题:
浮窗标题栏 → 齿轮按钮 → 设置常用问题
自定义配置
嵌入脚本自动从 <script> 标签地址识别服务端 URL。修改域名和端口即可指向你的服务。
API 接入文档
通过 HTTP API 将知识库问答能力集成到你的系统中。Base URL:http://localhost:8888
POST /api/public/query
知识库问答(LLM + RAG)。面向外部用户,内置速率限制(5 次/分钟/IP)、每日配额(10 次/天/IP)、成本熔断(全局 500 次/天后降级为纯搜索)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
query | string | 是 | 用户问题 |
top_k | int | 否 | 返回的匹配文档数量,默认 5。越大召回越全,但 LLM 上下文消耗越大 |
请求示例
curl -X POST http://localhost:8888/api/public/query \
-H "Content-Type: application/json" \
-d '{"query":"六轴车超限标准","top_k":5}'成功响应
{
"query": "六轴车超限标准",
"answer": "根据 GB1589-2016,六轴汽车列车最大允许总质量限值为 49000 千克...",
"sources": [
{
"name": "GB1589-2016",
"type": "entity",
"summary": "汽车、挂车及汽车列车外廓尺寸、轴荷及质量限值",
"filepath": "...",
"tags": ["标准", "限值"],
"relations": [...]
}
],
"source_count": 1,
"remaining": 9
}| 字段 | 类型 | 说明 |
|---|---|---|
query | string | 原始问题 |
answer | string | LLM 生成的回答 |
sources | array | 引用的知识库来源列表 |
sources[].name | string | 来源名称 |
sources[].type | string | 类型:entity / concept / source / decision |
sources[].summary | string | 来源摘要 |
source_count | int | 来源数量 |
remaining | int | 当前 IP 剩余查询次数 |
mode | string | "search_only" 表示熔断降级模式(仅搜索,无 LLM),正常模式不返回此字段 |
错误响应
| 状态码 | 说明 |
|---|---|
| 400 | query 为空 |
| 403 | 今日查询次数已用完 |
| 429 | 请求过于频繁,请稍后再试 |
GET /api/public/quota
查询当前 IP 的每日剩余查询次数。无请求参数。
请求示例
curl http://localhost:8888/api/public/quota响应示例
{
"remaining": 9,
"total": 10
}| 字段 | 类型 | 说明 |
|---|---|---|
remaining | int | 当前 IP 今日剩余次数 |
total | int | 每日配额上限 |
GET /api/public/stats
全局用量统计,用于监控整体健康状态。无请求参数。
请求示例
curl http://localhost:8888/api/public/stats响应示例
{
"global_daily": 47,
"global_limit": 500,
"circuit_breaker": false,
"active_ips_today": 12,
"daily_quota_per_ip": 10
}| 字段 | 类型 | 说明 |
|---|---|---|
global_daily | int | 当日全局 LLM 调用次数 |
global_limit | int | 熔断阈值 |
circuit_breaker | bool | 是否已触发熔断 |
active_ips_today | int | 当日活跃 IP 数量 |
daily_quota_per_ip | int | 每 IP 每日配额 |
POST /api/query
LLM 智能问答(RAG)。内部接口,无速率限制和配额控制。也支持 GET 方式:/api/query?q=...&top_k=5
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
query | string | 是 | 用户问题 |
top_k | int | 否 | 返回的匹配文档数量,默认 5 |
请求示例
curl -X POST http://localhost:8888/api/query \
-H "Content-Type: application/json" \
-d '{"query":"车辆限重标准","top_k":5}'成功响应
{
"query": "车辆限重标准",
"answer": "根据 GB1589-2016...",
"sources": [
{
"name": "GB1589-2016",
"type": "entity",
"summary": "...",
"filepath": "...",
"tags": ["标准"],
"relations": [...]
}
],
"source_count": 1
}| 字段 | 类型 | 说明 |
|---|---|---|
query | string | 原始问题 |
answer | string | LLM 生成的回答(含 [[wikilink]] 引用) |
sources[] | object | 引用的知识库来源:name、type、summary、filepath、tags、relations |
source_count | int | 来源数量 |
GET 方式
curl "http://localhost:8888/api/query?q=车辆限重标准&top_k=5"POST /api/chat
TF-IDF 搜索引擎问答,不调用 LLM,直接返回匹配的文档列表。适合关键词检索、无需 AI 润色的场景。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
query | string | 是 | 搜索关键词或问题 |
top_k | int | 否 | 返回的匹配文档数量,默认 5 |
请求示例
curl -X POST http://localhost:8888/api/chat \
-H "Content-Type: application/json" \
-d '{"query":"非现场执法","top_k":3}'成功响应
{
"query": "非现场执法",
"results": [
{
"name": "非现场执法",
"type": "entity",
"summary": "通过技术监控设备自动采集...",
"score": 0.856,
"filepath": "1_working_工作区/wiki_百科/entities_实体/非现场执法.md",
"tags": ["执法", "技术监控"],
"relations": [
{"relation": "法律依据", "target": "交通运输行政执法程序规定", "description": "..."}
],
"content_preview": "非现场执法是指交通运输执法机构利用技术监控设备..."
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
query | string | 原始查询 |
results[] | array | 匹配文档列表,按相关度降序排列 |
results[].name | string | 文档名称 |
results[].type | string | 类型:entity / concept / source / decision / raw_input |
results[].summary | string | 文档摘要 |
results[].score | float | TF-IDF 余弦相似度得分(0~1) |
results[].filepath | string | 文档在知识库中的相对路径 |
results[].tags | array | 标签列表 |
results[].relations | array | 关联实体列表:relation、target、description |
results[].content_preview | string | 文档内容前 500 字 |
GET /api/search
关键词搜索(GET 方式),功能与 /api/chat 相同,响应格式一致。
请求参数(Query String)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
q | string | 是 | 搜索关键词 |
top_k | int | 否 | 返回的匹配文档数量,默认 5 |
请求示例
curl "http://localhost:8888/api/search?q=公路法&top_k=3"成功响应
响应格式与 POST /api/chat 相同。
GET /api/health
服务健康检查。无请求参数。
请求示例
curl http://localhost:8888/api/health成功响应
{
"status": "ok",
"documents": 113,
"relations": 297
}| 字段 | 类型 | 说明 |
|---|---|---|
status | string | 服务状态:"ok" 表示正常 |
documents | int | 已索引的文档总数 |
relations | int | 图谱中的实体数量 |