Skip to content

Fields

Fields in Argilla define the content of a record that will be reviewed by a user.

Usage Examples

To define a field, instantiate the different field classes 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)
image_field = rg.ImageField(name="image")

The fields parameter of the Settings class can accept a list of fields, like this:

settings = rg.Settings(
    fields=[
        text_field,
        markdown_field,
        image_field,
    ],
    questions=[
        rg.TextQuestion(name="response"),
    ],
)

data = rg.Dataset(
    name="my_dataset",
    settings=settings,
)

To add records with values for fields, refer to the rg.Dataset.records documentation.


TextField

Bases: AbstractField

Text field for use in Argilla Dataset Settings

Source code in src/argilla/settings/_field.py
class TextField(AbstractField):
    """Text field for use in Argilla `Dataset` `Settings`"""

    def __init__(
        self,
        name: str,
        title: Optional[str] = None,
        use_markdown: Optional[bool] = False,
        required: bool = True,
        description: Optional[str] = None,
        client: Optional[Argilla] = 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 (bool): Whether the field is required. Defaults to True.
            description (Optional[str], optional): The description of the field. Defaults to None.

        """

        super().__init__(
            name=name,
            title=title,
            required=required,
            description=description,
            settings=TextFieldSettings(use_markdown=use_markdown),
            _client=client,
        )

    @property
    def use_markdown(self) -> Optional[bool]:
        return self._model.settings.use_markdown

    @use_markdown.setter
    def use_markdown(self, value: bool) -> None:
        self._model.settings.use_markdown = value

__init__(name, title=None, use_markdown=False, required=True, description=None, client=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 (bool): 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/settings/_field.py
def __init__(
    self,
    name: str,
    title: Optional[str] = None,
    use_markdown: Optional[bool] = False,
    required: bool = True,
    description: Optional[str] = None,
    client: Optional[Argilla] = 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 (bool): Whether the field is required. Defaults to True.
        description (Optional[str], optional): The description of the field. Defaults to None.

    """

    super().__init__(
        name=name,
        title=title,
        required=required,
        description=description,
        settings=TextFieldSettings(use_markdown=use_markdown),
        _client=client,
    )

ImageField

Bases: AbstractField

Image field for use in Argilla Dataset Settings

Source code in src/argilla/settings/_field.py
class ImageField(AbstractField):
    """Image field for use in Argilla `Dataset` `Settings`"""

    def __init__(
        self,
        name: str,
        title: Optional[str] = None,
        required: Optional[bool] = True,
        description: Optional[str] = None,
        _client: Optional[Argilla] = 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.
            required (Optional[bool], optional): Whether the field is required. Defaults to True.
            description (Optional[str], optional): The description of the field. Defaults to None.
        """

        super().__init__(
            name=name,
            title=title,
            required=required,
            description=description,
            settings=ImageFieldSettings(),
            _client=_client,
        )

__init__(name, title=None, required=True, description=None, _client=None)

Text field for use in Argilla Dataset Settings

Parameters:

Name Type Description Default
name str

The name of the field

required
title Optional[str]

The title of the field. Defaults to None.

None
required Optional[bool]

Whether the field is required. Defaults to True.

True
description Optional[str]

The description of the field. Defaults to None.

None
Source code in src/argilla/settings/_field.py
def __init__(
    self,
    name: str,
    title: Optional[str] = None,
    required: Optional[bool] = True,
    description: Optional[str] = None,
    _client: Optional[Argilla] = 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.
        required (Optional[bool], optional): Whether the field is required. Defaults to True.
        description (Optional[str], optional): The description of the field. Defaults to None.
    """

    super().__init__(
        name=name,
        title=title,
        required=required,
        description=description,
        settings=ImageFieldSettings(),
        _client=_client,
    )

ChatField

Bases: AbstractField

Chat field for use in Argilla Dataset Settings

Source code in src/argilla/settings/_field.py
class ChatField(AbstractField):
    """Chat field for use in Argilla `Dataset` `Settings`"""

    def __init__(
        self,
        name: str,
        title: Optional[str] = None,
        use_markdown: Optional[bool] = True,
        required: bool = True,
        description: Optional[str] = None,
        _client: Optional[Argilla] = None,
    ) -> None:
        """
        Chat 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 True.
            required (bool): Whether the field is required. Defaults to True.
            description (Optional[str], optional): The description of the field. Defaults to None.
        """

        super().__init__(
            name=name,
            title=title,
            required=required,
            description=description,
            settings=ChatFieldSettings(use_markdown=use_markdown),
            _client=_client,
        )

    @property
    def use_markdown(self) -> Optional[bool]:
        return self._model.settings.use_markdown

    @use_markdown.setter
    def use_markdown(self, value: bool) -> None:
        self._model.settings.use_markdown = value

__init__(name, title=None, use_markdown=True, required=True, description=None, _client=None)

Chat field for use in Argilla Dataset Settings

Parameters:

Name Type Description Default
name str

The name of the field

required
title Optional[str]

The title of the field. Defaults to None.

None
use_markdown Optional[bool]

Whether to use markdown. Defaults to True.

True
required bool

Whether the field is required. Defaults to True.

True
description Optional[str]

The description of the field. Defaults to None.

None
Source code in src/argilla/settings/_field.py
def __init__(
    self,
    name: str,
    title: Optional[str] = None,
    use_markdown: Optional[bool] = True,
    required: bool = True,
    description: Optional[str] = None,
    _client: Optional[Argilla] = None,
) -> None:
    """
    Chat 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 True.
        required (bool): Whether the field is required. Defaults to True.
        description (Optional[str], optional): The description of the field. Defaults to None.
    """

    super().__init__(
        name=name,
        title=title,
        required=required,
        description=description,
        settings=ChatFieldSettings(use_markdown=use_markdown),
        _client=_client,
    )

CustomField

Bases: AbstractField

Custom field for use in Argilla Dataset Settings

Source code in src/argilla/settings/_field.py
class CustomField(AbstractField):
    """Custom field for use in Argilla `Dataset` `Settings`"""

    def __init__(
        self,
        name: str,
        title: Optional[str] = None,
        template: Optional[str] = "",
        advanced_mode: Optional[bool] = False,
        required: bool = True,
        description: Optional[str] = None,
        _client: Optional[Argilla] = None,
    ) -> None:
        """
        Custom field for use in Argilla `Dataset` `Settings` for working with custom HTML and CSS templates.
        By default argilla will use a brackets syntax engine for the templates, which converts
        `{{ field.key }}` to the values of record's field's object.

        Parameters:
            name (str): The name of the field
            title (Optional[str], optional): The title of the field. Defaults to None.
            template (str): The template of the field (HTML and CSS)
            advanced_mode (Optional[bool], optional): Whether to use advanced mode. Defaults to False.
                Deactivate the brackets syntax engine and use custom javascript to render the field.
            required (Optional[bool], optional): Whether the field is required. Defaults to True.
            required (bool): Whether the field is required. Defaults to True.
            description (Optional[str], optional): The description of the field. Defaults to None.
        """
        template = self._load_template(template)
        super().__init__(
            name=name,
            title=title,
            required=required,
            description=description,
            settings=CustomFieldSettings(template=template, advanced_mode=advanced_mode),
            _client=_client,
        )

    @property
    def template(self) -> Optional[str]:
        return self._model.settings.template

    @template.setter
    def template(self, value: str) -> None:
        self._model.settings.template = self._load_template(value)

    @property
    def advanced_mode(self) -> Optional[bool]:
        return self._model.settings.advanced_mode

    @advanced_mode.setter
    def advanced_mode(self, value: bool) -> None:
        self._model.settings.advanced_mode = value

    def validate(self):
        if self.template is None or self.template.strip() == "":
            raise SettingsError("A valid template is required for CustomField")

    @classmethod
    def _load_template(cls, template: str) -> str:
        if template.endswith(".html") and os.path.exists(template):
            with open(template, "r") as f:
                return f.read()
        if template.startswith("http") or template.startswith("https"):
            return requests.get(template).text
        if isinstance(template, str):
            return template
        raise ArgillaError(
            "Invalid template. Please provide 1: a valid path or URL to a HTML file. 2: a valid HTML string."
        )

__init__(name, title=None, template='', advanced_mode=False, required=True, description=None, _client=None)

Custom field for use in Argilla Dataset Settings for working with custom HTML and CSS templates. By default argilla will use a brackets syntax engine for the templates, which converts {{ field.key }} to the values of record's field's object.

Parameters:

Name Type Description Default
name str

The name of the field

required
title Optional[str]

The title of the field. Defaults to None.

None
template str

The template of the field (HTML and CSS)

''
advanced_mode Optional[bool]

Whether to use advanced mode. Defaults to False. Deactivate the brackets syntax engine and use custom javascript to render the field.

False
required Optional[bool]

Whether the field is required. Defaults to True.

True
required bool

Whether the field is required. Defaults to True.

True
description Optional[str]

The description of the field. Defaults to None.

None
Source code in src/argilla/settings/_field.py
def __init__(
    self,
    name: str,
    title: Optional[str] = None,
    template: Optional[str] = "",
    advanced_mode: Optional[bool] = False,
    required: bool = True,
    description: Optional[str] = None,
    _client: Optional[Argilla] = None,
) -> None:
    """
    Custom field for use in Argilla `Dataset` `Settings` for working with custom HTML and CSS templates.
    By default argilla will use a brackets syntax engine for the templates, which converts
    `{{ field.key }}` to the values of record's field's object.

    Parameters:
        name (str): The name of the field
        title (Optional[str], optional): The title of the field. Defaults to None.
        template (str): The template of the field (HTML and CSS)
        advanced_mode (Optional[bool], optional): Whether to use advanced mode. Defaults to False.
            Deactivate the brackets syntax engine and use custom javascript to render the field.
        required (Optional[bool], optional): Whether the field is required. Defaults to True.
        required (bool): Whether the field is required. Defaults to True.
        description (Optional[str], optional): The description of the field. Defaults to None.
    """
    template = self._load_template(template)
    super().__init__(
        name=name,
        title=title,
        required=required,
        description=description,
        settings=CustomFieldSettings(template=template, advanced_mode=advanced_mode),
        _client=_client,
    )