Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure GlobalStandard as default deployment sku for gpt-4o #2030

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"forwardPorts": [
50505
],
"postCreateCommand": "",
"postCreateCommand": "python3 -m pip install -r requirements-dev.txt",
"remoteUser": "vscode",
"hostRequirements": {
"memory": "8gb"
Expand Down
9 changes: 9 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,12 @@ hooks:
run: ./scripts/auth_update.sh;./scripts/prepdocs.sh
interactive: true
continueOnError: false
predown:
windows:
shell: pwsh
run: ./scripts/pre-down.ps1
continueOnError: true
posix:
shell: sh
run: ./scripts/pre-down.sh
continueOnError: true
11 changes: 8 additions & 3 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,37 @@ param chatGptModelName string = ''
param chatGptDeploymentName string = ''
param chatGptDeploymentVersion string = ''
param chatGptDeploymentCapacity int = 0
param chatGptDeploymentSkuName string = ''
var chatGpt = {
modelName: !empty(chatGptModelName)
? chatGptModelName
: startsWith(openAiHost, 'azure') ? 'gpt-35-turbo' : 'gpt-3.5-turbo'
deploymentName: !empty(chatGptDeploymentName) ? chatGptDeploymentName : 'chat'
deploymentVersion: !empty(chatGptDeploymentVersion) ? chatGptDeploymentVersion : '0613'
deploymentCapacity: chatGptDeploymentCapacity != 0 ? chatGptDeploymentCapacity : 30
deploymentSkuName: !empty(chatGptDeploymentSkuName) ? chatGptDeploymentSkuName : 'Standard'
}

param embeddingModelName string = ''
param embeddingDeploymentName string = ''
param embeddingDeploymentVersion string = ''
param embeddingDeploymentCapacity int = 0
param embeddingDimensions int = 0
param embeddingDeploymentSkuName string = ''
var embedding = {
modelName: !empty(embeddingModelName) ? embeddingModelName : 'text-embedding-ada-002'
deploymentName: !empty(embeddingDeploymentName) ? embeddingDeploymentName : 'embedding'
deploymentVersion: !empty(embeddingDeploymentVersion) ? embeddingDeploymentVersion : '2'
deploymentCapacity: embeddingDeploymentCapacity != 0 ? embeddingDeploymentCapacity : 30
deploymentSkuName: !empty(embeddingDeploymentSkuName) ? embeddingDeploymentSkuName : 'Standard'
dimensions: embeddingDimensions != 0 ? embeddingDimensions : 1536
}

param gpt4vModelName string = 'gpt-4o'
param gpt4vDeploymentName string = 'gpt-4o'
param gpt4vModelVersion string = '2024-05-13'
param gpt4vDeploymentCapacity int = 10
param gpt4vDeploymentSkuName string = 'GlobalStandard'

param tenantId string = tenant().tenantId
param authTenantId string = ''
Expand Down Expand Up @@ -453,7 +458,7 @@ var defaultOpenAiDeployments = [
version: chatGpt.deploymentVersion
}
sku: {
name: 'Standard'
name: chatGpt.deploymentSkuName
capacity: chatGpt.deploymentCapacity
}
}
Expand All @@ -465,7 +470,7 @@ var defaultOpenAiDeployments = [
version: embedding.deploymentVersion
}
sku: {
name: 'Standard'
name: embedding.deploymentSkuName
capacity: embedding.deploymentCapacity
}
}
Expand All @@ -483,7 +488,7 @@ var openAiDeployments = concat(
version: gpt4vModelVersion
}
sku: {
name: 'Standard'
name: gpt4vDeploymentSkuName
capacity: gpt4vDeploymentCapacity
}
}
Expand Down
18 changes: 18 additions & 0 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
"chatGptDeploymentCapacity":{
"value": "${AZURE_OPENAI_CHATGPT_DEPLOYMENT_CAPACITY}"
},
"chatGptDeploymentSkuName":{
"value": "${AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU=Standard}"
},
"embeddingModelName":{
"value": "${AZURE_OPENAI_EMB_MODEL_NAME}"
},
Expand All @@ -113,12 +116,27 @@
"embeddingDeploymentCapacity":{
"value": "${AZURE_OPENAI_EMB_DEPLOYMENT_CAPACITY}"
},
"embeddingDeploymentSkuName":{
"value": "${AZURE_OPENAI_EMB_DEPLOYMENT_SKU=Standard}"
},
"embeddingDimensions": {
"value": "${AZURE_OPENAI_EMB_DIMENSIONS}"
},
"gpt4vModelName": {
"value": "${AZURE_OPENAI_GPT4V_MODEL_NAME=gpt-4o}"
},
"gpt4vDeploymentName": {
"value": "${AZURE_OPENAI_GPT4V_DEPLOYMENT=gpt-4o}"
},
"gpt4vDeploymentVersion":{
"value": "${AZURE_OPENAI_GPT4V_DEPLOYMENT_VERSION=2024-05-13}"
},
"gpt4vDeploymentCapacity":{
"value": "${AZURE_OPENAI_GPT4V_DEPLOYMENT_CAPACITY=10}"
},
"gpt4vDeploymentSkuName":{
"value": "${AZURE_OPENAI_GPT4V_DEPLOYMENT_SKU=GlobalStandard}"
},
"openAiHost": {
"value": "${OPENAI_HOST=azure}"
},
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r app/backend/requirements.txt
azure-mgmt-cognitiveservices
ruff
black
pytest
Expand Down
10 changes: 10 additions & 0 deletions scripts/pre-down.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Get the directory of the current script
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Load environment variables from azd env
$subscriptionId = azd env get-value AZURE_SUBSCRIPTION_ID
$resourceName = azd env get-value AZURE_OPENAI_SERVICE
$resourceGroup = azd env get-value AZURE_OPENAI_RESOURCE_GROUP

# Run the Python script with the retrieved values
python "$scriptDir/pre-down.py" --subscription-id $subscriptionId --resource-name $resourceName --resource-group $resourceGroup
32 changes: 32 additions & 0 deletions scripts/pre-down.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import argparse

from azure.identity import DefaultAzureCredential
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient

# Set up argument parsing
parser = argparse.ArgumentParser(description="Delete an Azure OpenAI deployment.")
parser.add_argument("--resource-name", required=True, help="The name of the Azure OpenAI resource.")
parser.add_argument("--resource-group", required=True, help="The name of the Azure resource group.")
parser.add_argument("--subscription-id", required=True, help="The Azure subscription ID.")

args = parser.parse_args()

# Authenticate using DefaultAzureCredential
credential = DefaultAzureCredential()

# Initialize the Cognitive Services client
client = CognitiveServicesManagementClient(credential, subscription_id=args.subscription_id)

# List all deployments
deployments = client.deployments.list(resource_group_name=args.resource_group, account_name=args.resource_name)

# Delete each deployment and wait for the operation to complete
for deployment in deployments:
deployment_name = deployment.name
if not deployment_name:
continue
poller = client.deployments.begin_delete(
resource_group_name=args.resource_group, account_name=args.resource_name, deployment_name=deployment_name
)
poller.result()
print(f"Deployment {deployment_name} deleted successfully.")
12 changes: 12 additions & 0 deletions scripts/pre-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Get the directory of the current script
script_dir=$(dirname "$0")

# Load environment variables from azd env
subscription_id=$(azd env get-value AZURE_SUBSCRIPTION_ID)
resource_name=$(azd env get-value AZURE_OPENAI_SERVICE)
resource_group=$(azd env get-value AZURE_OPENAI_RESOURCE_GROUP)

# Run the Python script with the retrieved values
python "$script_dir/pre-down.py" --subscription-id $subscription_id --resource-name $resource_name --resource-group $resource_group
Loading