def generate_pydantic_schema_for_fields(
    fields: List[Union["AllowedFieldTypes", "AllowedRemoteFieldTypes"]], name: Optional[str] = "FieldsSchema"
) -> typing.Type[BaseModel]:
    """Generates a `pydantic.BaseModel` schema from a list of `AllowedFieldTypes` or `AllowedRemoteFieldTypes`
    objects to validate the fields of a `FeedbackDataset` or `RemoteFeedbackDataset` object, respectively,
    before inserting them.

    Args:
        fields: the list of `AllowedFieldTypes` or `AllowedRemoteFieldTypes` objects to generate the schema from.
        name: the name of the `pydantic.BaseModel` schema to generate. Defaults to "FieldsSchema".

    Returns:
        A `pydantic.BaseModel` schema to validate the fields of a `FeedbackDataset` or `RemoteFeedbackDataset`
        object before inserting them.

    Raises:
        ValueError: if one of the fields has an unsupported type.

    Examples:
        >>> from argilla_v1.client.feedback.schemas.fields import TextField
        >>> from argilla_v1.client.feedback.dataset.helpers import generate_pydantic_schema_for_fields
        >>> fields = [
        ...     TextField(name="text", required=True),
        ...     TextField(name="label", required=True),
        ... ]
        >>> FieldsSchema = generate_pydantic_schema_for_fields(fields)
        >>> FieldsSchema(text="Hello", label="World")
        FieldsSchema(text='Hello', label='World')
    """
    fields_schema = {}
    for field in fields:
        if field.type not in FIELD_TYPE_TO_PYTHON_TYPE.keys():
            raise ValueError(
                f"Field {field.name} has an unsupported type: {field.type}, for the moment only the"
                f" following types are supported: {list(FIELD_TYPE_TO_PYTHON_TYPE.keys())}"
            )
        fields_schema.update({field.name: (FIELD_TYPE_TO_PYTHON_TYPE[field.type], ... if field.required else None)})
    return create_model(name, **fields_schema)
Generates a `pydantic.BaseModel` schema from a list of `AllowedFieldTypes` or `AllowedRemoteFieldTypes`
    objects to validate the fields of a `FeedbackDataset` or `RemoteFeedbackDataset` object, respectively,
    before inserting them.

    Args:
        fields: the list of `AllowedFieldTypes` or `AllowedRemoteFieldTypes` objects to generate the schema from.
        name: the name of the `pydantic.BaseModel` schema to generate. Defaults to "FieldsSchema".

    Returns:
        A `pydantic.BaseModel` schema to validate the fields of a `FeedbackDataset` or `RemoteFeedbackDataset`
        object before inserting them.

    Raises:
        ValueError: if one of the fields has an unsupported type.

    Examples:
        >>> from argilla_v1.client.feedback.schemas.fields import TextField
        >>> from argilla_v1.client.feedback.dataset.helpers import generate_pydantic_schema_for_fields
        >>> fields = [
        ...     TextField(name="text", required=True),
        ...     TextField(name="label", required=True),
        ... ]
        >>> FieldsSchema = generate_pydantic_schema_for_fields(fields)
        >>> FieldsSchema(text="Hello", label="World")
        FieldsSchema(text='Hello', label='World')
    
argilla-v1/src/argilla_v1/client/feedback/dataset/helpers.py