基于 @receptron/laya 的 ONNX 推理服务 — 结构化问答引擎
| GET | /health |
健康检查 |
| GET | /test |
内置测试用例 |
| POST | /system_one |
主推理接口 |
# 健康检查 curl https://168.110.14.163:3000/health # 主接口调用 curl -X POST https://168.110.14.163:3000/system_one \ -H "Content-Type: application/json" \ -d '{ "state": { "subject": "Refund not received", "body": "I cancelled my order two weeks ago and still have no refund." }, "questions": { "department": { "type": "choice", "instructions": "Which team should handle this ticket?", "criteria": { "billing": "payments, refunds and invoices", "support": "product help and bugs", "sales": "new purchases" } }, "urgency": { "type": "score", "instructions": "How urgent is this ticket?", "criteria": ["not urgent", "somewhat urgent", "urgent", "critical"] }, "churn_risk": { "type": "noul", "instructions": "Is the customer likely to cancel?" } } }'
const response = await fetch("/api/system_one", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ state: { subject: "...", body: "..." }, questions: { category: { type: "choice", instructions: "...", criteria: { a: "...", b: "..." } } } }) }); const result = await response.json();
choice — 单选分类,criteria 为对象 {key: description}
score — 评分(0-N),criteria 为数组 [label0, label1, ...]
noul — 二分类(是/否),输出 0~1 概率值
Laya 是由 Receptron 开发的轻量级结构化问答模型。 它基于 ONNX Runtime 运行,可以在 CPU 上高效推理,无需 GPU。
与传统的 LLM 不同,Laya 专注于 system_one 类型的结构化分析任务:
模型大小: ~500MB ONNX | 推理方式: CPU | 框架: onnxruntime-node
┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
│ 前端页面 │────▶│ Cloudflare │────▶│ Laya API │
│ (本页面) │ │ Worker (代理) │ │ (服务器) │
└─────────────┘ └──────────────────┘ └─────────────┘
laya.matt.sarl CF Edge 168.110.14.163:3000