diff --git a/app/Directory.Packages.props b/app/Directory.Packages.props index 02ca95bd..59a554a3 100644 --- a/app/Directory.Packages.props +++ b/app/Directory.Packages.props @@ -45,6 +45,7 @@ + diff --git a/app/functions/EmbedFunctions/EmbedFunctions.csproj b/app/functions/EmbedFunctions/EmbedFunctions.csproj index 0cefdf0e..51c86bde 100644 --- a/app/functions/EmbedFunctions/EmbedFunctions.csproj +++ b/app/functions/EmbedFunctions/EmbedFunctions.csproj @@ -21,6 +21,7 @@ + diff --git a/app/shared/Shared/EmbeddingType.cs b/app/shared/Shared/EmbeddingType.cs index 9b114730..ce15aa8b 100644 --- a/app/shared/Shared/EmbeddingType.cs +++ b/app/shared/Shared/EmbeddingType.cs @@ -26,5 +26,11 @@ public enum EmbeddingType /// Embed using the Milvus Vector Database. /// See https://milvus.io /// - Milvus = 3 + Milvus = 3, + + /// + /// Embed using the Redis Vector Database. + /// See https://redis.com + /// + Redis = 4 }; diff --git a/infra/main.bicep b/infra/main.bicep index eb1225ea..f1ac67be 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -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 = '' @@ -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)) @@ -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 } @@ -250,6 +269,10 @@ module keyVaultSecrets 'core/security/keyvault-secrets.bicep' = { name: 'UseVision' value: useVision ? 'true' : 'false' } + { + name: 'UseRedis' + value: useRedis ? 'true' : 'false' + } ], useAOAI ? [ { @@ -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 + } ] : []) } } @@ -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 } @@ -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 @@ -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 diff --git a/infra/main.parameters.json b/infra/main.parameters.json index acbd00ac..ea57cb67 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -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" }, @@ -89,6 +95,9 @@ "useVision": { "value": "${USE_VISION=false}" }, + "useRedis": { + "value": "${USE_REDIS=false}" + }, "openAiChatGptDeployment": { "value": "${OPENAI_CHATGPT_DEPLOYMENT=gpt-3.5-turbo}" },