create_asset_builder_template

imerit_ango.sdk.SDK.

create_asset_builder_template(project_id, template)

Create templates to be used while uploading data via asset builder. Learn more about asset builder templates from Asset Builder docs.

Parameters

  • project_id: string

  • template: AssetBuilderTemplate

    An object defining the structure of the template, excluding the _id field. Includes:

    • name: str

      • Unique name for this template.

    • template: str

      • Template HTML that will be filled in while uploading via asset builder.

    • external_id_column: str

      • Column name from the input tabular data to be used as the asset's externalId. In each row, the value in the cell corresponding to this column will be used as the externalId for that row.

    • data_config: Dict[str, DataConfigItem]

      Dictionary mapping column names to their configuration. Each DataConfigItem contains:

      • type: str - The data type for this column. Must be one of: text, link , image , audio , video , iframe , pdf

      • storage: str - Storage configuration for this column. Only necessary when type is one of: video, img, audio, or pdf

      • include_in_export: str (optional, default: False) - Whether to include this column in exports

    • description (Optional): str

      • A description for what the template does or what it is.

    • batch_column (Optional): str

      • Batch column name from the input tabular data to be used as the batch name for that asset. In each row, the value in the cell corresponding to this column will be used as the batch name for that row.

    • pre_label_config (Optional): PreLabelConfig

      Dictionary containing pre-labeling configuration. Each item contains:

      • cla: PreLabelCla - Classification configuration with fields:

        • schemaId: str - Schema identifier

        • title: str - Display title

        • multiple: bool - Whether multiple selections are allowed

      • value: str - Column that will be used as the source of pre-label data

Returns

  • output: AssetBuilderTemplate with _id field

Examples

Basic Template (minimal required fields)

from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
from imerit_ango.sdk import SDK
sdk = SDK("<YOUR_API_KEY")

template = AssetBuilderTemplate(
    name="Simple Image Template",
    template="<img src='{{image_url}}' alt='Sample image' />",
    external_id_column="image_id",
    data_config={
        "image_id": DataConfigItem(
            type="text",
        ),
        "image_url": DataConfigItem(
            type="image",
            storage="<YOUR_STORAGE_INTEGRATION_ID>" # or 'Public' if image is publicly accessible
        )
    }
)

result = sdk.create_asset_builder_template("project_123", template)

Comprehensive Template (all optional fields)

from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
from imerit_ango.sdk import SDK
sdk = SDK("<YOUR_API_KEY")

template = AssetBuilderTemplate(
    name="Video Classification Template",
    template="""
    <div class="video-container">
        <video src='{{video_url}}' controls></video>
        <p>{{description}}</p>
        <a href='{{reference_link}}'>Reference</a>
        <div id="cla-portal-{{classification_schema_id}}">Content classification</div>
        <div id="cla-portal-{{quality_schema_id}}">Quality assessment</div>
    </div>
    """,
    external_id_column="video_id",
    data_config={
        "video_id": DataConfigItem(
            type="text",
            include_in_export=True
        ),
        "video_url": DataConfigItem(
            type="video",
            storage="<YOUR_STORAGE_INTEGRATION_ID>"
        ),
        "description": DataConfigItem(
            type="text",
            include_in_export=True
        ),
        "reference_link": DataConfigItem(
            type="link"
        )
    },
    description="Template for video content classification with descriptions and quality assessment",
    pre_label_config={
        "classification_schema_id": {
            "cla": {
                "schemaId": "schema_123",
                "title": "Content Type",
                "multiple": False,
            },
            "value": "content_type_column"
        },
        "quality_schema_id": {
            "cla": {
                "schemaId": "schema_456",
                "title": "Quality Issues",
                "multiple": True,
            },
            "value": "quality_column"
        }
    }
)

result = sdk.create_asset_builder_template("project_123", template)

Template with Batch Processing

from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
from imerit_ango.sdk import SDK
sdk = SDK("<YOUR_API_KEY")

template = AssetBuilderTemplate(
    name="Batch Image Processing Template",
    template="""
    <div>
        <img src='{{image_url}}' alt='{{image_title}}' />
        <p>{{image_description}}</p>
        <iframe title='{{metadata_url}}' sandbox="" referrerpolicy="no-referrer" src='{{metadata_url}}' width="100%" height="200"></iframe>
        <div id="cla-portal-{{category_schema_id}}">Image Category</div>
        <div id="cla-portal-{{sentiment_schema_id}}">Sentiment Analysis</div>
    </div>
    """,
    external_id_column="image_id",
    data_config={
        "image_id": DataConfigItem(
            type="text",
            include_in_export=True
        ),
        "image_url": DataConfigItem(
            type="image",
            storage="<YOUR_STORAGE_INTEGRATION_ID>"
        ),
        "image_title": DataConfigItem(
            type="text"
        ),
        "image_description": DataConfigItem(
            type="text",
            include_in_export=True
        ),
        "metadata_url": DataConfigItem(
            type="iframe"
        ),
        "batch_group": DataConfigItem(
            type="text"
        )
    },
    description="Template for batch processing of images with categorization and sentiment analysis",
    batch_column="batch_group",
    pre_label_config={
        "category_schema_id": {
            "cla": {
                "schemaId": "cat_202",
                "title": "Image Category",
                "multiple": False,
            },
            "value": "category_column"
        },
        "sentiment_schema_id": {
            "cla": {
                "schemaId": "sent_303",
                "title": "Sentiment",
                "multiple": False,
            },
            "value": "sentiment_column"
        }
    }
)

result = sdk.create_asset_builder_template("project_123", template)

from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
from imerit_ango.sdk import SDK
sdk = SDK("<YOUR_API_KEY")

# Step 1: Create a simple template
template = AssetBuilderTemplate(
    name="Basic Image Template",
    template="<img src='{{image_url}}'/>",
    external_id_column="id",
    data_config={
        "id": DataConfigItem(type="text"),
        "image_url": DataConfigItem(type="image", storage="Public"),
    }
)

# Create template and extract the _id
result = sdk.create_asset_builder_template("project_123", template)
template_id = result["data"]["_id"]

# Step 2: Use the template_id to upload files
sdk.upload_files_with_asset_builder(
    project_id="project_123",
    template_id=template_id,  # Pass the extracted _id here
    input_file_path="data.csv"
)

Last updated