Evaluation - Bulk create
- TypeScript
- Python
The function bulkCreateEvaluations()
creates multiple Evaluations
in a single request.
The function bulk_create_evaluations()
creates multiple Evaluations
in a single request.
Example
typescript
import {bulkCreateEvaluations ,CreateEvaluationType ,getTestResult } from "@gentrace/core";constEXAMPLE_RESULT_ID = "492ef124-aca1-4640-8c9c-641c874acdb7";constEXAMPLE_EVALUATOR_ID = "e1117752-01fe-568c-9ee0-5e160352031d"constresult = awaitgetTestResult (EXAMPLE_RESULT_ID );construns =result .runs ?? [];constevaluationPayloads :CreateEvaluationType [] =runs .map ((run ) => {return {evaluatorId :EXAMPLE_EVALUATOR_ID ,runId :run .id ,evalLabel : "A",};});constcreationCount = awaitbulkCreateEvaluations (evaluationPayloads );console .log ("Creation count: ",creationCount );
python
import osimport gentracefrom dotenv import load_dotenvload_dotenv()gentrace.init(api_key=os.getenv("GENTRACE_API_KEY"))EXAMPLE_RESULT_ID = "492ef124-aca1-4640-8c9c-641c874acdb7"EXAMPLE_EVALUATOR_ID = "e1117752-01fe-568c-9ee0-5e160352031d"result = gentrace.get_test_result(EXAMPLE_RESULT_ID)runs = result.get("runs") or []run_ids = [run.get("id") for run in runs]payloads = [{"note": "test note","evaluatorId": EXAMPLE_EVALUATOR_ID,"runId": run_id,"evalLabel": "A",}for run_id in run_ids]creation_count = gentrace.bulk_create_evaluations(payloads=payloads)print(creation_count)
Arguments
evaluationPayloads: CreateEvaluationType[]
payloads: List[CreateEvaluationType]
Types
🛠️ CreateEvaluationType
note?: string
evaluatorId: string (UUID)
runId: string (UUID)
evalLabel?: string
evalValue?: number