構造化評価(Jev)
構造化評価(Jev)
Jev は JSON 状態を名前付きの質問で評価し、boolean、choice、score の型付き回答を返します。明確な基準をプログラムで扱える評価結果にしたい場合に使用します。
評価・判定専用
Jev はチャットには対応していません。Jev のリクエストは POST /v1/evaluations に送信してください。POST /v1/chat/completions に送ると HTTP 400 が返ります。
POST/v1/evaluations
BazaarLink API キーを使って次のエンドポイントを呼び出します。完全な URL: https://api.bazaarlink.ai/v1/evaluations。
フィールドの説明
model
string
省略可能です。省略すると typesafe-ai/jev が既定値になります。他のモデル ID では HTTP 400 と model_not_available が返ります。
state
string | object | array
必須です。評価対象の状態として JSON の文字列、オブジェクト、または配列を指定します。シリアライズ後の state と questions の合計が 32,000 tokens を超えると context_length_exceeded が返ります。
questions
record<string, Question>
必須です。名前付き質問を 1 つ以上含むオブジェクトを指定します。各質問名は応答 answers オブジェクトのキーになります。
type
boolean | choice | score
各質問で必須です。boolean、choice、score のいずれかを指定します。
instructions
string | object | array
各質問で必須です。判断内容を説明する JSON 文字列、オブジェクト、または配列を指定します。
criteria
object | array
type によって異なります。boolean では省略可能で、指定する場合はキーが true または false のオブジェクトです。choice は空でないオブジェクト、score は順序を保った 2 項目以上の配列が必須です。
回答の型
boolean — criteria は省略できます。指定する場合、キーには true と false のみ指定できます。回答には数値の probability が含まれます。choice — criteria は、選択肢名と JSON 形式の判定基準を対応付ける空でないオブジェクトです。回答には文字列の choice が含まれ、probabilities のキーは選択肢名です。score — criteria は2件以上の順序付き配列です。score は数値で、criteria 配列の順序に従ったインデックス 0..N-1 の期待値です。probabilities のキーは、そのインデックスを文字列にしたものです。
リクエスト例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
curl --fail-with-body https://api.bazaarlink.ai/v1/evaluations \
-H "Authorization: Bearer $BAZAARLINK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "typesafe-ai/jev",
"state": "The support agent issued a full refund and apologised for the delay.",
"questions": {
"refunded": {
"type": "boolean",
"instructions": "Was a refund issued?"
},
"tone": {
"type": "choice",
"instructions": "Tone of the agent?",
"criteria": {
"apologetic": "The agent apologises",
"neutral": "No emotional language",
"hostile": "The agent is rude"
}
},
"quality": {
"type": "score",
"instructions": "How complete was the resolution?",
"criteria": [
"poor",
"partial",
"complete"
]
}
}
}'
成功時の応答例
サンプルレスポンスには id、object、model、answers、usage、rounding、warnings が含まれます。answers のキーは質問名です。usage には input_tokens、output_tokens、total_tokens が含まれ、rounding には probabilityDecimals と scoreDecimals が示されます。warnings は配列で、この例では空です。answers 内では、choice の probabilities は選択肢名をキーにし、score の probabilities は criteria のインデックスを文字列にした値をキーにします。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
"id": "eval-a3d350e5-2705-4a9b-be7c-838fa4e4eb2b",
"object": "evaluation",
"model": "typesafe-ai/jev",
"answers": {
"refunded": {
"type": "boolean",
"probability": 0.99
},
"tone": {
"type": "choice",
"choice": "apologetic",
"probabilities": {
"apologetic": 1,
"neutral": 0,
"hostile": 0
}
},
"quality": {
"type": "score",
"score": 1.98,
"probabilities": {
"0": 0,
"1": 0.02,
"2": 0.98
}
}
},
"usage": {
"input_tokens": 394,
"output_tokens": 74,
"total_tokens": 468
},
"rounding": {
"probabilityDecimals": 2,
"scoreDecimals": 2
},
"warnings": []
}
チャット形式のエンドポイントでのエラー応答
Jev をチャット形式のエンドポイントに送信すると HTTP 400 が返ります。下記のフィールドと値はハンドラーの形状に一致します。message はプレースホルダーで、実際の文面はサーバーから返されます。
{
"error": {
"message": "<server-generated message>",
"type": "invalid_request_error",
"code": 400
}
}