in function_app/create_content_understanding_analyzers.py [0:0]
def create_config_analyzer_schemas(force_recreation: bool = False):
"""
Create the schemas for the Content Understanding analyzers.
:param force_recreation: If True, the existing analyzers will be recreated
even if it already exists. This is useful when a schema needs to be
updated.
:type force_recreation: bool
"""
# Load existing analyzer schemas
config_path = os.path.join(
os.path.dirname(__file__), "config/content_understanding_schemas.json"
)
with open(config_path, "r") as f:
CONTENT_UNDERSTANDING_SCHEMAS: dict[str, dict[str, dict]] = json.load(f)
# Create analyzers for any missing schemas
analyzer_to_schema_mapper = list()
for _modality, analyzer_schemas in CONTENT_UNDERSTANDING_SCHEMAS.items():
for analyzer_id, schema in analyzer_schemas.items():
analyzer_to_schema_mapper.append((analyzer_id, schema))
cu_client = AzureContentUnderstandingClient(
endpoint=CONTENT_UNDERSTANDING_ENDPOINT,
azure_ad_token_provider=token_provider,
api_version="2024-12-01-preview",
enable_face_identification=False,
)
_cu_analyzer_ids = create_analyzers(
cu_client, analyzer_to_schema_mapper, force_recreation=force_recreation
)