mirror of
https://github.com/Azure-Samples/graphrag-accelerator.git
synced 2025-11-02 03:29:06 +00:00
add aoai to bicep deployment
This commit is contained in:
parent
8d448f86d4
commit
863bff3c3b
96
backend/poetry.lock
generated
96
backend/poetry.lock
generated
@ -1903,44 +1903,48 @@ name = "graphrag"
|
||||
version = "1.0.1"
|
||||
description = "GraphRAG: A graph-based retrieval-augmented generation (RAG) system."
|
||||
optional = false
|
||||
python-versions = "<3.13,>=3.10"
|
||||
files = [
|
||||
{file = "graphrag-1.0.1-py3-none-any.whl", hash = "sha256:821f5c4017f79802ee4e97fa00582b9720ab8146b651523825cb037b978e0fd7"},
|
||||
{file = "graphrag-1.0.1.tar.gz", hash = "sha256:178da70b500fd7a85d422774a14ae45ed315f0bb61bebd28f36bccd56da45fa1"},
|
||||
]
|
||||
python-versions = ">=3.10,<3.13"
|
||||
files = []
|
||||
develop = false
|
||||
|
||||
[package.dependencies]
|
||||
aiofiles = ">=24.1.0,<25.0.0"
|
||||
azure-identity = ">=1.19.0,<2.0.0"
|
||||
azure-search-documents = ">=11.5.2,<12.0.0"
|
||||
azure-storage-blob = ">=12.24.0,<13.0.0"
|
||||
datashaper = ">=0.0.49,<0.0.50"
|
||||
devtools = ">=0.12.2,<0.13.0"
|
||||
environs = ">=11.0.0,<12.0.0"
|
||||
fnllm = ">=0.0.10,<0.0.11"
|
||||
future = ">=1.0.0,<2.0.0"
|
||||
graspologic = ">=3.4.1,<4.0.0"
|
||||
httpx = ">=0.28.1,<0.29.0"
|
||||
json-repair = ">=0.30.3,<0.31.0"
|
||||
lancedb = ">=0.17.0,<0.18.0"
|
||||
matplotlib = ">=3.9.3,<4.0.0"
|
||||
networkx = ">=3.4.2,<4.0.0"
|
||||
aiofiles = "^24.1.0"
|
||||
azure-cosmos = "^4.9.0"
|
||||
azure-identity = "^1.19.0"
|
||||
azure-search-documents = "^11.5.2"
|
||||
azure-storage-blob = "^12.24.0"
|
||||
devtools = "^0.12.2"
|
||||
environs = "^11.0.0"
|
||||
fnllm = "^0.0.10"
|
||||
future = "^1.0.0"
|
||||
graspologic = "^3.4.1"
|
||||
httpx = "^0.28.1"
|
||||
json-repair = "^0.30.3"
|
||||
lancedb = "^0.17.0"
|
||||
matplotlib = "^3.9.3"
|
||||
networkx = "^3.4.2"
|
||||
nltk = "3.9.1"
|
||||
numpy = ">=1.25.2,<2.0.0"
|
||||
openai = ">=1.57.0,<2.0.0"
|
||||
pandas = ">=2.2.3,<3.0.0"
|
||||
pyaml-env = ">=1.2.1,<2.0.0"
|
||||
pyarrow = ">=15.0.0,<16.0.0"
|
||||
pydantic = ">=2.10.3,<3.0.0"
|
||||
python-dotenv = ">=1.0.1,<2.0.0"
|
||||
pyyaml = ">=6.0.2,<7.0.0"
|
||||
rich = ">=13.9.4,<14.0.0"
|
||||
tenacity = ">=9.0.0,<10.0.0"
|
||||
tiktoken = ">=0.8.0,<0.9.0"
|
||||
tqdm = ">=4.67.1,<5.0.0"
|
||||
typer = ">=0.15.1,<0.16.0"
|
||||
typing-extensions = ">=4.12.2,<5.0.0"
|
||||
umap-learn = ">=0.5.6,<0.6.0"
|
||||
numpy = "^1.25.2"
|
||||
openai = "^1.57.0"
|
||||
pandas = "^2.2.3"
|
||||
pyaml-env = "^1.2.1"
|
||||
pyarrow = "^15.0.0"
|
||||
pydantic = "^2.10.3"
|
||||
python-dotenv = "^1.0.1"
|
||||
pyyaml = "^6.0.2"
|
||||
rich = "^13.9.4"
|
||||
tenacity = "^9.0.0"
|
||||
tiktoken = "^0.8.0"
|
||||
tqdm = "^4.67.1"
|
||||
typer = "^0.15.1"
|
||||
typing-extensions = "^4.12.2"
|
||||
umap-learn = "^0.5.6"
|
||||
|
||||
[package.source]
|
||||
type = "git"
|
||||
url = "https://github.com/microsoft/graphrag.git"
|
||||
reference = "main"
|
||||
resolved_reference = "cbb8f8788e060f53a3dbe9580eb620c648b3343d"
|
||||
|
||||
[[package]]
|
||||
name = "graspologic"
|
||||
@ -2980,13 +2984,13 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "marshmallow"
|
||||
version = "3.23.2"
|
||||
version = "3.23.3"
|
||||
description = "A lightweight library for converting complex datatypes to and from native Python datatypes."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "marshmallow-3.23.2-py3-none-any.whl", hash = "sha256:bcaf2d6fd74fb1459f8450e85d994997ad3e70036452cbfa4ab685acb19479b3"},
|
||||
{file = "marshmallow-3.23.2.tar.gz", hash = "sha256:c448ac6455ca4d794773f00bae22c2f351d62d739929f761dce5eacb5c468d7f"},
|
||||
{file = "marshmallow-3.23.3-py3-none-any.whl", hash = "sha256:20c0f8c613f68bcb45b2a0d3282e2f172575560170bf220d67aafb42717910e4"},
|
||||
{file = "marshmallow-3.23.3.tar.gz", hash = "sha256:d586c8685ebdb80bf754e1f96e3f305aaf30951f1fc69175b977453633467e76"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@ -2994,7 +2998,7 @@ packaging = ">=17.0"
|
||||
|
||||
[package.extras]
|
||||
dev = ["marshmallow[tests]", "pre-commit (>=3.5,<5.0)", "tox"]
|
||||
docs = ["alabaster (==1.0.0)", "autodocsumm (==0.2.14)", "sphinx (==8.1.3)", "sphinx-issues (==5.0.0)", "sphinx-version-warning (==1.1.2)"]
|
||||
docs = ["alabaster (==1.0.0)", "autodocsumm (==0.2.14)", "sphinx (==8.1.3)", "sphinx-issues (==5.0.0)"]
|
||||
tests = ["pytest", "simplejson"]
|
||||
|
||||
[[package]]
|
||||
@ -3545,13 +3549,13 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
|
||||
|
||||
[[package]]
|
||||
name = "openai"
|
||||
version = "1.58.1"
|
||||
version = "1.59.3"
|
||||
description = "The official Python library for the openai API"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "openai-1.58.1-py3-none-any.whl", hash = "sha256:e2910b1170a6b7f88ef491ac3a42c387f08bd3db533411f7ee391d166571d63c"},
|
||||
{file = "openai-1.58.1.tar.gz", hash = "sha256:f5a035fd01e141fc743f4b0e02c41ca49be8fab0866d3b67f5f29b4f4d3c0973"},
|
||||
{file = "openai-1.59.3-py3-none-any.whl", hash = "sha256:b041887a0d8f3e70d1fc6ffbb2bf7661c3b9a2f3e806c04bf42f572b9ac7bc37"},
|
||||
{file = "openai-1.59.3.tar.gz", hash = "sha256:7f7fff9d8729968588edf1524e73266e8593bb6cab09298340efb755755bb66f"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@ -5899,13 +5903,13 @@ standard = ["colorama (>=0.4)", "httptools (>=0.6.3)", "python-dotenv (>=0.13)",
|
||||
|
||||
[[package]]
|
||||
name = "virtualenv"
|
||||
version = "20.28.0"
|
||||
version = "20.28.1"
|
||||
description = "Virtual Python Environment builder"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "virtualenv-20.28.0-py3-none-any.whl", hash = "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0"},
|
||||
{file = "virtualenv-20.28.0.tar.gz", hash = "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa"},
|
||||
{file = "virtualenv-20.28.1-py3-none-any.whl", hash = "sha256:412773c85d4dab0409b83ec36f7a6499e72eaf08c80e81e9576bca61831c71cb"},
|
||||
{file = "virtualenv-20.28.1.tar.gz", hash = "sha256:5d34ab240fdb5d21549b76f9e8ff3af28252f5499fb6d6f031adac4e5a8c5329"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@ -6183,4 +6187,4 @@ type = ["pytest-mypy"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "~3.10"
|
||||
content-hash = "bae0ddd74ebd3aa28bc21fb73b05b1f563cfd6aa8b032b82a7a05d4bc40555e2"
|
||||
content-hash = "c573abfd1adb4d94a371b59107776a1bbb1799b732e18147e1ae2ebdee597796"
|
||||
|
||||
@ -54,7 +54,7 @@ fastapi = ">=0.110.0"
|
||||
fastapi-offline = ">=1.7.3"
|
||||
fastparquet = ">=2023.10.1"
|
||||
fsspec = ">=2024.2.0"
|
||||
graphrag = "==1.0.1"
|
||||
graphrag = {git = "https://github.com/microsoft/graphrag.git", branch = "main"}
|
||||
graspologic = ">=3.3.0"
|
||||
httpx = ">=0.25.2"
|
||||
kubernetes = ">=29.0.0"
|
||||
|
||||
80
infra/core/aoai/aoai.bicep
Normal file
80
infra/core/aoai/aoai.bicep
Normal file
@ -0,0 +1,80 @@
|
||||
@description('Name of the Azure OpenAI instance')
|
||||
param openAiName string = 'openai${uniqueString(resourceGroup().id)}'
|
||||
|
||||
@description('Location for the Azure OpenAI instance')
|
||||
param location string = resourceGroup().location
|
||||
|
||||
@description('LLM model deployment name')
|
||||
param llmModelDeploymentName string = 'gpt-4o'
|
||||
|
||||
@description('Embedding model deployment name')
|
||||
param embeddingModelDeploymentName string = 'text-embedding-ada-002'
|
||||
|
||||
@description('TPM quota for GPT-4o deployment')
|
||||
param gpt4oTpm int = 10
|
||||
|
||||
@description('TPM quota for text-embedding-ada-002 deployment')
|
||||
param textEmbeddingAdaTpm int = 10
|
||||
|
||||
@description('Array of objects with fields principalId, roleDefinitionId')
|
||||
param roleAssignments array = []
|
||||
|
||||
|
||||
resource aoai 'Microsoft.CognitiveServices/accounts@2024-10-01' = {
|
||||
name: openAiName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'S0'
|
||||
}
|
||||
kind: 'OpenAI'
|
||||
properties: {
|
||||
publicNetworkAccess: 'Enabled'
|
||||
disableLocalAuth: true
|
||||
}
|
||||
}
|
||||
|
||||
resource gpt4oDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-10-01' = {
|
||||
parent: aoai
|
||||
name: llmModelDeploymentName
|
||||
sku: {
|
||||
name: 'GlobalStandard'
|
||||
capacity: gpt4oTpm
|
||||
}
|
||||
properties: {
|
||||
model: {
|
||||
format: 'OpenAI'
|
||||
name: 'gpt-4o'
|
||||
version: '2024-05-13'
|
||||
}
|
||||
currentCapacity: gpt4oTpm
|
||||
}
|
||||
}
|
||||
|
||||
resource textEmbeddingAdaDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-10-01' = {
|
||||
parent: aoai
|
||||
name: embeddingModelDeploymentName
|
||||
sku: {
|
||||
name: 'Standard'
|
||||
capacity: textEmbeddingAdaTpm
|
||||
}
|
||||
properties: {
|
||||
model: {
|
||||
format: 'OpenAI'
|
||||
name: 'text-embedding-ada-002'
|
||||
version: '2'
|
||||
}
|
||||
currentCapacity: textEmbeddingAdaTpm
|
||||
}
|
||||
}
|
||||
|
||||
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
|
||||
for role in roleAssignments: {
|
||||
name: guid('${role.principalId}-${role.roleDefinitionId}')
|
||||
scope: resourceGroup()
|
||||
properties: role
|
||||
}
|
||||
]
|
||||
|
||||
output openAiEndpoint string = aoai.properties.endpoint
|
||||
output gpt4oDeploymentName string = gpt4oDeployment.name
|
||||
output textEmbeddingAdaDeploymentName string = textEmbeddingAdaDeployment.name
|
||||
@ -344,7 +344,6 @@ deployAzureResources () {
|
||||
AZURE_OUTPUTS=$(jq -r .properties.outputs <<< $AZURE_DEPLOY_RESULTS)
|
||||
exitIfCommandFailed $? "Error parsing outputs from Azure deployment..."
|
||||
exitIfValueEmpty "$AZURE_OUTPUTS" "Error parsing outputs from Azure deployment..."
|
||||
assignAOAIRoleToManagedIdentity
|
||||
}
|
||||
|
||||
validateSKUs() {
|
||||
@ -396,19 +395,6 @@ checkSKUQuotas() {
|
||||
printf "Done.\n"
|
||||
}
|
||||
|
||||
assignAOAIRoleToManagedIdentity() {
|
||||
printf "Assigning 'Cognitive Services OpenAI Contributor' role to managed identity... "
|
||||
local servicePrincipalId=$(jq -r .azure_workload_identity_principal_id.value <<< $AZURE_OUTPUTS)
|
||||
exitIfValueEmpty "$servicePrincipalId" "Unable to parse service principal id from azure outputs, exiting..."
|
||||
local scope=$(az cognitiveservices account list --query "[?contains(properties.endpoint, '$GRAPHRAG_API_BASE')] | [0].id" -o tsv)
|
||||
az role assignment create --only-show-errors \
|
||||
--role "Cognitive Services OpenAI Contributor" \
|
||||
--assignee "$servicePrincipalId" \
|
||||
--scope "$scope" > /dev/null 2>&1
|
||||
exitIfCommandFailed $? "Error assigning role to service principal, exiting..."
|
||||
printf "Done.\n"
|
||||
}
|
||||
|
||||
installGraphRAGHelmChart () {
|
||||
echo "Deploying graphrag helm chart... "
|
||||
local workloadId=$(jq -r .azure_workload_identity_client_id.value <<< $AZURE_OUTPUTS)
|
||||
|
||||
@ -169,6 +169,25 @@ resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
|
||||
}
|
||||
}
|
||||
|
||||
module aoai 'core/aoai/aoai.bicep' = {
|
||||
name: 'aoai-deployment'
|
||||
params: {
|
||||
openAiName: '${abbrs.cognitiveServicesAccounts}${resourceBaseNameFinal}'
|
||||
location: location
|
||||
llmModelDeploymentName: 'gpt-4o-${uniqueString(resourceBaseNameFinal)}'
|
||||
gpt4oTpm: 10
|
||||
embeddingModelDeploymentName: 'text-embedding-ada-002-${uniqueString(resourceBaseNameFinal)}'
|
||||
textEmbeddingAdaTpm: 10
|
||||
roleAssignments: [
|
||||
{
|
||||
principalId: workloadIdentity.outputs.principalId
|
||||
roleDefinitionId: roles.cognitiveServicesOpenaiContributor
|
||||
principalType: 'ServicePrincipal'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module acr 'core/acr/acr.bicep' = {
|
||||
name: 'acr-deployment'
|
||||
params: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user