Langfuse JS/TS SDKs
    Preparing search index...

    Class DatasetManager

    Manager for dataset operations in Langfuse.

    Provides methods to retrieve datasets and their items, with automatic pagination handling and convenient linking functionality for experiments.

    Index

    Constructors

    Methods

    Constructors

    • Internal

      Creates a new DatasetManager instance.

      Parameters

      • params: { apiClient: LangfuseAPIClient }

        Configuration object containing the API client

      Returns DatasetManager

    Methods

    • Retrieves a dataset by name along with all its items.

      This method automatically handles pagination to fetch all dataset items and enhances each item with a link function for easy experiment tracking.

      Parameters

      • name: string

        The name of the dataset to retrieve

      • Optionaloptions: { fetchItemsPageSize: number }

        Optional configuration for fetching

        • fetchItemsPageSize: number

          Number of items to fetch per page (default: 50)

      Returns Promise<
          Dataset & { items: (DatasetItem & { link: LinkDatasetItemFunction })[] },
      >

      Promise that resolves to the dataset with enhanced items

      const dataset = await langfuse.dataset.get("my-dataset");

      for (const item of dataset.items) {
      // Use the item data for your experiment
      const result = await processItem(item.input);

      // Link the result to the dataset item
      await item.link(
      { otelSpan: currentSpan },
      "experiment-run-1",
      { description: "Testing new model" }
      );
      }