Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

Convert Chosen Sessions into Test Cases with the REST APIBeta

Beta
This is coming — this page describes a feature that's still being rolled out and may not be available to you yet.

To add specific Sessions to an existing Dataset, convert them into test cases.


About This Task​

An agent turns each Session into a test case by following a blueprint. By default, the blueprint removes sensitive data, writes the goals the user needed as expected data, and shortens redundant data so the test case fits the size limits. The platform stores each converted conversation with the Dataset, so the conversation doesn't appear in search history.

The conversion runs in the background. The request returns a transfer that you check until the conversion ends.

Prerequisites​

  • You have a Dataset in the workspace, with room for the new test cases. A Dataset holds at most 100 test cases.
  • The Sessions were recorded on a pipeline in the same workspace.
  • You need an API key. For details, see Generate API Keys.
  • You need the workspace ID and the pipeline ID. For details, see Workspace ID and Pipeline ID.
  • You need the Dataset ID and the Session IDs.

Convert the Sessions​

Send a POST request to /api/v2/workspaces/{workspace_id}/evaluation/datasets/{dataset_id}/test-cases/conversions. Replace <WORKSPACE_ID>, <DATASET_ID>, <PIPELINE_ID>, and the Session IDs with your values, and <YOUR_API_KEY> with your Haystack Platform API key:

curl --request POST \
--url https://api.cloud.deepset.ai/api/v2/workspaces/<WORKSPACE_ID>/evaluation/datasets/<DATASET_ID>/test-cases/conversions \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>' \
--header 'content-type: application/json' \
--data '
{
"pipeline_id": "<PIPELINE_ID>",
"session_ids": [
"<SESSION_ID_1>",
"<SESSION_ID_2>"
]
}
'

The body has these fields:

  • pipeline_id: The pipeline the Sessions were recorded on.
  • session_ids: The Sessions to convert, from one to 100. The test cases are appended to the Dataset in this order. A repeated ID counts once.
  • blueprint: Optional. Markdown instructions for turning a Session into a test case. Leave it out to use the default blueprint.

Check the Transfer​

The response is a transfer. Send a GET request to /api/v2/workspaces/{workspace_id}/evaluation/datasets/transfers/{transfer_id} until the conversion has ended. Use the transfer ID from the response as <TRANSFER_ID>:

curl --request GET \
--url https://api.cloud.deepset.ai/api/v2/workspaces/<WORKSPACE_ID>/evaluation/datasets/transfers/<TRANSFER_ID> \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>'

The transfer's generation.session_ids field lists the Sessions you asked for. A generation that samples Sessions leaves this field empty and sets start, end, and seed. Use that difference to tell a conversion from a sampled generation. For that flow, see Generate a Dataset from a Pipeline's Sessions with the REST API.

A Session that can't be converted is left out and listed in skipped. The transfer fails only when none of the Sessions could be converted. It also fails if the Dataset is deleted or reaches its limit of 100 test cases while the conversion runs.

When a Request Is Rejected​

If the request is rejected, check the status code:

  • 404: The Dataset or the pipeline isn't in this workspace.
  • 422: The Sessions would take the Dataset over its limit of 100 test cases, or the Dataset already holds some of them. Remove those Sessions from session_ids and send the request again.
  • 503: This instance can't generate test cases.