Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,7 @@ param storageContainerName string = 'sample-dataset'
param storageContainerNameRetailCustomer string = 'retail-dataset-customer'
param storageContainerNameRetailOrder string = 'retail-dataset-order'
param storageContainerNameRFP string = 'rfp-dataset'
param storageContainerNameLegalContract string = 'legal-contract-dataset'
module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
name: take('avm.res.storage.storage-account.${storageAccountName}', 64)
params: {
Expand Down Expand Up @@ -1604,6 +1605,10 @@ module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
name: storageContainerNameRFP
publicAccess: 'None'
}
{
name: storageContainerNameLegalContract
publicAccess: 'None'
}
]
deleteRetentionPolicyDays: 9
deleteRetentionPolicyEnabled: true
Expand All @@ -1615,7 +1620,7 @@ module avmStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
// ========== Search Service ========== //

var searchServiceName = 'srch-${solutionSuffix}'
var aiSearchIndexName = 'sample-dataset-index'
var aiSearchIndexNameForLegalContract = 'sample-dataset-index'
var aiSearchIndexNameForRetailCustomer = 'macae-retail-customer-index'
var aiSearchIndexNameForRetailOrder = 'macae-retail-order-index'
var aiSearchIndexNameForRFP = 'macae-rfp-index'
Expand Down Expand Up @@ -1822,7 +1827,9 @@ output AZURE_DEV_COLLECT_TELEMETRY string = 'no'
output AZURE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER string = storageContainerNameRetailCustomer
output AZURE_STORAGE_CONTAINER_NAME_RETAIL_ORDER string = storageContainerNameRetailOrder
output AZURE_STORAGE_CONTAINER_NAME_RFP string = storageContainerNameRFP
output AZURE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT string = storageContainerNameLegalContract
output AZURE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER string = aiSearchIndexNameForRetailCustomer
output AZURE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER string = aiSearchIndexNameForRetailOrder
output AZURE_AI_SEARCH_INDEX_NAME_RFP string = aiSearchIndexNameForRFP
output AZURE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT string = aiSearchIndexNameForLegalContract

72 changes: 63 additions & 9 deletions infra/scripts/Selecting-Team-Config-And-Data.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ $storageAccount = ""
$blobContainerForRetailCustomer = ""
$blobContainerForRetailOrder = ""
$blobContainerForRFP = ""
$blobContainerForLegalContract = ""
$aiSearch = ""
$aiSearchIndexForRetailCustomer = ""
$aiSearchIndexForRetailOrder = ""
$aiSearchIndexForRFP = ""
$aiSearchIndexForLegalContract = ""
$azSubscriptionId = ""

function Test-AzdInstalled {
Expand All @@ -40,10 +42,12 @@ function Get-ValuesFromAzdEnv {
$script:blobContainerForRetailCustomer = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER)
$script:blobContainerForRetailOrder = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RETAIL_ORDER)
$script:blobContainerForRFP = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_RFP)
$script:blobContainerForLegalContract = $(azd env get-value AZURE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT)
$script:aiSearch = $(azd env get-value AZURE_AI_SEARCH_NAME)
$script:aiSearchIndexForRetailCustomer = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER)
$script:aiSearchIndexForRetailOrder = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER)
$script:aiSearchIndexForRFP = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_RFP)
$script:aiSearchIndexForLegalContract = $(azd env get-value AZURE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT)
$script:ResourceGroup = $(azd env get-value AZURE_RESOURCE_GROUP)

# Validate that we got all required values
Expand Down Expand Up @@ -81,9 +85,11 @@ function Get-ValuesFromAzDeployment {
$script:blobContainerForRetailCustomer = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RETAIL_CUSTOMER.value
$script:blobContainerForRetailOrder = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RETAIL_ORDER.value
$script:blobContainerForRFP = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_RFP.value
$script:blobContainerForLegalContract = $deploymentOutputs.azurE_STORAGE_CONTAINER_NAME_LEGAL_CONTRACT.value
$script:aiSearchIndexForRetailCustomer = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RETAIL_CUSTOMER.value
$script:aiSearchIndexForRetailOrder = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RETAIL_ORDER.value
$script:aiSearchIndexForRFP = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_RFP.value
$script:aiSearchIndexForLegalContract = $deploymentOutputs.azurE_AI_SEARCH_INDEX_NAME_LEGAL_CONTRACT.value
$script:aiSearch = $deploymentOutputs.azurE_AI_SEARCH_NAME.value
$script:backendUrl = $deploymentOutputs.backenD_URL.value

Expand Down Expand Up @@ -200,7 +206,8 @@ Write-Host "1. RFP Evaluation"
Write-Host "2. Retail Customer Satisfaction"
Write-Host "3. HR Employee Onboarding"
Write-Host "4. Marketing Press Release"
Write-Host "5. All"
Write-Host "5. Legal Contract Review"
Write-Host "6. All"
Write-Host "==============================================="
Write-Host ""

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

# Handle both numeric and text input for 'all'
if ($useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
if ($useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
$selectedUseCase = "All"
$useCaseValid = $true
Write-Host "Selected: All use cases will be installed."
Expand Down Expand Up @@ -238,9 +245,15 @@ do {
Write-Host "Selected: Marketing Press Release"
Write-Host "Note: If you choose to install a single use case, installation of other use cases will require re-running this script."
}
elseif ($useCaseSelection -eq "5") {
$selectedUseCase = "Legal Contract Review"
$useCaseValid = $true
Write-Host "Selected: Legal Contract Review"
Write-Host "Note: If you choose to install a single use case, installation of other use cases will require re-running this script."
}
else {
$useCaseValid = $false
Write-Host "Invalid selection. Please enter a number from 1-5." -ForegroundColor Red
Write-Host "Invalid selection. Please enter a number from 1-6." -ForegroundColor Red
}
} while (-not $useCaseValid)

Expand Down Expand Up @@ -325,7 +338,7 @@ $isSampleDataFailed = $false
$failedTeamConfigs = 0

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

# Use Case 4 -----=--
if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {
if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
Write-Host "Uploading Team Configuration for Marketing Press Release..."
$directoryPath = "data/agent_teams"
$teamId = "00000000-0000-0000-0000-000000000002"
Expand All @@ -365,7 +378,7 @@ if($useCaseSelection -eq "4" -or $useCaseSelection -eq "all" -or $useCaseSelecti
$stIsPublicAccessDisabled = $false
$srchIsPublicAccessDisabled = $false
# Enable public access for resources
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5"){
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6"){
if ($ResourceGroup) {
$stPublicAccess = $(az storage account show --name $storageAccount --resource-group $ResourceGroup --query "publicNetworkAccess" -o tsv)
if ($stPublicAccess -eq "Disabled") {
Expand Down Expand Up @@ -399,7 +412,7 @@ if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection



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

if($useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5") {

if($useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
Write-Host "Uploading Team Configuration for Legal Contract..."
$directoryPath = "data/agent_teams"
$teamId = "00000000-0000-0000-0000-000000000005"
try {
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/upload_team_config.py", $backendUrl, $directoryPath, $userPrincipalId, $teamId -Wait -NoNewWindow -PassThru
if ($process.ExitCode -ne 0) {
Write-Host "Error: Team configuration for Legal Contract upload failed."
$failedTeamConfigs += 1
$isTeamConfigFailed = $true
}
} catch {
Write-Host "Error: Uploading team configuration failed."
$isTeamConfigFailed = $true
}
Write-Host "Uploaded Team Configuration for Legal Contract..."

$directoryPath = "data/datasets/legal_contract"
# Upload sample files to blob storage
Write-Host "Uploading sample files to blob storage for Legal Contract..."
$result = az storage blob upload-batch --account-name $storageAccount --destination $blobContainerForLegalContract --source $directoryPath --auth-mode login --pattern "*" --overwrite --output none

if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to upload files to blob storage."
$isSampleDataFailed = $true
exit 1
}
Write-Host "Files uploaded successfully to blob storage."

# Run the Python script to index data
Write-Host "Running the python script to index data for Legal Contract"
$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/index_datasets.py", $storageAccount, $blobContainerForLegalContract , $aiSearch, $aiSearchIndexForLegalContract -Wait -NoNewWindow -PassThru

if ($process.ExitCode -ne 0) {
Write-Host "Error: Indexing python script execution failed."
$isSampleDataFailed = $true
}
Write-Host "Python script to index data for Legal Contract successfully executed."
}

if($useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6") {
Write-Host "Uploading Team Configuration for Retail Customer Satisfaction..."
$directoryPath = "data/agent_teams"
$teamId = "00000000-0000-0000-0000-000000000003"
Expand Down Expand Up @@ -522,7 +576,7 @@ if ($isTeamConfigFailed -or $isSampleDataFailed) {
Write-Host "`nOne or more tasks failed. Please check the error messages above."
exit 1
} else {
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "5"){
if($useCaseSelection -eq "1"-or $useCaseSelection -eq "2" -or $useCaseSelection -eq "5" -or $useCaseSelection -eq "all" -or $useCaseSelection -eq "6"){
Write-Host "`nTeam configuration upload and sample data processing completed successfully."
}else {
Write-Host "`nTeam configuration upload completed successfully."
Expand Down
3 changes: 2 additions & 1 deletion infra/scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ azure-identity==1.24.0
azure-storage-blob==12.26.0
requests==2.32.5
azure-core
PyPDF2
PyPDF2
python-docx
1 change: 1 addition & 0 deletions infra/scripts/upload_team_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def check_team_exists(backend_url, team_id, user_principal_id):
("marketing.json", "00000000-0000-0000-0000-000000000002"),
("retail.json", "00000000-0000-0000-0000-000000000003"),
("rfp_analysis_team.json", "00000000-0000-0000-0000-000000000004"),
("legal_contract_team.json", "00000000-0000-0000-0000-000000000005"),
]

upload_endpoint = backend_url.rstrip('/') + '/api/v4/upload_team_config'
Expand Down
Loading