fluxmodel.ai 文档
聊天系列TypeSafe Jev

Jev 结构化判断

通过 fluxmodel.ai 调用 typesafe/jev,对文本或结构化状态进行判断、分类和评分,直接读取 answers 与 token 用量。

typesafe/jev 用于对一份状态进行结构化评估。一次请求可以同时提出多个问题,分别返回肯定判断的分值、分类结果或等级评分,适合工单分流、内容评估和规则辅助判断。

接入地址与准备

POST https://api.modelsell.cc/v1/responses
Authorization: Bearer $MODELSELL_API_KEY
Content-Type: application/json

使用 fluxmodel.ai API Key,并确保令牌所属分组已开放 typesafe/jev。将 Key 保存在服务端环境变量 MODELSELL_API_KEY 中;下方示例均从环境变量读取,不应把 Key 写进浏览器代码或提交到代码仓库。

该模型使用同步、非流式调用:提交后等待本次 HTTP 请求返回 JSON。下方请求省略 stream,不要设置 stream: true,也无需轮询任务。

从 answers 读取结果

虽然入口是 /v1/responses,Jev 成功响应使用自己的 model、answers、usage 结构。直接读取 answers,不要按通用文本响应读取 output_text 或 choices。

请求字段

{
  "model": "typesafe/jev",
  "input": {
    "state": "需要评估的内容",
    "questions": {
      "needs_follow_up": {
        "type": "noul",
        "instructions": "这件事是否需要继续跟进?"
      }
    }
  }
}
字段必填说明
model是固定为 typesafe/jev
input是包含 state 和 questions 的对象
input.state是被评估的状态,常用字符串或 JSON 对象;也支持数组或 null
input.questions是问题对象;每个非空键是自定义问题 ID,响应沿用同名键
input.questions.<id>.type是noul、choice 或 score
input.questions.<id>.instructions是该问题的评估指令,建议用清晰的字符串描述
input.questions.<id>.criteria视题型而定判断标准、分类选项或有序评分等级,见下表

字符串 state 适合直接评估一段文本;对象 state 适合同时提供工单、订单、规则等上下文,无需先把对象转换成字符串。对象或数组中的值可包含数字、布尔值和 null;state 自身不能是裸数字或布尔值。

三种题型与 criteria

题型criteria 格式主要结果
noul可省略或为 null;使用对象时仅支持 "true"、"false" 两个键,分别描述肯定和否定标准noul:0 到 1 的数值,越接近 1 越支持肯定判断
choice必填对象,键是选项标识,值是选项说明choice:选中选项的键;另有 probabilities 和 confidence
score必填数组,至少两个元素,按评分等级顺序排列score:可为小数的分值;另有 legend、probabilities 和 confidence

score 的等级从索引 0 开始,读取返回的 legend 确认每一级的含义。noul 是数值而非布尔值;如果业务需要是/否结果,应在自己的业务逻辑中定义阈值。confidence 和 probabilities 是模型输出的评估信息,不代表结果一定正确。

题目中的 instructions 和标准说明也支持对象、数组或 null;首次接入建议使用字符串,便于检查评估规则。题目对象仅使用上述 type、instructions、criteria 字段。

cURL:一次提交三种问题

先在运行环境中配置 MODELSELL_API_KEY,再执行:

curl --fail-with-body --request POST 'https://api.modelsell.cc/v1/responses' \
  --header "Authorization: Bearer ${MODELSELL_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{
    "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 仅用于说明字段结构,分值、模型版本和 token 数均为示意,非实测结果:

{
  "model": "jev-example-version",
  "answers": {
    "urgent": {
      "type": "noul",
      "noul": 0.92
    },
    "team": {
      "type": "choice",
      "choice": "fulfillment",
      "confidence": 0.87,
      "probabilities": {
        "fulfillment": 0.91,
        "support": 0.07,
        "sales": 0.02
      }
    },
    "impact": {
      "type": "score",
      "score": 1.76,
      "confidence": 0.81,
      "legend": {
        "0": "常规咨询,不影响使用",
        "1": "影响使用,但有替代方案",
        "2": "阻碍使用且期限临近"
      },
      "probabilities": {
        "0": 0.03,
        "1": 0.18,
        "2": 0.79
      }
    }
  },
  "usage": {
    "input_tokens": 310,
    "output_tokens": 64
  }
}
  • 使用提交时的问题 ID 索引结果,如 answers.urgent.noul、answers.team.choice、answers.impact.score。
  • probabilities 给出选项或评分等级对应的数值,confidence 在 0 到 1 之间;noul 题型直接返回 noul,没有单独的 confidence 字段。
  • 返回的 model 可能是具体模型版本,不要要求它与请求中的 typesafe/jev 完全相同。
  • usage.input_tokens 和 usage.output_tokens 分别表示输入与输出 token 用量。需要合计时可自行相加;不要要求响应额外提供 total_tokens。实际费用请以平台模型价格和消费记录为准。

Python:传入结构化 state

安装 requests 后,在已配置 MODELSELL_API_KEY 的服务端环境中运行:

import os
import requests

payload = {
    "model": "typesafe/jev",
    "input": {
        "state": {
            "order_id": "X42",
            "missing_parts": ["mounting bracket"],
            "replacement_sent": False,
            "customer_note": "The equipment is needed at tomorrow's exhibition.",
        },
        "questions": {
            "needs_follow_up": {
                "type": "noul",
                "instructions": "Is follow-up needed to address the missing part before use?",
            }
        },
    },
}

response = requests.post(
    "https://api.modelsell.cc/v1/responses",
    headers={"Authorization": f"Bearer {os.environ['MODELSELL_API_KEY']}"},
    json=payload,
    timeout=60,
)
response.raise_for_status()
data = response.json()

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

JavaScript:使用 fetch

以下示例运行于支持 fetch 的服务端 Node.js 环境,不应直接放入浏览器页面:

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

const response = await fetch('https://api.modelsell.cc/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: 'An installation part is missing from order X42. Please send a replacement.',
      questions: {
        team: {
          type: 'choice',
          instructions: 'Which team should handle this request first?',
          criteria: {
            fulfillment: 'Missing parts and replacement shipments',
            support: 'Setup instructions and troubleshooting',
            sales: 'Product selection and purchase questions',
          },
        },
      },
    },
  }),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}

const data = await response.json();
console.log(data.answers.team.choice);
console.log(data.answers.team.confidence);
console.log(data.usage);

示例中的 60 秒是客户端超时设置,可按业务调整,不是服务延迟承诺。

常见问题

现象检查方式
鉴权失败确认环境变量已设置,使用有效的 fluxmodel.ai Key,且请求头为 Authorization: Bearer ...
模型不可用、无可用渠道或无权限确认令牌分组已开放 typesafe/jev;仍不可用时联系管理员检查模型可用性
请求参数错误检查 input.state、input.questions 和题目的 type、instructions;choice 的 criteria 应为对象,score 应为至少两个元素的数组
流式请求被拒绝移除 stream: true,按本页示例等待完整 JSON 响应
成功后读不到文本直接读取 answers,而非 output_text 或 choices;问题 ID 应与提交时一致

错误由平台统一格式返回。排查时先检查 HTTP 状态码,再读取 JSON 中的 error.message;如果响应包含 error.code,一并保留用于定位。不要将错误响应当作带有 answers 的成功结果,也不要依赖原始服务商的错误结构。

Jev 的题型与字段定义可参考官方模型说明、输入 Schema和输出 Schema。通过 fluxmodel.ai 接入时,请使用本页的平台地址与 fluxmodel.ai Key。

On this page