Skip to content

Commit

Permalink
Merge pull request #133 from yus04/feature/fix-deploy-gpt4
Browse files Browse the repository at this point in the history
GPT-4 モデルのデプロイ簡易化
  • Loading branch information
suzukiyuhsuke authored Aug 16, 2024
2 parents d1d05b7 + 12d69e8 commit 3d3a42f
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 79 deletions.
69 changes: 68 additions & 1 deletion 5.internal-document-search/infra/core/ai/cognitiveservices.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,81 @@ param location string = resourceGroup().location
param tags object = {}

param customSubDomainName string = name
param deployments array = []
param kind string = 'OpenAI'
@allowed(['Enabled', 'Disabled'])
param publicNetworkAccess string = 'Enabled'
param sku object = {
name: 'S0'
}

param useOpenAiGpt4 bool = true
param openAiGpt35TurboDeploymentName string = ''
param openAiGpt35Turbo16kDeploymentName string = ''
param openAiGpt4DeploymentName string = ''
param openAiGpt432kDeploymentName string = ''

param openAiGpt35TurboDeployObj object = {
name: openAiGpt35TurboDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-35-turbo'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}

param openAiGpt35Turbo16kDeployObj object = {
name: openAiGpt35Turbo16kDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-35-turbo-16k'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}

param openAiGpt4DeployObj object = {
name: openAiGpt4DeploymentName
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 40
}
}

param openAiGpt432kDeployObj object = {
name: openAiGpt432kDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-4-32k'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 40
}
}

param deployments array = useOpenAiGpt4? [
openAiGpt35TurboDeployObj
openAiGpt35Turbo16kDeployObj
openAiGpt4DeployObj
openAiGpt432kDeployObj
]: [
openAiGpt35TurboDeployObj
openAiGpt35Turbo16kDeployObj
]

resource account 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
name: name
location: location
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/db/cosmosdb.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ param tags object = {}
@allowed(['Enabled', 'Disabled'])
param publicNetworkAccess string

resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
name: name
location: location
tags: tags
Expand Down
4 changes: 2 additions & 2 deletions 5.internal-document-search/infra/core/host/appservice.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ param ftpsState string = 'FtpsOnly'
param healthCheckPath string = ''
param virtualNetworkSubnetId string

resource appService 'Microsoft.Web/sites@2022-03-01' = {
resource appService 'Microsoft.Web/sites@2022-09-01' = {
name: name
location: location
tags: tags
Expand Down Expand Up @@ -95,7 +95,7 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
}
}

resource keyVault 'Microsoft.KeyVault/vaults@2023-02-01' existing = if (!(empty(keyVaultName))) {
resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' existing = if (!(empty(keyVaultName))) {
name: keyVaultName
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ param kind string = ''
param reserved bool = true
param sku object

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
name: name
location: location
tags: tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ param workspaceName string = ''
param location string = resourceGroup().location
param tags object = {}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
name: workspaceName
location: location
tags: tags
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/network/nic.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param publicIPId string
param nsgId string
param isPrivateNetworkEnabled bool

resource networkInterface 'Microsoft.Network/networkInterfaces@2021-02-01' = if (isPrivateNetworkEnabled) {
resource networkInterface 'Microsoft.Network/networkInterfaces@2023-11-01' = if (isPrivateNetworkEnabled) {
name: name
location: location
properties: {
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/network/nsg.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ param name string
param location string
param isPrivateNetworkEnabled bool

resource nsg 'Microsoft.Network/networkSecurityGroups@2021-02-01' = if (isPrivateNetworkEnabled) {
resource nsg 'Microsoft.Network/networkSecurityGroups@2023-11-01' = if (isPrivateNetworkEnabled) {
name: name
location: location
properties: {
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/network/pip.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ param name string
param location string
param isPrivateNetworkEnabled bool

resource publicIP 'Microsoft.Network/publicIPAddresses@2021-02-01' = if (isPrivateNetworkEnabled) {
resource publicIP 'Microsoft.Network/publicIPAddresses@2023-11-01' = if (isPrivateNetworkEnabled) {
name: name
location: location
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource virtualNetworkLinks 'Microsoft.Network/privateDnsZones/virtualNetworkLi
}

// https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/private-link/private-endpoint-overview.md
resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-02-01' = if (isPrivateNetworkEnabled) {
resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-11-01' = if (isPrivateNetworkEnabled) {
name: '${name}-endpoint'
location: location
properties: {
Expand All @@ -44,7 +44,7 @@ resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-02-01' = if (i
}
}

resource privateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-04-01' = if (isPrivateNetworkEnabled) {
resource privateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-11-01' = if (isPrivateNetworkEnabled) {
parent: privateEndpoint
name: privateDnsZone.name
properties: {
Expand Down
4 changes: 2 additions & 2 deletions 5.internal-document-search/infra/core/network/subnet.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ param networkSecurityGroup object = {}
param delegations array = []
param isPrivateNetworkEnabled bool

resource existVnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = if (isPrivateNetworkEnabled) {
resource existVnet 'Microsoft.Network/virtualNetworks@2023-11-01' existing = if (isPrivateNetworkEnabled) {
scope: resourceGroup()
name: existVnetName
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2023-02-01' = if (isPrivateNetworkEnabled) {
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2023-11-01' = if (isPrivateNetworkEnabled) {
parent: existVnet
name: name
properties: {
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/network/vnet.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param location string
param addressPrefixes array
param isPrivateNetworkEnabled bool

resource vnet 'Microsoft.Network/virtualNetworks@2023-02-01' = if (isPrivateNetworkEnabled) {
resource vnet 'Microsoft.Network/virtualNetworks@2023-11-01' = if (isPrivateNetworkEnabled) {
name: name
location: location
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param sku object = {
param authOptions object = {}
param semanticSearch string = 'disabled'

resource search 'Microsoft.Search/searchServices@2021-04-01-preview' = {
resource search 'Microsoft.Search/searchServices@2023-11-01' = {
name: name
location: location
tags: tags
Expand All @@ -19,17 +19,15 @@ resource search 'Microsoft.Search/searchServices@2021-04-01-preview' = {
properties: {
authOptions: authOptions
disableLocalAuth: false
disabledDataExfiltrationOptions: []
encryptionWithCmk: {
enforcement: 'Unspecified'
}
hostingMode: 'default'
networkRuleSet: {
bypass: 'None'
ipRules: []
}
partitionCount: 1
publicNetworkAccess: 'Enabled'
publicNetworkAccess: 'enabled'
replicaCount: 1
semanticSearch: semanticSearch
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ param sku object = { name: 'Standard_LRS' }

param containers array = []

resource storage 'Microsoft.Storage/storageAccounts@2022-05-01' = {
resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: name
location: location
tags: tags
Expand Down
2 changes: 1 addition & 1 deletion 5.internal-document-search/infra/core/vm/vm.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ param imageReference object = {
version: 'latest'
}

resource virtualMachine 'Microsoft.Compute/virtualMachines@2021-04-01' = if (isPrivateNetworkEnabled) {
resource virtualMachine 'Microsoft.Compute/virtualMachines@2023-09-01' = if (isPrivateNetworkEnabled) {
name: name
location: location
properties: {
Expand Down
92 changes: 33 additions & 59 deletions 5.internal-document-search/infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,33 @@ param storageContainerName string = 'content'

param openAiServiceName string = ''
param openAiResourceGroupName string = ''
param openAiResourceGroupLocation string = location

param openAiSkuName string = 'S0'
@allowed([
'1. australiaeast (You can deploy GPT-4 and GPT-3 models)'
'2. canadaeast (You can deploy GPT-4 and GPT-3 models)'
'3. swedencentral (You can deploy GPT-4 and GPT-3 models)'
'4. switzerlandnorth (You can deploy GPT-4 and GPT-3 models)'
'5. eastus (You can deploy only GPT-3 models)'
'6. eastus2 (You can deploy only GPT-3 models)'
'7. francecentral (You can deploy only GPT-3 models)'
'8. japaneast (You can deploy only GPT-3 models)'
'9. northcentralus (You can deploy only GPT-3 models)'
'10. uksouth (You can deploy only GPT-3 models)'
])
param AzureOpenAIServiceRegion string

param delimiters array = ['.', '(']
param aoaiRegionWithBlankSpace string = split(AzureOpenAIServiceRegion, delimiters)[1]
param openAiResourceGroupLocation string = trim(aoaiRegionWithBlankSpace)
param useOpenAiGpt4 bool = contains(AzureOpenAIServiceRegion, 'GPT-4')

param openAiSkuName string = 'S0'
param openAiGpt35TurboDeploymentName string = 'gpt-35-turbo-deploy'
param openAiGpt35Turbo16kDeploymentName string = 'gpt-35-turbo-16k-deploy'
param openAiGpt4DeploymentName string = 'gpt-4-deploy'
param openAiGpt432kDeploymentName string = 'gpt-4-32k-deploy'
param openAiApiVersion string = '2023-05-15'


param formRecognizerServiceName string = ''
param formRecognizerResourceGroupName string = ''
param formRecognizerResourceGroupLocation string = location
Expand Down Expand Up @@ -102,29 +118,29 @@ var resourceToken = toLower(uniqueString(subscription().id, environmentName, loc
var tags = { 'azd-env-name': environmentName }

// Organize resources in a resource group
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
resource resourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
location: location
tags: tags
}

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

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

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

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

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

Expand Down Expand Up @@ -217,56 +233,11 @@ module openAi 'core/ai/cognitiveservices.bicep' = {
sku: {
name: openAiSkuName
}
deployments: [
{
name: openAiGpt35TurboDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-35-turbo'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}
{
name: openAiGpt35Turbo16kDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-35-turbo-16k'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}
{
name: openAiGpt4DeploymentName
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}
{
name: openAiGpt432kDeploymentName
model: {
format: 'OpenAI'
name: 'gpt-4-32k'
version: '0613'
}
sku: {
name: 'Standard'
capacity: 120
}
}
]
useOpenAiGpt4: useOpenAiGpt4
openAiGpt35TurboDeploymentName: openAiGpt35TurboDeploymentName
openAiGpt35Turbo16kDeploymentName: openAiGpt35Turbo16kDeploymentName
openAiGpt4DeploymentName: openAiGpt4DeploymentName
openAiGpt432kDeploymentName: openAiGpt432kDeploymentName
publicNetworkAccess: isPrivateNetworkEnabled ? 'Disabled' : 'Enabled'
}
}
Expand All @@ -282,6 +253,7 @@ module formRecognizer 'core/ai/cognitiveservices.bicep' = {
sku: {
name: formRecognizerSkuName
}
deployments: []
}
}

Expand Down Expand Up @@ -736,6 +708,8 @@ output AZURE_OPENAI_GPT_35_TURBO_16K_DEPLOYMENT string = openAiGpt35Turbo16kDepl
output AZURE_OPENAI_GPT_4_DEPLOYMENT string = openAiGpt4DeploymentName
output AZURE_OPENAI_GPT_4_32K_DEPLOYMENT string = openAiGpt432kDeploymentName
output AZURE_OPENAI_API_VERSION string = openAiApiVersion
output AZURE_OPENAI_RESOURCE_GROUP_LOCATION string = openAiResourceGroupLocation
output USE_OPENAI_GPT4 bool = useOpenAiGpt4

output AZURE_FORMRECOGNIZER_SERVICE string = formRecognizer.outputs.name
output AZURE_FORMRECOGNIZER_RESOURCE_GROUP string = formRecognizerResourceGroup.name
Expand Down

0 comments on commit 3d3a42f

Please sign in to comment.