@gentrace/core
Version:
Core Gentrace Node.JS library
45 lines (42 loc) • 2.11 kB
JavaScript
import { globalGentraceApiV2, globalGentraceApiV3 } from './init.mjs';
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 (!globalGentraceApiV2) {
throw new Error("Gentrace API key not initialized. Call init() first.");
}
const response = yield 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 (!globalGentraceApiV3) {
throw new Error("Gentrace API key not initialized. Call init() first.");
}
if (!resultId) {
throw new Error("resultId must be provided.");
}
const response = yield globalGentraceApiV3.v3EvaluationsGet(resultId);
return (_a = response.data.data) !== null && _a !== void 0 ? _a : [];
});
export { bulkCreateEvaluations, getEvaluations };
//# sourceMappingURL=evaluation.mjs.map