UNPKG

@arizeai/phoenix-client

Version:

A client for the Phoenix API

32 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createOrGetDataset = createOrGetDataset; const client_1 = require("../client"); const createDataset_1 = require("./createDataset"); const getDatasetInfoByName_1 = require("./getDatasetInfoByName"); /** * Given the parameters to create a dataset, this function will either * retrieve an existing dataset by name or create a new one with the provided parameters. * * This is useful in cases where you would like to re-run a pipeline like: * - ensure dataset exists * - create a task * - run experiment * - evaluate experiment * without having to create a new dataset each time. */ async function createOrGetDataset({ name, description, examples, client: _client, }) { const client = _client || (0, client_1.createClient)(); // start by fetching an existing dataset by name, catching any errors that occur try { const dataset = await (0, getDatasetInfoByName_1.getDatasetInfoByName)({ datasetName: name, client }); return { datasetId: dataset.id, }; } catch (_a) { // If the dataset doesn't exist, create it, falling back to the error handling inside createDataset return await (0, createDataset_1.createDataset)({ name, description, examples, client }); } } //# sourceMappingURL=createOrGetDataset.js.map