Langfuse JS/TS SDKs
    Preparing search index...

    Type Alias LinkDatasetItemFunction

    LinkDatasetItemFunction: (
        obj: { otelSpan: Span },
        runName: string,
        runArgs?: { description?: string; metadata?: any },
    ) => Promise<DatasetRunItem>

    Function type for linking dataset items to OpenTelemetry spans.

    This function creates a connection between a dataset item and a trace/observation, enabling tracking of which dataset items were used in which experiments or runs. This is essential for creating dataset runs and tracking experiment lineage.

    Type declaration

      • (
            obj: { otelSpan: Span },
            runName: string,
            runArgs?: { description?: string; metadata?: any },
        ): Promise<DatasetRunItem>
      • Parameters

        • obj: { otelSpan: Span }

          Object containing the OpenTelemetry span to link to

          • otelSpan: Span

            The OpenTelemetry span from a Langfuse observation

        • runName: string

          Name of the experiment run for grouping related items

        • OptionalrunArgs: { description?: string; metadata?: any }

          Optional configuration for the dataset run

          • Optionaldescription?: string

            Description of the dataset run

          • Optionalmetadata?: any

            Additional metadata for the dataset run

        Returns Promise<DatasetRunItem>

        Promise that resolves to the created dataset run item

    const dataset = await langfuse.dataset.get("my-dataset");
    const span = startObservation("my-task", { input: "test" });
    span.update({ output: "result" });
    span.end();

    // Link the dataset item to this execution
    await dataset.items[0].link(
    { otelSpan: span.otelSpan },
    "experiment-run-1"
    );
    await dataset.items[0].link(
    { otelSpan: span.otelSpan },
    "model-comparison-v2",
    {
    description: "Comparing GPT-4 vs Claude performance",
    metadata: {
    modelVersion: "gpt-4-1106-preview",
    temperature: 0.7,
    timestamp: new Date().toISOString()
    }
    }
    );

    https://langfuse.com/docs/datasets Langfuse datasets documentation

    4.0.0