from artos import ArtosClient, ProcessingStep
from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
class AzureFoundryPostProcessor:
def __init__(self, api_key, subscription_id, resource_group, workspace_name):
self.client = ArtosClient(api_key=api_key)
self.credential = DefaultAzureCredential()
self.ml_client = MLClient(
credential=self.credential,
subscription_id=subscription_id,
resource_group_name=resource_group,
workspace_name=workspace_name
)
def create_foundry_style_matcher(self, endpoint_name, model_name):
"""Create style matching step using Azure Foundry"""
step = ProcessingStep(
name=f"Foundry Style Matcher ({endpoint_name})",
description=f"Style matching using Azure Foundry {endpoint_name}",
agent_type="style_matcher",
order=2,
configuration={
"foundryConfig": {
"endpointName": endpoint_name,
"modelName": model_name,
"subscriptionId": self.subscription_id,
"resourceGroup": self.resource_group,
"workspaceName": self.workspace_name
},
"styleSettings": {
"tone": "professional",
"formatting": "standard",
"brandGuidelines": "default",
"language": "en",
"formality": "formal"
}
},
conditions={
"contentType": ["document", "email", "report"],
"targetAudience": ["internal", "external"]
}
)
return self.client.post_processing.add_step(step)
def create_foundry_data_validator(self, endpoint_name, model_name):
"""Create data validation step using Azure Foundry"""
step = ProcessingStep(
name=f"Foundry Data Validator ({endpoint_name})",
description=f"Data validation using Azure Foundry {endpoint_name}",
agent_type="data_validator",
order=4,
configuration={
"foundryConfig": {
"endpointName": endpoint_name,
"modelName": model_name,
"subscriptionId": self.subscription_id,
"resourceGroup": self.resource_group,
"workspaceName": self.workspace_name
},
"validationRules": {
"requiredFields": ["id", "name", "value"],
"dataTypes": {
"id": "integer",
"name": "string",
"value": "float"
},
"constraints": {
"minValue": 0,
"maxLength": 255
}
}
},
conditions={
"contentType": ["tabular", "structured"],
"minRows": 1
}
)
return self.client.post_processing.add_step(step)
# Usage
foundry_processor = AzureFoundryPostProcessor(
api_key="your_api_key",
subscription_id="your_subscription_id",
resource_group="your_resource_group",
workspace_name="your_workspace"
)
# Create style matcher step
style_step = foundry_processor.create_foundry_style_matcher(
endpoint_name="style-matcher-endpoint",
model_name="style-matcher-model"
)
# Create data validator step
validator_step = foundry_processor.create_foundry_data_validator(
endpoint_name="data-validator-endpoint",
model_name="data-validator-model"
)