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
}

要点:

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
}

要点:

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
}

要点:

State — 输入材料

state = "plain text"          # string

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

state = [                     # array
    "msg 1", "msg 2", "msg 3",
]

硬限制速查

限制
单 request questions 数无明确上限,实践 ≤ ~50
Choice options255
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()

反模式(不要做)

好模式