Fields
Fields in Argilla are define the content of a record that will be reviewed by a user.
Usage Examples
To define a field, instantiate the TextField
class and pass it to the fields
parameter of the Settings
class.
text_field = rg.TextField(name="text")
markdown_field = rg.TextField(name="text", use_markdown=True)
The fields
parameter of the Settings
class can accept a list of fields, like this:
settings = rg.Settings(
fields=[
rg.TextField(name="text"),
],
)
data = rg.Dataset(
name="my_dataset",
settings=settings,
)
To add records with values for fields, refer to the rg.Dataset.records
documentation.
Class References
rg.TextField
Bases: SettingsPropertyBase
Text field for use in Argilla Dataset
Settings
Source code in src/argilla_sdk/settings/_field.py
| class TextField(SettingsPropertyBase):
"""Text field for use in Argilla `Dataset` `Settings`"""
_model: TextFieldModel
def __init__(
self,
name: str,
title: Optional[str] = None,
use_markdown: Optional[bool] = False,
required: Optional[bool] = True,
description: Optional[str] = None,
) -> None:
"""Text field for use in Argilla `Dataset` `Settings`
Parameters:
name (str): The name of the field
title (Optional[str], optional): The title of the field. Defaults to None.
use_markdown (Optional[bool], optional): Whether to use markdown. Defaults to False.
required (Optional[bool], optional): Whether the field is required. Defaults to True.
description (Optional[str], optional): The description of the field. Defaults to None.
"""
self._model = TextFieldModel(
name=name,
title=title,
required=required or True,
description=description,
settings=FieldSettings(type="text", use_markdown=use_markdown),
)
@property
def use_markdown(self) -> Optional[bool]:
return self._model.settings.use_markdown
@classmethod
def from_model(cls, model: TextFieldModel) -> "TextField":
instance = cls(name=model.name)
instance._model = model
return instance
|
__init__(name, title=None, use_markdown=False, required=True, description=None)
Text field for use in Argilla Dataset
Settings
Parameters:
name (str): The name of the field
title (Optional[str], optional): The title of the field. Defaults to None.
use_markdown (Optional[bool], optional): Whether to use markdown. Defaults to False.
required (Optional[bool], optional): Whether the field is required. Defaults to True.
description (Optional[str], optional): The description of the field. Defaults to None.
Source code in src/argilla_sdk/settings/_field.py
| def __init__(
self,
name: str,
title: Optional[str] = None,
use_markdown: Optional[bool] = False,
required: Optional[bool] = True,
description: Optional[str] = None,
) -> None:
"""Text field for use in Argilla `Dataset` `Settings`
Parameters:
name (str): The name of the field
title (Optional[str], optional): The title of the field. Defaults to None.
use_markdown (Optional[bool], optional): Whether to use markdown. Defaults to False.
required (Optional[bool], optional): Whether the field is required. Defaults to True.
description (Optional[str], optional): The description of the field. Defaults to None.
"""
self._model = TextFieldModel(
name=name,
title=title,
required=required or True,
description=description,
settings=FieldSettings(type="text", use_markdown=use_markdown),
)
|