# test model
class TestModel(BaseModel):
id: int
str
name: str
description: "tag1", "tag2", "tag3"]
tags: t.Literal[ result: MetricResult
Dataset
A python list like object that contains your evaluation data.
Dataset
Dataset (name:str, model:Type[ragas_experimental.model.pydantic_model.Ext endedPydanticBaseModel], project_id:str, dataset_id:str, ragas_a pi_client:ragas_experimental.backends.ragas_api_client.RagasApiC lient)
*A list-like interface for managing dataset entries with backend synchronization.
This class behaves like a Python list while synchronizing operations with the Ragas backend API.*
= {} TestModel.__column_mapping__
= TestModel(
test_model id=0,
="test",
name="test description",
description=MetricResult(result=0.5, reason="test reason"),
result="tag1"
tags
) test_model
TestModel(id=0, name='test', description='test description', tags='tag1', result=0.5)
test_model.__column_mapping__
{'id': 'id',
'name': 'name',
'description': 'description',
'tags': 'tags',
'result': 'result',
'result_reason': 'result_reason'}
import os
from ragas_experimental import Project
= "api_key"
RAGAS_APP_TOKEN = "https://api.dev.app.ragas.io"
RAGAS_API_BASE_URL
"RAGAS_APP_TOKEN"] = RAGAS_APP_TOKEN
os.environ["RAGAS_API_BASE_URL"] = RAGAS_API_BASE_URL os.environ[
= RagasApiClientFactory.create() ragas_api_client
= Project(project_id="3d9b529b-c23f-4e87-8a26-dd1923749aa7", ragas_api_client=ragas_api_client)
p = p.create_dataset(name="TestModel_with_long_text", model=TestModel)
test_dataset test_dataset
Dataset(name=TestModel_with_long_text, model=TestModel, len=0)
# https://dev.app.ragas.io/dashboard/projects/0a7c4ecb-b313-4bb0-81c0-852c9634ce03/datasets/a4f0d169-ebce-4a2b-b758-0ff49c0c4312
= p.project_id
TEST_PROJECT_ID = test_dataset.dataset_id
TEST_DATASET_ID = await ragas_api_client.get_project(project_id=TEST_PROJECT_ID)
test_project = await ragas_api_client.get_dataset(project_id=TEST_PROJECT_ID, dataset_id=TEST_DATASET_ID)
test_dataset test_dataset
{'id': 'aa1fb420-4820-45a6-9502-6cfb7938b7a3',
'name': 'TestModel_with_long_text',
'description': None,
'created_at': '2025-04-16T18:54:04.355883+00:00',
'updated_at': '2025-04-16T18:54:04.355883+00:00',
'version_counter': 0,
'project_id': '3d9b529b-c23f-4e87-8a26-dd1923749aa7'}
= Dataset(
dataset ="TestModel", model=TestModel, project_id=TEST_PROJECT_ID, dataset_id=TEST_DATASET_ID, ragas_api_client=ragas_api_client
name )
Dataset.append
Dataset.append (entry:~BaseModelType)
Add a new entry to the dataset and sync to Notion.
dataset.append(test_model)len(dataset)
1
Dataset.pop
Dataset.pop (index:int=-1)
Remove and return entry at index, sync deletion to Notion.
dataset.pop()len(dataset)
0
# now add some more entries
for i in range(10):
dataset.append(test_model)len(dataset)
10
Dataset.load
Dataset.load ()
Load all entries from the backend API.
dataset.load()
Dataset.load_as_dicts
Dataset.load_as_dicts ()
Load all entries as dictionaries.
dataset.load_as_dicts()
[{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0}]
Dataset.to_pandas
Dataset.to_pandas ()
Convert dataset to pandas DataFrame.
dataset.to_pandas()
id | name | description | result | |
---|---|---|---|---|
0 | 0 | test | test description | 0.5 |
1 | 0 | test | test description | 0.5 |
2 | 0 | test | test description | 0.5 |
3 | 0 | test | test description | 0.5 |
4 | 0 | test | test description | 0.5 |
5 | 0 | test | test description | 0.5 |
6 | 0 | test | test description | 0.5 |
7 | 0 | test | test description | 0.5 |
8 | 0 | test | test description | 0.5 |
9 | 0 | test | test description | 0.5 |
10 | 0 | test | test description | 0.5 |
11 | 0 | test | test description | 0.5 |
Dataset.save
Dataset.save (item:~BaseModelType)
Save changes to an item to the backend.
= dataset[0]
d d
TestModel(id=0, name='updated name', description='test description', result=0.5)
= "updated name"
d.name
dataset.save(d)0].name dataset[
'updated name'
dataset.load_as_dicts()
[{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'test',
'id': 0},
{'description': 'test description',
'result': 0.5,
'result_reason': 'test reason',
'name': 'updated name',
'id': 0}]
Dataset.get
Dataset.get (field_value:str, field_name:str='_row_id')
*Get an entry by field value.
Args: id_value: The value to match field_name: The field to match against (default: “id”)
Returns: The matching model instance or None if not found*
d._row_id
'eVpgxsmPGwa8'
= dataset.get(d._row_id)
test_model test_model
TestModel(id=0, name='updated name', description='test description', result=0.5)