Skip to content

Commit

Permalink
update the main bicep file
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleysmall-microsoft committed Apr 2, 2024
1 parent 2f12360 commit 6f55e36
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<PackageVersion Include="MudBlazor" Version="6.11.1" />
<PackageVersion Include="PdfSharpCore" Version="1.3.62" />
<PackageVersion Include="Pinecone.NET" Version="1.3.2" />
<PackageVersion Include="StackExchange.Redis" Version="2.7.27" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
Expand Down
1 change: 1 addition & 0 deletions app/functions/EmbedFunctions/EmbedFunctions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.Extensions.Azure" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
<PackageReference Include="Pinecone.NET" />
<PackageReference Include="StackExchange.Redis" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\shared\Shared\Shared.csproj" />
Expand Down
8 changes: 7 additions & 1 deletion app/shared/Shared/EmbeddingType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ public enum EmbeddingType
/// Embed using the Milvus Vector Database.
/// See <a href='https://milvus.io'>https://milvus.io</a>
/// </summary>
Milvus = 3
Milvus = 3,

/// <summary>
/// Embed using the Redis Vector Database.
/// See <a href='https://redis.com'>https://redis.com</a>
/// </summary>
Redis = 4
};
52 changes: 52 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ param searchServiceResourceGroupName string = ''
@description('SKU name for the Azure Cognitive Search service. Default: standard')
param searchServiceSkuName string = 'standard'

@description('Name of the Azure Cache for Redis search index. Default: gptkbindex')
param azureCacheIndexName string = 'gptkbindex'

@description('Name of the Azure Cache for Redis service')
param azureCacheName string = ''

@description('Location of the resource group for the Azure Cache for Redis service')
param azureCacheResourceGroupLocation string = location

@description('Name of the resource group for the Azure Cache for Redis service')
param azureCacheResourceGroupName string = ''

@description('Name of the storage account')
param storageAccountName string = ''

Expand Down Expand Up @@ -169,6 +181,9 @@ param openAiEmbeddingDeployment string
@description('Use Vision retrival. default: false')
param useVision bool = false

@description('Use Azure Cache. default: false')
param useRedis bool = false

var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))

Expand Down Expand Up @@ -199,6 +214,10 @@ resource searchServiceResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-
name: !empty(searchServiceResourceGroupName) ? searchServiceResourceGroupName : resourceGroup.name
}

resource azureCacheResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = if (!empty(azureCacheResourceGroupName)) {
name: !empty(azureCacheResourceGroupName) ? azureCacheResourceGroupName : resourceGroup.name
}

resource storageResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = if (!empty(storageResourceGroupName)) {
name: !empty(storageResourceGroupName) ? storageResourceGroupName : resourceGroup.name
}
Expand Down Expand Up @@ -250,6 +269,10 @@ module keyVaultSecrets 'core/security/keyvault-secrets.bicep' = {
name: 'UseVision'
value: useVision ? 'true' : 'false'
}
{
name: 'UseRedis'
value: useRedis ? 'true' : 'false'
}
],
useAOAI ? [
{
Expand Down Expand Up @@ -283,6 +306,16 @@ module keyVaultSecrets 'core/security/keyvault-secrets.bicep' = {
name: 'AzureComputerVisionServiceEndpoint'
value: computerVision.outputs.endpoint
}
] : [],
useRedis ? [
{
name: 'AzureCacheServiceEndpoint'
value: azureCache.outputs.endpoint
}
{
name: 'AzureCacheIndex'
value: azureCacheIndexName
}
] : [])
}
}
Expand Down Expand Up @@ -370,6 +403,9 @@ module function './app/function.bicep' = {
AZURE_OPENAI_ENDPOINT: useAOAI ? azureOpenAi.outputs.endpoint : ''
USE_VISION: string(useVision)
USE_AOAI: string(useAOAI)
USE_REDIS: string(useRedis)
AZURE_CACHE_SERVICE_ENDPOINT: useRedis ? azureCache.outputs.endpoint : ''
AZURE_CACHE_INDEX: azureCacheIndexName
AZURE_COMPUTER_VISION_ENDPOINT: useVision ? computerVision.outputs.endpoint : ''
OPENAI_API_KEY: useAOAI ? '' : openAIApiKey
}
Expand Down Expand Up @@ -493,6 +529,17 @@ module searchService 'core/search/search-services.bicep' = {
}
}

module azureCache 'core/search/azure-cache.bicep' = if (useRedis) {
name: 'azure-cache'
scope: azureCacheResourceGroup
params: {
name: !empty(azureCacheName) ? azureCacheName : 'azurecachekb-${resourceToken}'
location: azureCacheResourceGroupLocation
tags: updatedTags
skuName: 'Enterprise_E5'
}
}

module storage 'core/storage/storage-account.bicep' = {
name: 'storage'
scope: storageResourceGroup
Expand Down Expand Up @@ -757,6 +804,11 @@ output AZURE_SEARCH_INDEX string = searchIndexName
output AZURE_SEARCH_SERVICE string = searchService.outputs.name
output AZURE_SEARCH_SERVICE_ENDPOINT string = searchService.outputs.endpoint
output AZURE_SEARCH_SERVICE_RESOURCE_GROUP string = searchServiceResourceGroup.name
output AZURE_CACHE_INDEX string = azureCacheIndexName
output AZURE_CACHE_SERVICE string = azureCache.outputs.name
output AZURE_CACHE_SERVICE_ENDPOINT string = azureCache.outputs.endpoint
output AZURE_CACHE_SERVICE_RESOURCE_GROUP string = azureCacheResourceGroup.name
output USE_REDIS bool = useRedis
output AZURE_STORAGE_ACCOUNT string = storage.outputs.name
output AZURE_STORAGE_BLOB_ENDPOINT string = storage.outputs.primaryEndpoints.blob
output AZURE_STORAGE_CONTAINER string = storageContainerName
Expand Down
9 changes: 9 additions & 0 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
"searchServiceResourceGroupName": {
"value": "${AZURE_SEARCH_SERVICE_RESOURCE_GROUP}"
},
"azureCacheName": {
"value": "${AZURE_CACHE_SERVICE}"
},
"azureCacheResourceGroupName": {
"value": "${AZURE_CACHE_SERVICE_RESOURCE_GROUP}"
},
"searchServiceSkuName": {
"value": "standard"
},
Expand Down Expand Up @@ -89,6 +95,9 @@
"useVision": {
"value": "${USE_VISION=false}"
},
"useRedis": {
"value": "${USE_REDIS=false}"
},
"openAiChatGptDeployment": {
"value": "${OPENAI_CHATGPT_DEPLOYMENT=gpt-3.5-turbo}"
},
Expand Down

0 comments on commit 6f55e36

Please sign in to comment.