評估與測試集
評估與測試集端點對應後台 AgentOps 的「測試集」與「自動化測試」,讓您從自己的系統批次測試 Agent。完整流程是:
建立測試集:用
POST /api/v1/dataset/建立空白測試集,或用POST /api/v1/dataset/upload/上傳 CSV/Excel 一次建好。加入測試案例:單輪問答用
/api/v1/test-case/(逐筆建立、上傳檔案或從知識庫檔案生成),多輪對話情境用/api/v1/multi-turn-test-case/。從知識庫檔案生成在背景執行,回應202與jobId,再用 查詢測試案例生成任務進度 追蹤。執行評估:用
POST /api/v1/evaluations/evaluate/(單輪)或POST /api/v1/evaluations/multi-turn-evaluate/(多輪)指定測試集與 Agent,回應202與evaluationId。讀取結果與匯出:輪詢
GET /api/v1/evaluations/{id}/,status變成completed、partial_completed或failed即結束;單輪的逐題結果在details,多輪的逐對話結果在multi-turn-results。已完成的單輪評估可以用export匯出 Excel 報表,再從export-status取得下載網址。
所需權限:API Key 以建立它的成員身分呼叫。/dataset/、/test-case/、/multi-turn-test-case/ 的列表與所有寫入操作需要角色具備「測試集權限」,/evaluations/ 的列表與所有寫入操作需要「自動化測試權限」(角色權限中的 AgentOps 權限;擁有者一律具備),權限不足回 403。擁有者以外的成員只看得到、也只能評估自己角色可使用的 Agent。
Credit:從知識庫檔案生成測試案例,依實際生成的題數扣計價項目 agentops_test_gen;執行評估在結束時依完成的測試案例數扣 agentops_test_run 與 agentops_deepeval,評分用的評估模型呼叫另依該模型的用量計費。送出生成或評估前,系統會先檢查組織 Credit 與額度,不足回 402。手動建立、上傳檔案與讀取結果不扣 Credit;各項單價見 列出計價項目。
功能與後台操作見使用者手冊測試集管理與自動評估與 Agent 監控。
列出測試集
GET /api/v1/dataset/
參數
isActive
❌
boolean
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
建立空白測試集
POST /api/v1/dataset/
請求內容
請求參數
name
string
是
description
string
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
上傳 CSV 或 Excel 建立測試集
POST /api/v1/dataset/upload/
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
從知識庫檔案生成測試集
POST /api/v1/dataset/generate-from-file/
請求內容
請求參數
name
string
是
description
string
否
chatbotFileId
string (uuid)
否
knowledgeBaseFileId
string (uuid)
否
numTestCases
integer
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
列出可生成測試案例的知識庫檔案
GET /api/v1/dataset/knowledge-base-files/
參數
pageSize
❌
integer
Number of files per knowledge base (default: 5, max: 100)
search
❌
string
Filter files by filename
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取得特定測試集
GET /api/v1/dataset/{id}/
參數
id
✅
string
A UUID string identifying this Dataset.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取得測試集與單輪測試案例
GET /api/v1/dataset/{id}/details/
參數
id
✅
string
A UUID string identifying this Dataset.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
更新測試集
PUT /api/v1/dataset/{id}/
參數
id
✅
string
A UUID string identifying this Dataset.
請求內容
請求參數
name
string
是
description
string
否
isActive
boolean
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
部分更新測試集
PATCH /api/v1/dataset/{id}/
參數
id
✅
string
A UUID string identifying this Dataset.
請求內容
請求參數
name
string
否
description
string
否
isActive
boolean
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
刪除測試集
DELETE /api/v1/dataset/{id}/
參數
id
✅
string
A UUID string identifying this Dataset.
程式碼範例
回應內容
204
No response body
列出單輪測試案例
GET /api/v1/test-case/
參數
creationMethod
❌
string
`manual`: Manual ; `file`: File import ; `generate`: Generated;
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`active`: Active ; `inactive`: Inactive ; `pending`: Pending Review;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
建立單輪測試案例
POST /api/v1/test-case/
請求內容
請求參數
datasetId
string (uuid)
是
question
string
是
groundTruth
string
是
status
string
否
flaky
boolean
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
上傳 CSV 或 Excel 加入測試案例
POST /api/v1/test-case/upload/
參數
creationMethod
❌
string
`manual`: Manual ; `file`: File import ; `generate`: Generated;
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`active`: Active ; `inactive`: Inactive ; `pending`: Pending Review;
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
從知識庫檔案生成單輪測試案例
POST /api/v1/test-case/generate-from-file/
請求內容
請求參數
chatbotFileIds
array[string]
否
List of KnowledgeBaseFile IDs to generate test cases from (deprecated)
knowledgeBaseFileIds
array[string]
否
List of KnowledgeBaseFile IDs to generate test cases from
knowledgeBaseIds
array[string]
否
List of KnowledgeBase IDs to generate test cases from all their files
datasetId
string (uuid)
是
numTestCases
integer
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 202
回應結構範例
回應範例值
列出測試案例生成任務
GET /api/v1/test-case/generation-jobs/
參數
creationMethod
❌
string
`manual`: Manual ; `file`: File import ; `generate`: Generated;
datasetId
❌
string
只列出此資料集的生成任務
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
依狀態過濾:pending / running / completed / partial_completed / failed
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
查詢測試案例生成任務進度
GET /api/v1/test-case/generation-jobs/{jobId}/
參數
jobId
✅
string
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
更新單輪測試案例
PUT /api/v1/test-case/{id}/
參數
id
✅
string
A UUID string identifying this Q&A pair.
請求內容
請求參數
question
string
是
groundTruth
string
否
status
string (enum: active, inactive, pending)
否
active: Active ; inactive: Inactive ; pending: Pending Review;
flaky
boolean
否
Flaky test cases still run and keep their results, but are excluded from the pass rate.
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
部分更新單輪測試案例
PATCH /api/v1/test-case/{id}/
參數
id
✅
string
A UUID string identifying this Q&A pair.
請求內容
請求參數
question
string
否
groundTruth
string
否
status
string (enum: active, inactive, pending)
否
active: Active ; inactive: Inactive ; pending: Pending Review;
flaky
boolean
否
Flaky test cases still run and keep their results, but are excluded from the pass rate.
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
刪除單輪測試案例
DELETE /api/v1/test-case/{id}/
參數
id
✅
string
A UUID string identifying this Q&A pair.
程式碼範例
回應內容
204
No response body
批次刪除單輪測試案例
POST /api/v1/test-case/bulk-delete/
請求內容
請求參數
test_case_ids
array[string]
是
要刪除的測試案例 ID 列表
請求結構範例
請求範例值
程式碼範例
回應內容
204
No response body
列出多輪測試案例
GET /api/v1/multi-turn-test-case/
參數
dataset
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
search
❌
string
A search term.
status
❌
string
`active`: Active ; `inactive`: Inactive;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
建立多輪測試案例
POST /api/v1/multi-turn-test-case/
請求內容
請求參數
datasetId
string (uuid)
是
scenario
string
是
expectedOutcome
string
是
userDescription
string
否
status
object
否
flaky
boolean
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
從知識庫檔案生成多輪測試案例
POST /api/v1/multi-turn-test-case/generate-from-file/
請求內容
請求參數
datasetId
string (uuid)
是
knowledgeBaseFileIds
array[string]
是
List of KnowledgeBaseFile IDs to generate multi-turn test cases from
numTestCases
integer
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 202
回應結構範例
回應範例值
取得特定多輪測試案例
GET /api/v1/multi-turn-test-case/{id}/
參數
id
✅
string
A UUID string identifying this Multi-turn test case.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
更新多輪測試案例
PUT /api/v1/multi-turn-test-case/{id}/
參數
id
✅
string
A UUID string identifying this Multi-turn test case.
請求內容
請求參數
scenario
string
是
Task scenario the simulated user should accomplish
expectedOutcome
string
是
Outcome a successful conversation should reach, also used as the simulation stop condition
userDescription
string
否
Persona of the simulated user, such as tone, background and level of expertise
status
string (enum: active, inactive)
否
active: Active ; inactive: Inactive;
flaky
boolean
否
Flaky test cases still run and keep their results, but are excluded from the pass rate.
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
部分更新多輪測試案例
PATCH /api/v1/multi-turn-test-case/{id}/
參數
id
✅
string
A UUID string identifying this Multi-turn test case.
請求內容
請求參數
scenario
string
否
Task scenario the simulated user should accomplish
expectedOutcome
string
否
Outcome a successful conversation should reach, also used as the simulation stop condition
userDescription
string
否
Persona of the simulated user, such as tone, background and level of expertise
status
string (enum: active, inactive)
否
active: Active ; inactive: Inactive;
flaky
boolean
否
Flaky test cases still run and keep their results, but are excluded from the pass rate.
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
刪除多輪測試案例
DELETE /api/v1/multi-turn-test-case/{id}/
參數
id
✅
string
A UUID string identifying this Multi-turn test case.
程式碼範例
回應內容
204
No response body
列出可用的評估模型
GET /api/v1/evaluations/evaluation-llms/
參數
chatbotId
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
query
❌
string
search
❌
string
A search term.
status
❌
string
`pending`: Pending evaluation ; `running`: Evaluating ; `stopping`: Stopping ; `completed`: Completed ; `partial_completed`: Partially completed ; `failed`: Evaluation failed;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
執行單輪評估
POST /api/v1/evaluations/evaluate/
請求內容
請求參數
datasetId
string (uuid)
是
chatbotId
string (uuid)
是
evaluationLlmId
string (uuid)
否
name
string
否
description
string
否
metricConfig
object
否
customMetrics
array[DatasetEvaluationCustomMetric]
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 202
回應結構範例
回應範例值
執行多輪評估
POST /api/v1/evaluations/multi-turn-evaluate/
請求內容
請求參數
datasetId
string (uuid)
是
chatbotId
string (uuid)
是
evaluationLlmId
string (uuid)
否
name
string
否
description
string
否
maxTurns
integer
否
minTurns
integer
否
turnFaithfulness
boolean
否
turnRelevancy
boolean
否
conversationCompleteness
boolean
否
language
object
否
customMetrics
array[MultiTurnCustomMetric]
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 202
回應結構範例
回應範例值
列出評估
GET /api/v1/evaluations/
參數
chatbotId
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`pending`: Pending evaluation ; `running`: Evaluating ; `stopping`: Stopping ; `completed`: Completed ; `partial_completed`: Partially completed ; `failed`: Evaluation failed;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取得評估結果
GET /api/v1/evaluations/{id}/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取得單輪評估的逐題結果
GET /api/v1/evaluations/{id}/details/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
chatbotId
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`pending`: Pending evaluation ; `running`: Evaluating ; `stopping`: Stopping ; `completed`: Completed ; `partial_completed`: Partially completed ; `failed`: Evaluation failed;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取得多輪評估的逐對話結果
GET /api/v1/evaluations/{id}/multi-turn-results/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
chatbotId
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`pending`: Pending evaluation ; `running`: Evaluating ; `stopping`: Stopping ; `completed`: Completed ; `partial_completed`: Partially completed ; `failed`: Evaluation failed;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
取消執行中的評估
POST /api/v1/evaluations/{id}/cancel/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
繼續未完成的評估
POST /api/v1/evaluations/{id}/resume/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
狀態碼: 202
回應結構範例
回應範例值
匯出評估報表
POST /api/v1/evaluations/{id}/export/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
狀態碼: 201
回應結構範例
回應範例值
查詢最新匯出狀態
GET /api/v1/evaluations/{id}/export-status/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
列出匯出紀錄
GET /api/v1/evaluations/{id}/exports/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
chatbotId
❌
string
datasetId
❌
string
ordering
❌
string
Which field to use when ordering the results.
page
❌
integer
A page number within the paginated result set.
pageSize
❌
integer
Number of results to return per page.
query
❌
string
search
❌
string
A search term.
status
❌
string
`pending`: Pending evaluation ; `running`: Evaluating ; `stopping`: Stopping ; `completed`: Completed ; `partial_completed`: Partially completed ; `failed`: Evaluation failed;
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
編輯評估名稱與描述
PATCH /api/v1/evaluations/{id}/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
請求內容
請求參數
name
string
否
description
string
否
請求結構範例
請求範例值
程式碼範例
回應內容
狀態碼: 200
回應結構範例
回應範例值
刪除評估
DELETE /api/v1/evaluations/{id}/
參數
id
✅
string
A UUID string identifying this Dataset evaluation.
程式碼範例
回應內容
204
No response body
最後更新於
這有幫助嗎?