SDK または httpx でシンプルに呼び出す
軽量な非同期 HTTP クライアントを使用することで、FastAPI や Django の非同期ルート内で超低遅延に意思決定を統合できます。
Confidence に基づくガードレール
最高信頼度が 0.80 未満の場合は自動的にフラグを立て、人間のレビューキューへ転送するコードを数行で記述できます。
Pydantic との併用による厳格な型保証
Jev の出力を Pydantic モデルへマッピングすることで、Python アプリケーション全体の型安全性を強固に維持できます。
python / typesafe-sdk
# pip install typesafe-sdk (Python 3.10 以上)
# export TYPESAFE_API_KEY="..." # console.typesafe.ai/keys で取得
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient
ticket = "20 分ほど前から API 連携がすべてのリクエストで 500 を返し、直るまで注文処理が一切できません。"
with TypeSafeClient(model="jev-latest") as client: # TYPESAFE_API_KEY を自動で読みます
response = client.system_one(
state=ticket,
questions={
"department": Choice(
instructions="このチケットはどのチームが担当すべきか",
criteria={
"billing": "支払い・サブスクリプションの問題",
"technical": "不具合・連携の問題",
"sales": "料金・アカウントの相談",
},
),
"frustration": Score(
instructions="顧客のいら立ちの度合い",
criteria=[
"落ち着いて事実を述べている",
"不満はあるが礼儀は保っている",
"非常に怒っていて語気が強い",
],
),
"is_urgent": Noul(
instructions="このメッセージは緊急性・時間的制約を示しているか",
),
},
)
print(response.choices["department"].choice) # 例: "technical"
print(response.scores["frustration"].score) # 0-2、尺度上の位置
print(response.nouls["is_urgent"].noul) # 0-1 の確率python / SDK なし(curl)
# SDK を使わない場合: POST https://api.typesafe.ai/v1/systemone
curl --fail-with-body --silent --show-error \
https://api.typesafe.ai/v1/systemone \
-H "Authorization: Bearer $TYPESAFE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"model": "jev-latest",
"state": "同じ注文で二重に請求されました。余分な分を返金してください。",
"questions": {
"department": {
"type": "choice",
"instructions": "このチケットはどのチームが担当すべきか",
"criteria": {
"billing": "支払い・サブスクリプションの問題",
"technical": "不具合・連携の問題",
"sales": "料金・アカウントの相談"
}
}
}
}
JSON
# 返り値: { "model": "jev-1.14.0", "answers": { "department": { "type": "choice",
# "choice": "billing", "confidence": 1.0, "probabilities": {...} } }, "usage": {...} }