J

Jev Cheatsheet

一屏搞懂 Choice / Score / Noul 的所有要点。

Choice — 单选题

from typesafe_sdk import Choice

Choice(
    instructions="Which team handles this?",
    options=["billing", "technical", "account", "shipping", "other"],
)

返回:

{
  "choice": "billing",
  "probabilities": { "billing": 0.92, "technical": 0.05, ... },
  "confidence": 0.92
}

要点:

  • 选项最多 255 个
  • 每个选项的 key 必须是你想原样返回的字符串
  • 无顺序关系(有序用 Score)
  • confidence = 最大概率值

Score — 评分题

from typesafe_sdk import Score

Score(
    instructions="How urgent?",
    criteria=["not urgent", "slightly", "urgent", "very urgent"],
)

返回:

{
  "score": 2.4,
  "legend": { "0": "not urgent", "1": "slightly", "2": "urgent", "3": "very urgent" },
  "probabilities": { "0": 0.05, "1": 0.10, "2": 0.55, "3": 0.30 },
  "confidence": 0.55
}

要点:

  • criteria 2–10 级
  • 有顺序关系(必须从低到高)
  • score 可落在级别之间(连续值)
  • 别用 score 做精确插值(校准弱)

Noul — 是非题

from typesafe_sdk import Noul

Noul(
    instructions="Does the customer request a refund?",
    criteria={  # 可选
        "true": "the customer explicitly asks for money back",
        "false": "the customer does not request a refund",
    },
)

返回:

{
  "noul": 0.95
}

要点:

  • 不返回 confidence(noul 本身就是答案)
  • 0 = 100% 不是,1 = 100% 是
  • criteria 不是必填,但强烈推荐(给模型明确语义)

State — 输入材料

state = "plain text"          # string

state = {                     # object (推荐)
    "message": "...",
    "context": {...},
}

state = [                     # array
    "msg 1", "msg 2", "msg 3",
]
  • 文本 / JSON 对象 / 数组均可
  • 推荐用 object,字段语义清晰
  • 当前只吃文本(图片/音频/视频不支持)

硬限制速查

限制值
单 request questions 数无明确上限,实践 ≤ ~50
Choice options≤ 255
Score criteria2–10
总 context window64K tokens
state + 最长 question≤ ~32K tokens(~150K 字符)
延迟(端到端)70–500ms
价格(输入)$0.042 / MTok
价格(输出)免费

Confidence 用法

HIGH = 0.85
LOW  = 0.50

if answer.confidence < LOW:
    escalate_to_human()
elif answer.confidence < HIGH:
    ask_user_to_confirm()
else:
    act_automatically()

反模式(不要做)

  • ❌ 让 Jev 写文章 / 代码 / 解释
  • ❌ 让 Jev 数数 / 做日期算术
  • ❌ 让 Jev 处理图片 / 音频 / 视频
  • ❌ 把无关内容塞进 state
  • ❌ 用 score 在级别之间精确插值
  • ❌ 让 Jev 自己"反问"或质疑前提

好模式

  • ✅ 一个 question = 一个原子判断
  • ✅ 一次 call 问多道题(并行)
  • ✅ 候选选项在代码里枚举
  • ✅ 算术在代码里算完,只把判断给 Jev
  • ✅ 用 confidence 阈值 gate 高风险动作