diff --git a/infrastructure/terraform/orchestration.tf b/infrastructure/terraform/orchestration.tf index fd3c19c3..99870bf7 100644 --- a/infrastructure/terraform/orchestration.tf +++ b/infrastructure/terraform/orchestration.tf @@ -64,6 +64,8 @@ module "logic_app_orchestration" { FUNCTION_SHORTCLIP_KEY = module.function_shortclip.linux_function_app_primary_key META_PROMPT = data.local_file.file_meta_prompt.content DEFAULT_LANGUAGE = var.default_language + DELETE_ASSISTANT_ENABLED = var.delete_assistant_enabled + } logic_app_always_on = true logic_app_code_path = "${path.module}/../../utilities/logicApp" diff --git a/infrastructure/terraform/variables.tf b/infrastructure/terraform/variables.tf index 7f18268e..973d1a14 100644 --- a/infrastructure/terraform/variables.tf +++ b/infrastructure/terraform/variables.tf @@ -107,3 +107,10 @@ variable "subnet_id" { sensitive = false default = "/subscriptions/be25820a-df86-4794-9e95-6a45cd5c0941/resourceGroups/swedencentral-vnet/providers/Microsoft.Network/virtualNetworks/swedencentral-vnet/subnets/default" } + +variable "delete_assistant_enabled" { + description = "Specifies whether the delete assistant is enabled." + type = bool + sensitive = false + default = false +} diff --git a/utilities/logicApp/OpenAi-Workflow/workflow.json b/utilities/logicApp/OpenAi-Workflow/workflow.json index e2519116..87d7f361 100644 --- a/utilities/logicApp/OpenAi-Workflow/workflow.json +++ b/utilities/logicApp/OpenAi-Workflow/workflow.json @@ -770,6 +770,27 @@ }, "type": "Scope" }, + "OpenAI-DeleteAssistant": { + "inputs": { + "authentication": { + "audience": "https://cognitiveservices.azure.com", + "type": "ManagedServiceIdentity" + }, + "method": "DELETE", + "uri": "@concat(parameters('AZURE_OPENAI_ENDPOINT'), '/openai/assistants/', body('OpenAi-CreateAssisstant-Response')?['id'], '?api-version=2024-03-01-preview')" + }, + "runAfter": { + "Get_Assistant_Messages": [ + "Succeeded" + ] + }, + "runtimeConfiguration": { + "contentTransfer": { + "transferMode": "Chunked" + } + }, + "type": "Http" + }, "Validate_Assistant_Response": { "actions": { "For_each": { @@ -1041,8 +1062,8 @@ } }, "runAfter": { - "Get_Assistant_Messages": [ - "Succeeded" + "OpenAI-DeleteAssistant": [ + "SUCCEEDED" ] }, "type": "Scope" diff --git a/utilities/logicApp/parameters.json b/utilities/logicApp/parameters.json index f62921a7..b8ce0921 100644 --- a/utilities/logicApp/parameters.json +++ b/utilities/logicApp/parameters.json @@ -51,6 +51,10 @@ "type": "String", "value": "@appsetting('AZURE_OPENAI_DEPLOYMENT_NAME')" }, + "DELETE_ASSISTANT_ENABLED": { + "type": "string", + "value": "@appsetting('DELETE_ASSISTANT_ENABLED')" + }, "VIDEO_INDEXER_ID": { "type": "String", "value": "@appsetting('VIDEO_INDEXER_ID')"