create_asset_builder_template
imerit_ango.sdk.SDK.
create_asset_builder_template(project_id, template)
Create templates to be used while uploading data via the asset builder. Learn more about asset builder templates from the Asset Builder docs.
Parameters
project_id: string
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projects
function.
template: AssetBuilderTemplate
An object defining the structure of the template, excluding the
_id
field. Includes:name: string
Unique name for this template.
template: string
Template HTML that will be filled in while uploading via asset builder.
external_id_column: string
The 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: string - The data type for this column. Must be one of:
"text", "link", "image", "audio", "video", "iframe", "pdf"
storage: string, Optional, default None - Storage configuration for this column. Only necessary when the type is one of: video, image, audio, or pdf.
include_in_export: string, Optional, default False - Whether to include this column in exports
description: string, Optional, default ""
A description of what the template does or what it is.
batch_column: string, Optional, default ""
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: PreLabelConfig
Dictionary containing pre-labeling configuration. Each item contains:
cla: PreLabelCla - Classification configuration with fields:
schemaId: string - Schema identifier
title: string - Display title
multiple: bool - Whether multiple selections are allowed
value: string - Column that will be used as the source of pre-label data
Returns
output: AssetBuilderTemplate with
_id
field
Examples
Basic Template (minimal required fields)
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(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>")})
sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
template_id = sdk_response["data"]["_id"]
Comprehensive Template (all optional fields)
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
load_dotenv("variables.env")
api_key = os.getenv("API_KEY")
project_id = os.getenv("PROJECT_ID")
ango_sdk = SDK(api_key)
# HTML template with placeholders
html_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>
"""
# Data configuration
data_config = {
"video_id": DataConfigItem(type="text", include_in_export=True),
"video_url": DataConfigItem(type="video", storage="<YOUR_STORAGE_ID>"),
"description": DataConfigItem(type="text", include_in_export=True),
"reference_link": DataConfigItem(type="link")
}
# Pre-label configuration
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"
}
}
template = AssetBuilderTemplate(
name="Video Classification Template",
description="Template for video content classification with descriptions and quality assessment",
template=html_template,
external_id_column="video_id",
data_config=data_config,
pre_label_config=pre_label_config
)
sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
Template with Batch Processing
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
load_dotenv("variables.env")
api_key = os.getenv("API_KEY")
project_id = os.getenv("PROJECT_ID")
ango_sdk = SDK(api_key)
html_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>
"""
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")}
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"
}
}
template = AssetBuilderTemplate(
name="Batch Image Processing Template",
template=html_template,
external_id_column="image_id",
data_config=data_config,
description="Template for batch processing of images with categorization and sentiment analysis",
batch_column="batch_group",
pre_label_config=pre_label_config
)
sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
Usage with upload_files_with_asset_builder
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem
load_dotenv("variables.env")
api_key = os.getenv("API_KEY")
project_id = os.getenv("PROJECT_ID")
ango_sdk = SDK(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")})
sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
template_id = sdk_response["data"]["_id"]
# Step 2: Use the template_id to upload files
ango_sdk.upload_files_with_asset_builder(project_id=project_id,
template_id=template_id,
input_file_path="data.csv")
Last updated