Models Hub
API 参考聊天系列

TypeSafe Jev 结构化判断

通过 /v1/responses 调用 typesafe/jev,对一段文本或一份结构化状态同时提出多个判断、分类和评分问题,直接拿到机器可用的结果。

编辑此页

typesafe/jev 不生成自由文本,而是回答你事先定义好的问题:一次请求可以对同一份内容同时提出多个问题,每个问题返回一个数值判断、一个分类选项或一个等级评分。适合工单分流、内容审核预判、线索打分、规则辅助决策等需要把结果直接交给程序处理的场景。

接入方式

项目取值
接口POST https://modelsok.com/v1/responses
鉴权Authorization: Bearer <API Key>
模型名typesafe/jev
调用方式同步、非流式,一次请求返回完整 JSON

只支持非流式调用

不要发送 "stream": true,否则会直接返回 400。这个模型也不需要轮询任务,等待本次 HTTP 请求返回即可。

使用前请确认 API Key 所属分组已开放 typesafe/jev。API Key 只应保存在服务端(例如环境变量),不要写进浏览器或移动端代码。

请求体

{
  "model": "typesafe/jev",
  "input": {
    "state": "要评估的内容,可以是一段文本,也可以是一个 JSON 对象",
    "questions": {
      "<问题 ID>": {
        "type": "noul | choice | score",
        "instructions": "这个问题要判断什么",
        "criteria": "判断标准,格式随题型变化,见下表"
      }
    }
  }
}
字段必填说明
model是固定为 typesafe/jev
input.state是被评估的内容。常用字符串或 JSON 对象,也可以是数组或 null;不能是单独的数字或布尔值
input.questions是问题集合。键是你自己起的问题 ID,结果会用同一个键返回
questions.<ID>.type是题型:noul、choice 或 score
questions.<ID>.instructions是这道题的评估要求,建议写成一句清楚的话
questions.<ID>.criteria视题型判断标准,见下表

state 传对象时,可以把工单、订单、用户资料等上下文原样放进去,不需要先拼成字符串。

三种题型

题型criteria 写法返回什么
noul可省略;需要时写成对象,只能有 "true"、"false" 两个键,分别描述肯定与否定的标准noul:0 到 1 之间的数值,越接近 1 越倾向肯定
choice必填对象,键是选项 ID,值是选项说明choice:选中的选项 ID;另有 probabilities(各选项的概率)与 confidence
score必填数组,至少两项,按等级从低到高排列score:可以带小数的等级值(从 0 开始);另有 legend(等级含义)、probabilities 与 confidence

noul 返回的是数值,不是布尔值。需要是/否结论时,请在自己的程序里设定阈值(例如大于 0.7 视为是)。confidence 与 probabilities 是模型给出的把握程度,不代表结果一定正确。

调用示例

下面一次请求同时问了三个问题:是否需要今天处理、交给哪个团队、对客户影响多大。

curl https://modelsok.com/v1/responses \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev",
    "input": {
      "state": "订单 X42 少了一个安装配件。客户明天参加展会,希望今天补发。",
      "questions": {
        "urgent": {
          "type": "noul",
          "instructions": "是否需要今天优先处理?",
          "criteria": {
            "true": "有明确的当天处理要求,或临近使用期限",
            "false": "没有明确期限,按常规流程处理即可"
          }
        },
        "team": {
          "type": "choice",
          "instructions": "哪个团队最适合先处理?",
          "criteria": {
            "fulfillment": "补发、缺件与配送问题",
            "support": "使用方法与故障排查",
            "sales": "选型与购买咨询"
          }
        },
        "impact": {
          "type": "score",
          "instructions": "这件事对客户计划的影响有多大?",
          "criteria": [
            "常规咨询,不影响使用",
            "影响使用,但有替代方案",
            "阻碍使用且期限临近"
          ]
        }
      }
    }
  }'

返回结果

响应是完整的 JSON,结果不在顶层,而是在 result.result 下面。下面是一次真实调用的返回:

{
  "result": {
    "state": "Completed",
    "result": {
      "model": "jev-1.13.0",
      "answers": {
        "urgent": { "type": "noul", "noul": 0.91 },
        "team": {
          "type": "choice",
          "choice": "fulfillment",
          "probabilities": { "sales": 0, "support": 0, "fulfillment": 1 },
          "confidence": 1
        },
        "impact": {
          "type": "score",
          "score": 2,
          "legend": {
            "0": "常规咨询,不影响使用",
            "1": "影响使用,但有替代方案",
            "2": "阻碍使用且期限临近"
          },
          "probabilities": { "0": 0, "1": 0, "2": 1 },
          "confidence": 1
        }
      },
      "usage": { "input_tokens": 472, "output_tokens": 72 }
    },
    "gatewayMetadata": { "keySource": "Unified" }
  },
  "success": true,
  "errors": [],
  "messages": []
}
路径含义
success本次评估是否成功,先判断它再读结果
result.result.answers.<问题 ID>每道题的结果,键与请求里的问题 ID 相同
result.result.model实际执行的模型版本,例如 jev-1.13.0,不一定等于请求里的 typesafe/jev
result.result.usage本次的输入、输出 Token 数;没有 total_tokens,需要时自行相加

不要按通用文本模型的方式读结果

虽然接口是 /v1/responses,但这个模型的响应里没有 output、output_text 或 choices,请直接读 result.result.answers。

Python 示例

import os
import requests

resp = requests.post(
    "https://modelsok.com/v1/responses",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
        "model": "typesafe/jev",
        "input": {
            "state": {
                "order_id": "X42",
                "missing_parts": ["安装支架"],
                "replacement_sent": False,
                "customer_note": "设备明天展会要用",
            },
            "questions": {
                "needs_follow_up": {
                    "type": "noul",
                    "instructions": "使用前是否需要跟进补齐缺件?",
                }
            },
        },
    },
    timeout=60,
)
resp.raise_for_status()
data = resp.json()
if not data.get("success"):
    raise RuntimeError(data.get("errors"))

answers = data["result"]["result"]["answers"]
usage = data["result"]["result"]["usage"]
print(answers["needs_follow_up"]["noul"])
print(usage["input_tokens"], usage["output_tokens"])

Node.js 示例

以下代码运行在服务端(Node.js 18 及以上自带 fetch),不要放进浏览器页面。

const apiKey = process.env.API_KEY;
if (!apiKey) throw new Error('Missing API_KEY');

const resp = await fetch('https://modelsok.com/v1/responses', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  signal: AbortSignal.timeout(60_000),
  body: JSON.stringify({
    model: 'typesafe/jev',
    input: {
      state: '订单 X42 缺了一个安装配件,请尽快补发。',
      questions: {
        team: {
          type: 'choice',
          instructions: '哪个团队最适合先处理?',
          criteria: {
            fulfillment: '补发、缺件与配送问题',
            support: '使用方法与故障排查',
            sales: '选型与购买咨询',
          },
        },
      },
    },
  }),
});
if (!resp.ok) throw new Error(`HTTP ${resp.status}: ${await resp.text()}`);

const data = await resp.json();
const { answers, usage } = data.result.result;
console.log(answers.team.choice, answers.team.confidence);
console.log(usage.input_tokens, usage.output_tokens);

计费

按 Token 计费,输入、输出 Token 数以 result.result.usage 为准,价格以模型广场中 typesafe/jev 的展示为准,每次调用的扣费可在使用日志里查看。评估没有成功的请求不扣费。

常见问题

返回 400,提示不支持流式:请求里带了 "stream": true,去掉即可。

读不到结果:检查是否按顶层 answers 或 output_text 读取了,结果在 result.result.answers 下。

请求返回错误:评估没有成功时不会扣费。常见原因是题型与 criteria 格式不匹配,例如 score 题的 criteria 少于两项、choice 题漏写了 criteria、noul 题的 criteria 用了 "true"、"false" 以外的键。修正请求后重试即可。

本页目录