Skip to content

Commit 1473dd6

Browse files
updated the post deployment script for Legal Cotract scenario
1 parent cf77e12 commit 1473dd6

File tree

4 files changed

+74
-11
lines changed

4 files changed

+74
-11
lines changed

infra/main.bicep

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,7 @@ param storageContainerName string = 'sample-dataset'
15351535
param storageContainerNameRetailCustomer string = 'retail-dataset-customer'
15361536
param storageContainerNameRetailOrder string = 'retail-dataset-order'
15371537
param storageContainerNameRFP string = 'rfp-dataset'
1538+
param storageContainerNameLegalContract string = 'legal-contract-dataset'
15381539
module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
15391540
name: take('avm.res.storage.storage-account.${storageAccountName}', 64)
15401541
params: {
@@ -1604,6 +1605,10 @@ module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
16041605
name: storageContainerNameRFP
16051606
publicAccess: 'None'
16061607
}
1608+
{
1609+
name: storageContainerNameLegalContract
1610+
publicAccess: 'None'
1611+
}
16071612
]
16081613
deleteRetentionPolicyDays: 9
16091614
deleteRetentionPolicyEnabled: true
@@ -1615,7 +1620,7 @@ module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
16151620
// ========== Search Service ========== //
16161621

16171622
var searchServiceName = 'srch-${solutionSuffix}'
1618-
var aiSearchIndexName = 'sample-dataset-index'
1623+
var aiSearchIndexNameForLegalContract = 'sample-dataset-index'
16191624
var aiSearchIndexNameForRetailCustomer = 'macae-retail-customer-index'
16201625
var aiSearchIndexNameForRetailOrder = 'macae-retail-order-index'
16211626
var aiSearchIndexNameForRFP = 'macae-rfp-index'
@@ -1822,7 +1827,9 @@ output AZURE_DEV_COLLECT_TELEMETRY string = 'no'
18221827
output AZURE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER string = storageContainerNameRetailCustomer
18231828
output AZURE_STORAGE_CONTAINER_NAME_RETAIL_ORDER string = storageContainerNameRetailOrder
18241829
output AZURE_STORAGE_CONTAINER_NAME_RFP string = storageContainerNameRFP
1830+
output AZURE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT string = storageContainerNameLegalContract
18251831
output AZURE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER string = aiSearchIndexNameForRetailCustomer
18261832
output AZURE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER string = aiSearchIndexNameForRetailOrder
18271833
output AZURE_AI_SEARCH_INDEX_NAME_RFP string = aiSearchIndexNameForRFP
1834+
output AZURE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT string = aiSearchIndexNameForLegalContract
18281835

infra/scripts/Selecting-Team-Config-And-Data.ps1

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ $storageAccount = ""
1111
$blobContainerForRetailCustomer = ""
1212
$blobContainerForRetailOrder = ""
1313
$blobContainerForRFP = ""
14+
$blobContainerForLegalContract = ""
1415
$aiSearch = ""
1516
$aiSearchIndexForRetailCustomer = ""
1617
$aiSearchIndexForRetailOrder = ""
1718
$aiSearchIndexForRFP = ""
19+
$aiSearchIndexForLegalContract = ""
1820
$azSubscriptionId = ""
1921

2022
function Test-AzdInstalled {
@@ -40,10 +42,12 @@ function Get-ValuesFromAzdEnv {
4042
$script:blobContainerForRetailCustomer = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER)
4143
$script:blobContainerForRetailOrder = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RETAIL_ORDER)
4244
$script:blobContainerForRFP = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RFP)
45+
$script:blobContainerForLegalContract = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT)
4346
$script:aiSearch = $(azd env get-value AZURE_AI_SEARCH_NAME)
4447
$script:aiSearchIndexForRetailCustomer = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER)
4548
$script:aiSearchIndexForRetailOrder = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER)
4649
$script:aiSearchIndexForRFP = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RFP)
50+
$script:aiSearchIndexForLegalContract = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT)
4751
$script:ResourceGroup = $(azd env get-value AZURE_RESOURCE_GROUP)
4852

4953
# Validate that we got all required values
@@ -81,9 +85,11 @@ function Get-ValuesFromAzDeployment {
8185
$script:blobContainerForRetailCustomer = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER.value
8286
$script:blobContainerForRetailOrder = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RETAIL_ORDER.value
8387
$script:blobContainerForRFP = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RFP.value
88+
$script:blobContainerForLegalContract = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT.value
8489
$script:aiSearchIndexForRetailCustomer = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER.value
8590
$script:aiSearchIndexForRetailOrder = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER.value
8691
$script:aiSearchIndexForRFP = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RFP.value
92+
$script:aiSearchIndexForLegalContract = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT.value
8793
$script:aiSearch = $deploymentOutputs.azurE_AI_SEARCH_NAME.value
8894
$script:backendUrl = $deploymentOutputs.backenD_URL.value
8995

@@ -200,7 +206,8 @@ Write-Host "1. RFP Evaluation"
200206
Write-Host "2. Retail Customer Satisfaction"
201207
Write-Host "3. HR Employee Onboarding"
202208
Write-Host "4. Marketing Press Release"
203-
Write-Host "5. All"
209+
Write-Host "5. Legal Contract Review"
210+
Write-Host "6. All"
204211
Write-Host "==============================================="
205212
Write-Host ""
206213

@@ -209,7 +216,7 @@ do {
209216
$useCaseSelection = Read-Host "Please enter the number of the use case you would like to install."
210217

211218
# Handle both numeric and text input for 'all'
212-
if ($useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
219+
if ($useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
213220
$selectedUseCase = "All"
214221
$useCaseValid = $true
215222
Write-Host "Selected: All use cases will be installed."
@@ -238,9 +245,15 @@ do {
238245
Write-Host "Selected: Marketing Press Release"
239246
Write-Host "Note: If you choose to install a single use case, installation of other use cases will require re-running this script."
240247
}
248+
elseif ($useCaseSelection -eq "5") {
249+
$selectedUseCase = "Legal Contract Review"
250+
$useCaseValid = $true
251+
Write-Host "Selected: Legal Contract Review"
252+
Write-Host "Note: If you choose to install a single use case, installation of other use cases will require re-running this script."
253+
}
241254
else {
242255
$useCaseValid = $false
243-
Write-Host "Invalid selection. Please enter a number from 1-5." -ForegroundColor Red
256+
Write-Host "Invalid selection. Please enter a number from 1-6." -ForegroundColor Red
244257
}
245258
} while (-not $useCaseValid)
246259

@@ -325,7 +338,7 @@ $isSampleDataFailed = $false
325338
$failedTeamConfigs = 0
326339

327340
# Use Case 3 -----=--
328-
if($useCaseSelection -eq "3" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
341+
if($useCaseSelection -eq "3" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
329342
Write-Host "Uploading Team Configuration for HR Employee Onboarding..."
330343
$directoryPath = "data/agent_teams"
331344
$teamId = "00000000-0000-0000-0000-000000000001"
@@ -344,7 +357,7 @@ if($useCaseSelection -eq "3" -or $useCaseSelection -eq "all" -or $useCaseSelecti
344357
}
345358

346359
# Use Case 4 -----=--
347-
if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
360+
if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
348361
Write-Host "Uploading Team Configuration for Marketing Press Release..."
349362
$directoryPath = "data/agent_teams"
350363
$teamId = "00000000-0000-0000-0000-000000000002"
@@ -365,7 +378,7 @@ if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelecti
365378
$stIsPublicAccessDisabled = $false
366379
$srchIsPublicAccessDisabled = $false
367380
# Enable public access for resources
368-
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5"){
381+
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6"){
369382
if ($ResourceGroup) {
370383
$stPublicAccess = $(az storage account show --name $storageAccount --resource-group $ResourceGroup --query "publicNetworkAccess" -o tsv)
371384
if ($stPublicAccess -eq "Disabled") {
@@ -399,7 +412,7 @@ if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection
399412

400413

401414

402-
if($useCaseSelection -eq "1" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
415+
if($useCaseSelection -eq "1" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
403416
Write-Host "Uploading Team Configuration for RFP Evaluation..."
404417
$directoryPath = "data/agent_teams"
405418
$teamId = "00000000-0000-0000-0000-000000000004"
@@ -439,7 +452,48 @@ if($useCaseSelection -eq "1" -or $useCaseSelection -eq "all" -or $useCaseSelecti
439452
Write-Host "Python script to index data for RFP Evaluation successfully executed."
440453
}
441454

442-
if($useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
455+
456+
if($useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
457+
Write-Host "Uploading Team Configuration for Legal Contract..."
458+
$directoryPath = "data/agent_teams"
459+
$teamId = "00000000-0000-0000-0000-000000000005"
460+
try {
461+
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/upload_team_config.py", $backendUrl, $directoryPath, $userPrincipalId, $teamId -Wait -NoNewWindow -PassThru
462+
if ($process.ExitCode -ne 0) {
463+
Write-Host "Error: Team configuration for Legal Contract upload failed."
464+
$failedTeamConfigs += 1
465+
$isTeamConfigFailed = $true
466+
}
467+
} catch {
468+
Write-Host "Error: Uploading team configuration failed."
469+
$isTeamConfigFailed = $true
470+
}
471+
Write-Host "Uploaded Team Configuration for Legal Contract..."
472+
473+
$directoryPath = "data/datasets/legal_contract"
474+
# Upload sample files to blob storage
475+
Write-Host "Uploading sample files to blob storage for Legal Contract..."
476+
$result = az storage blob upload-batch --account-name $storageAccount --destination $blobContainerForLegalContract --source $directoryPath --auth-mode login --pattern "*" --overwrite --output none
477+
478+
if ($LASTEXITCODE -ne 0) {
479+
Write-Host "Error: Failed to upload files to blob storage."
480+
$isSampleDataFailed = $true
481+
exit 1
482+
}
483+
Write-Host "Files uploaded successfully to blob storage."
484+
485+
# Run the Python script to index data
486+
Write-Host "Running the python script to index data for Legal Contract"
487+
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/index_datasets.py", $storageAccount, $blobContainerForLegalContract , $aiSearch, $aiSearchIndexForLegalContract -Wait -NoNewWindow -PassThru
488+
489+
if ($process.ExitCode -ne 0) {
490+
Write-Host "Error: Indexing python script execution failed."
491+
$isSampleDataFailed = $true
492+
}
493+
Write-Host "Python script to index data for Legal Contract successfully executed."
494+
}
495+
496+
if($useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
443497
Write-Host "Uploading Team Configuration for Retail Customer Satisfaction..."
444498
$directoryPath = "data/agent_teams"
445499
$teamId = "00000000-0000-0000-0000-000000000003"
@@ -522,7 +576,7 @@ if ($isTeamConfigFailed -or $isSampleDataFailed) {
522576
Write-Host "`nOne or more tasks failed. Please check the error messages above."
523577
exit 1
524578
} else {
525-
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5"){
579+
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6"){
526580
Write-Host "`nTeam configuration upload and sample data processing completed successfully."
527581
}else {
528582
Write-Host "`nTeam configuration upload completed successfully."

infra/scripts/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ azure-identity==1.24.0
33
azure-storage-blob==12.26.0
44
requests==2.32.5
55
azure-core
6-
PyPDF2
6+
PyPDF2
7+
python-docx

infra/scripts/upload_team_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def check_team_exists(backend_url, team_id, user_principal_id):
5151
("marketing.json", "00000000-0000-0000-0000-000000000002"),
5252
("retail.json", "00000000-0000-0000-0000-000000000003"),
5353
("rfp_analysis_team.json", "00000000-0000-0000-0000-000000000004"),
54+
("legal_contract_team.json", "00000000-0000-0000-0000-000000000005"),
5455
]
5556

5657
upload_endpoint = backend_url.rstrip('/') + '/api/v4/upload_team_config'

0 commit comments

Comments
 (0)