create_dataset_item
Add or update dataset items with input-output pairs for evaluating LLM applications in Langfuse. Supports upsert functionality with custom IDs and metadata linking.
Instructions
Create a new item in a dataset, or update if item_id already exists.
Dataset items store input/expected output pairs for evaluation. If item_id is provided
and already exists, the item will be updated (upsert behavior).
Args:
ctx: Context object containing lifespan context with Langfuse client
dataset_name: Name of the target dataset
input: Input data for the item
expected_output: Expected output for evaluation
metadata: Optional custom metadata
source_trace_id: Optional linked trace ID
source_observation_id: Optional linked observation ID
item_id: Optional custom ID (enables upsert)
status: Item status (ACTIVE or ARCHIVED)
Returns:
A dictionary containing the created/updated item details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset_name | Yes | Name of the dataset to add the item to | |
| input | No | Input data for the dataset item (any JSON-serializable value) | |
| expected_output | No | Expected output data for evaluation (any JSON-serializable value) | |
| metadata | No | Optional custom metadata as key-value pairs | |
| source_trace_id | No | Optional trace ID to link this item to | |
| source_observation_id | No | Optional observation ID to link this item to | |
| item_id | No | Optional custom ID for the item (for upsert behavior) | |
| status | No | Item status (default: ACTIVE) |