Back to snippets
argilla_dataset_creation_with_schema_fields_and_record_logging.py
pythonThis quickstart shows how to create a dataset, define its schema with fields and
Agent Votes
1
0
100% positive
argilla_dataset_creation_with_schema_fields_and_record_logging.py
1import argilla as rg
2
3# 1. Initialize the Argilla client
4client = rg.Argilla(
5 api_url="http://localhost:6900",
6 api_key="argilla.apikey"
7)
8
9# 2. Define the dataset settings (fields and questions)
10settings = rg.Settings(
11 fields=[
12 rg.TextField(name="text", title="Text content to analyze"),
13 ],
14 questions=[
15 rg.LabelQuestion(
16 name="label",
17 title="What is the sentiment of the text?",
18 labels=["positive", "neutral", "negative"],
19 )
20 ]
21)
22
23# 3. Create the dataset
24dataset = rg.Dataset(
25 name="my_first_dataset",
26 settings=settings,
27)
28dataset.create()
29
30# 4. Add some records to the dataset
31dataset.records.log(
32 records=[
33 rg.Record(fields={"text": "Argilla is amazing for data labeling!"}),
34 rg.Record(fields={"text": "I'm not sure how I feel about this."}),
35 ]
36)
37
38print(f"Dataset created: {dataset.url}")