🧠 Laya 模型测试客户端

基于 @receptron/laya 的 ONNX 推理服务 — 结构化问答引擎

示例:

State(输入状态)

Questions(问题定义)

结果

点击"发送请求"查看结果...

API 端点

GET /health 健康检查
GET /test 内置测试用例
POST /system_one 主推理接口

cURL 调用示例

# 健康检查
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?"
      }
    }
  }'

JavaScript 调用示例

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

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