Skip to main content
Glama

@arizeai/phoenix-mcp

Official
by Arize-ai
createOrGetDataset.ts1.32 kB
import { createClient } from "../client"; import { CreateDatasetParams, createDataset } from "./createDataset"; import { getDatasetInfoByName } from "./getDatasetInfoByName"; export type CreateOrGetDatasetParams = CreateDatasetParams; export type CreateOrGetDatasetResponse = { datasetId: string; }; /** * 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. */ export async function createOrGetDataset({ name, description, examples, client: _client, }: CreateOrGetDatasetParams): Promise<CreateOrGetDatasetResponse> { const client = _client || createClient(); // start by fetching an existing dataset by name, catching any errors that occur try { const dataset = await getDatasetInfoByName({ datasetName: name, client }); return { datasetId: dataset.id, }; } catch { // If the dataset doesn't exist, create it, falling back to the error handling inside createDataset return await createDataset({ name, description, examples, client }); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arize-ai/phoenix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server