Skip to content

Commit edc33cf

Browse files
fixed emmbedding issue for 3-large
1 parent 2394bc7 commit edc33cf

7 files changed

Lines changed: 191 additions & 200 deletions

File tree

code/backend/batch/host.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
},
1111
"extensionBundle": {
1212
"id": "Microsoft.Azure.Functions.ExtensionBundle",
13-
"version": "[3.*, 4.0.0)"
13+
"version": "[4.*, 5.0.0)"
1414
}
15-
}
15+
}

code/backend/batch/utilities/helpers/llm_helper.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,37 @@ def get_streaming_llm(self):
9191
)
9292

9393
def get_embedding_model(self):
94+
dimensions = (
95+
int(self.env_helper.AZURE_SEARCH_DIMENSIONS)
96+
if self.env_helper.AZURE_SEARCH_DIMENSIONS
97+
else None
98+
)
9499
if self.auth_type_keys:
95100
return AzureOpenAIEmbeddings(
96101
azure_endpoint=self.env_helper.AZURE_OPENAI_ENDPOINT,
97102
api_key=self.env_helper.OPENAI_API_KEY,
98103
azure_deployment=self.embedding_model,
104+
dimensions=dimensions,
99105
chunk_size=1,
100106
)
101107
else:
102108
return AzureOpenAIEmbeddings(
103109
azure_endpoint=self.env_helper.AZURE_OPENAI_ENDPOINT,
104110
azure_deployment=self.embedding_model,
111+
dimensions=dimensions,
105112
chunk_size=1,
106113
azure_ad_token_provider=self.token_provider,
107114
)
108115

109116
def generate_embeddings(self, input: Union[str, list[int]]) -> List[float]:
117+
dimensions = (
118+
int(self.env_helper.AZURE_SEARCH_DIMENSIONS)
119+
if self.env_helper.AZURE_SEARCH_DIMENSIONS
120+
else None
121+
)
110122
return (
111123
self.openai_client.embeddings.create(
112-
input=[input], model=self.embedding_model
124+
input=[input], model=self.embedding_model, dimensions=dimensions
113125
)
114126
.data[0]
115127
.embedding

infra/main.bicep

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,6 @@ param useAdvancedImageProcessing bool = false
150150
@description('Optional. The maximum number of images to pass to the vision model in a single request.')
151151
param advancedImageProcessingMaxImages int = 1
152152

153-
@description('Optional. Azure OpenAI Vision Model Deployment Name.')
154-
param azureOpenAIVisionModel string = 'gpt-4.1'
155-
156-
@description('Optional. Azure OpenAI Vision Model Name.')
157-
param azureOpenAIVisionModelName string = 'gpt-4.1'
158-
159-
@description('Optional. Azure OpenAI Vision Model Version.')
160-
param azureOpenAIVisionModelVersion string = '2025-04-14'
161-
162-
@description('Optional. Azure OpenAI Vision Model Capacity - See here for more info https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/quota.')
163-
param azureOpenAIVisionModelCapacity int = 10
164-
165153
@description('Optional. Orchestration strategy: openai_function or semantic_kernel or langchain str. If you use a old version of turbo (0301), please select langchain. If the database type is PostgreSQL, set this to sementic_kernel.')
166154
@allowed([
167155
'openai_function'
@@ -210,6 +198,9 @@ param azureOpenAIEmbeddingModelVersion string = '2'
210198
@description('Optional. Azure OpenAI Embedding Model Capacity - See here for more info https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/quota .')
211199
param azureOpenAIEmbeddingModelCapacity int = 100
212200

201+
@description('Optional. Azure Search vector field dimensions. Must match the embedding model dimensions. 1536 for text-embedding-ada-002, 3072 for text-embedding-3-large. See https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#embeddings-models.')
202+
param azureSearchDimensions string = '1536'
203+
213204
@description('Optional. Name of Computer Vision Resource (if useAdvancedImageProcessing=true).')
214205
var computerVisionName string = 'cv-${solutionSuffix}'
215206

@@ -858,7 +849,7 @@ module pgSqlDelayScript 'br/public:avm/res/resources/deployment-script:0.5.1' =
858849
tags: tags
859850
kind: 'AzurePowerShell'
860851
enableTelemetry: enableTelemetry
861-
scriptContent: 'start-sleep -Seconds 300'
852+
scriptContent: 'start-sleep -Seconds 600'
862853
azPowerShellVersion: '11.0'
863854
timeout: 'PT15M'
864855
cleanupPreference: 'Always'
@@ -1285,6 +1276,7 @@ module web 'modules/app/web.bicep' = {
12851276
MANAGED_IDENTITY_RESOURCE_ID: managedIdentityModule.outputs.resourceId
12861277
AZURE_CLIENT_ID: managedIdentityModule.outputs.clientId // Required so LangChain AzureSearch vector store authenticates with this user-assigned managed identity
12871278
APP_ENV: appEnvironment
1279+
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
12881280
},
12891281
databaseType == 'CosmosDB'
12901282
? {
@@ -1383,6 +1375,7 @@ module adminweb 'modules/app/adminweb.bicep' = {
13831375
MANAGED_IDENTITY_CLIENT_ID: managedIdentityModule.outputs.clientId
13841376
MANAGED_IDENTITY_RESOURCE_ID: managedIdentityModule.outputs.resourceId
13851377
APP_ENV: appEnvironment
1378+
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
13861379
},
13871380
databaseType == 'CosmosDB'
13881381
? {
@@ -1482,6 +1475,7 @@ module function 'modules/app/function.bicep' = {
14821475
AZURE_CLIENT_ID: managedIdentityModule.outputs.clientId // Required so LangChain AzureSearch vector store authenticates with this user-assigned managed identity
14831476
APP_ENV: appEnvironment
14841477
BACKEND_URL: backendUrl
1478+
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
14851479
},
14861480
databaseType == 'CosmosDB'
14871481
? {

0 commit comments

Comments
 (0)