Skip to content

Commit d55d8f2

Browse files
committed
.
1 parent b45718c commit d55d8f2

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

deepeval/dataset/dataset.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,16 @@ def push(
550550
overwrite: Optional[bool] = None,
551551
auto_convert_test_cases_to_goldens: bool = False,
552552
):
553-
if len(self.test_cases) == 0 and len(self.goldens) == 0:
554-
raise ValueError(
555-
"Unable to push empty dataset to Confident AI, there must be at least one test case or golden in dataset"
556-
)
553+
if auto_convert_test_cases_to_goldens is False:
554+
if len(self.goldens) == 0:
555+
raise ValueError(
556+
"Unable to push empty dataset to Confident AI, there must be at least one golden in dataset. To include test cases, set 'auto_convert_test_cases_to_goldens' to True."
557+
)
558+
else:
559+
if len(self.test_cases) == 0 and len(self.goldens) == 0:
560+
raise ValueError(
561+
"Unable to push empty dataset to Confident AI, there must be at least one test case or golden in dataset"
562+
)
557563
if is_confident():
558564
goldens = self.goldens
559565
if auto_convert_test_cases_to_goldens:

docs/docs/confident-ai-evaluation-dataset-management.mdx

+27-14
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ Alternatively, you can also choose to upload entire datasets from CSV files. Sim
3434

3535
Pushing an `EvaluationDataset` on Confident using `deepeval` is a two-step process:
3636

37-
1. Create a dataset locally (same as how you would create a dataset as shown in the [datasets section](evaluation-datasets))
38-
2. Push the created dataset to Confident
37+
1. Create a dataset locally (same as how you would create a dataset as shown in the [datasets section](evaluation-datasets)).
38+
2. Populate it with `Golden`s.
39+
3. Push the new dataset to Confident AI.
40+
41+
:::warning
42+
Although you can also populate an `EvaluationDataset` with `LLMTestCase`s, we **HIGHLY** recommend that you do it with `Golden`s instead as it is more flexible to work with when dealing with datasets.
43+
:::
3944

4045
### Create A Dataset Locally
4146

42-
Here's a quick example:
47+
Here's a quick example of populating an `EvaluationDataset` with `Golden`s before pushing it to Confident AI:
4348

4449
```python
45-
from deepeval.test_case import LLMTestCase
46-
from deepeval.dataset import EvaluationDataset
50+
from deepeval.dataset import EvaluationDataset, Golden
4751

4852
original_dataset = [
4953
{
@@ -66,44 +70,53 @@ original_dataset = [
6670
},
6771
]
6872

69-
test_cases = []
73+
goldens = []
7074
for datapoint in original_dataset:
7175
input = datapoint.get("input", None)
7276
actual_output = datapoint.get("actual_output", None)
7377
expected_output = datapoint.get("expected_output", None)
7478
context = datapoint.get("context", None)
7579

76-
test_case = LLMTestCase(
80+
golden = Golden(
7781
input=input,
7882
actual_output=actual_output,
7983
expected_output=expected_output,
8084
context=context
8185
)
82-
test_cases.append(test_case)
86+
goldens.append(golden)
8387

84-
dataset = EvaluationDataset(test_cases=test_cases)
88+
dataset = EvaluationDataset(goldens=goldens)
8589
```
8690

8791
### Push Dataset to Confident AI
8892

89-
After creating your `EvaluationDataset`, all you have to do is push it to Confident by providing an `alias` as an unique identifier:
93+
After creating your `EvaluationDataset`, all you have to do is push it to Confident by providing an `alias` as an unique identifier. When you push an `EvaluationDataset`, the data is being uploaded as `Golden`s, **NOT** `LLMTestCase`s:
9094

9195
```python
96+
...
97+
9298
# Provide an alias when pushing a dataset
9399
dataset.push(alias="My Confident Dataset")
94100
```
95101

96-
:::tip Did you know?
97-
You can choose to overwrite or append to an existing dataset if an existing dataset with the same alias already exist.
102+
The `push()` method will upload all `Goldens` found in your dataset to Confident AI, ignoring any `LLMTestCase`s. If you wish to also include `LLMTestCase`s in the push, you can set the `auto_convert_test_cases_to_goldens` parameter to `True`:
98103

99104
```python
105+
...
106+
107+
dataset.push(alias="My Confident Dataset", auto_convert_test_cases_to_goldens=True)
108+
```
109+
110+
You can also choose to overwrite or append to an existing dataset if an existing dataset with the same alias already exist.
111+
112+
```python
113+
...
114+
100115
dataset.push(alias="My Confident Dataset", overwrite=False)
101116
```
102117

103118
`deepeval` will prompt you in the terminal if no value for `overwrite` is provided.
104119

105-
:::
106-
107120
## What is a Golden?
108121

109122
A "Golden" is what makes up an evaluation dataset and is very similar to a test case in `deepeval`, but they:

0 commit comments

Comments
 (0)