BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用AI Skills
章節導覽

結構化評估(Jev)

結構化評估(Jev)

Jev 會根據 JSON 狀態回答具名問題,並回傳 boolean、choice 或 score 類型的答案;適合將明確判準轉成程式可讀的評估結果。

僅供評估與判斷
Jev 不支援聊天。請將 Jev 請求送至 POST /v1/evaluations;若送至 POST /v1/chat/completions,會收到 HTTP 400。
POST/v1/evaluations

使用 BazaarLink API 金鑰呼叫以下端點。完整網址為 https://api.bazaarlink.ai/v1/evaluations。

欄位說明

model
string
選用。省略時預設為 typesafe-ai/jev;其他模型識別值會回傳 HTTP 400,錯誤代碼為 model_not_available。
state
string | object | array
必填,須為 JSON 字串、物件或陣列,作為待評估的狀態資料。序列化後的 state 與 questions 合計超過 32,000 tokens 時,會回傳 context_length_exceeded。
questions
record<string, Question>
必填,至少包含一個具名問題的物件。每個問題名稱會成為回應 answers 物件中的鍵。
type
boolean | choice | score
每個問題皆必填;可用 boolean、choice 或 score。
instructions
string | object | array
每個問題皆必填;可使用 JSON 字串、物件或陣列,描述要判斷的內容。
criteria
object | array
依 type 決定:boolean 可省略,若提供則為鍵名只能是 true 或 false 的物件;choice 必須是非空物件;score 必須是至少含兩項且順序有意義的陣列。

答案類型

  • boolean — criteria 可省略;如有提供,只接受 true 與 false 作為鍵。boolean 答案包含數值型的 probability。
  • choice — criteria 必須是非空物件,以選項名稱對應 JSON criteria。答案包含字串 choice;probabilities 以選項名稱為鍵。
  • score — criteria 必須是至少含兩項的有序陣列。答案包含數值 score;score 是依 criteria 陣列順序、在索引 0..N-1 上的期望值;probabilities 以相同索引的字串形式作為鍵。

請求範例

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 項目的索引字串為鍵。

{
  "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
  }
}
客服
您好!有什麼可以協助?
請留下訊息,我們會盡快回覆。
結構化評估(Jev) | BazaarLink