@gentrace/core
Version:
Core Gentrace Node.JS library
48 lines (44 loc) • 2.15 kB
JavaScript
;
var init = require('./init.js');
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function bulkCreateEvaluations(evaluations) {
return __awaiter(this, void 0, void 0, function* () {
if (!init.globalGentraceApiV2) {
throw new Error("Gentrace API key not initialized. Call init() first.");
}
const response = yield init.globalGentraceApiV2.v2EvaluationsBulkPost({
data: evaluations,
});
return response.data;
});
}
/**
* Retrieves evaluations for a specific result from the Gentrace API.
* @async
* @param {Object} params - The parameters for the function.
* @param {string} params.resultId - The ID of the result to get evaluations for.
* @returns {Promise<Array<EvaluationV2>>} - A promise that resolves to an array of evaluations.
* @throws {Error} - Throws an error if the Gentrace API key is not initialized.
*/
const getEvaluations = ({ resultId, }) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
if (!init.globalGentraceApiV3) {
throw new Error("Gentrace API key not initialized. Call init() first.");
}
if (!resultId) {
throw new Error("resultId must be provided.");
}
const response = yield init.globalGentraceApiV3.v3EvaluationsGet(resultId);
return (_a = response.data.data) !== null && _a !== void 0 ? _a : [];
});
exports.bulkCreateEvaluations = bulkCreateEvaluations;
exports.getEvaluations = getEvaluations;
//# sourceMappingURL=evaluation.js.map