Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/broken-links-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: lycheeverse/lychee-action@v2.7.0
with:
args: >
--verbose --exclude-mail --no-progress --exclude ^https?://
--verbose --no-progress --exclude ^https?://
${{ steps.changed-markdown-files.outputs.all_changed_files }}
failIfEmpty: false
env:
Expand All @@ -48,7 +48,7 @@ jobs:
uses: lycheeverse/lychee-action@v2.7.0
with:
args: >
--verbose --exclude-mail --no-progress --exclude ^https?://
--verbose --no-progress --exclude ^https?://
'**/*.md'
failIfEmpty: false
env:
Expand Down
4 changes: 2 additions & 2 deletions code/backend/batch/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
"version": "[4.*, 5.0.0)"
}
}
}
14 changes: 13 additions & 1 deletion code/backend/batch/utilities/helpers/llm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,37 @@ def get_streaming_llm(self):
)

def get_embedding_model(self):
dimensions = (
int(self.env_helper.AZURE_SEARCH_DIMENSIONS)
if self.env_helper.AZURE_SEARCH_DIMENSIONS
else None
)
if self.auth_type_keys:
return AzureOpenAIEmbeddings(
azure_endpoint=self.env_helper.AZURE_OPENAI_ENDPOINT,
api_key=self.env_helper.OPENAI_API_KEY,
azure_deployment=self.embedding_model,
dimensions=dimensions,
chunk_size=1,
)
else:
return AzureOpenAIEmbeddings(
azure_endpoint=self.env_helper.AZURE_OPENAI_ENDPOINT,
azure_deployment=self.embedding_model,
dimensions=dimensions,
chunk_size=1,
azure_ad_token_provider=self.token_provider,
)

def generate_embeddings(self, input: Union[str, list[int]]) -> List[float]:
dimensions = (
int(self.env_helper.AZURE_SEARCH_DIMENSIONS)
if self.env_helper.AZURE_SEARCH_DIMENSIONS
else None
)
return (
self.openai_client.embeddings.create(
input=[input], model=self.embedding_model
input=[input], model=self.embedding_model, dimensions=dimensions
)
.data[0]
.embedding
Expand Down
2 changes: 1 addition & 1 deletion code/tests/functional/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AppConfig:
"AZURE_SEARCH_CONVERSATIONS_LOG_INDEX": "some-log-index",
"AZURE_SEARCH_CONTENT_COLUMN": "content",
"AZURE_SEARCH_CONTENT_VECTOR_COLUMN": "some-search-content-vector-columns",
"AZURE_SEARCH_DIMENSIONS": "some-search-dimensions",
"AZURE_SEARCH_DIMENSIONS": "1536",
"AZURE_SEARCH_ENABLE_IN_DOMAIN": "True",
"AZURE_SEARCH_FIELDS_ID": "some-search-fields-id",
"AZURE_SEARCH_FIELDS_METADATA": "some-search-fields-metadata",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_get_vector_dimensions(
json={
"input": [[1199]],
"model": "text-embedding-ada-002",
"dimensions": 1536,
"encoding_format": "base64",
},
headers={
Expand Down Expand Up @@ -164,6 +165,7 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_embed_question_to_sear
"model": app_config.get_from_json(
"AZURE_OPENAI_EMBEDDING_MODEL_INFO", "model"
),
"dimensions": 1536,
"encoding_format": "base64",
},
headers={
Expand Down Expand Up @@ -197,6 +199,7 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_embed_question_to_stor
[3923, 374, 279, 7438, 315, 2324, 30]
], # Embedding of "What is the meaning of life?"
"model": "text-embedding-ada-002", # this is hard coded in the langchain code base
"dimensions": 1536,
"encoding_format": "base64",
},
headers={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_post_makes_correct_call_to_openai_embeddings(
[3923, 374, 279, 7438, 315, 2324, 30]
], # Embedding of "What is the meaning of life?"
"model": "text-embedding-ada-002",
"dimensions": 1536,
"encoding_format": "base64",
},
headers={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def test_embeddings_generated_for_caption(
"model": app_config.get_from_json(
"AZURE_OPENAI_EMBEDDING_MODEL_INFO", "model"
),
"dimensions": 1536,
"encoding_format": "base64",
},
headers={
Expand Down
6 changes: 5 additions & 1 deletion code/tests/utilities/helpers/test_llm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
PROMPT_FLOW_DEPLOYMENT_NAME = "mock-deployment-name"


AZURE_SEARCH_DIMENSIONS = "1536"


@pytest.fixture(autouse=True)
def env_helper_mock():
with patch("backend.batch.utilities.helpers.llm_helper.EnvHelper") as mock:
Expand All @@ -36,6 +39,7 @@ def env_helper_mock():
env_helper.AZURE_ML_WORKSPACE_NAME = AZURE_ML_WORKSPACE_NAME
env_helper.PROMPT_FLOW_ENDPOINT_NAME = PROMPT_FLOW_ENDPOINT_NAME
env_helper.PROMPT_FLOW_DEPLOYMENT_NAME = PROMPT_FLOW_DEPLOYMENT_NAME
env_helper.AZURE_SEARCH_DIMENSIONS = AZURE_SEARCH_DIMENSIONS

yield env_helper

Expand Down Expand Up @@ -113,7 +117,7 @@ def test_generate_embeddings_embeds_input(azure_openai_mock):

# then
azure_openai_mock.return_value.embeddings.create.assert_called_once_with(
input=["some input"], model=AZURE_OPENAI_EMBEDDING_MODEL
input=["some input"], model=AZURE_OPENAI_EMBEDDING_MODEL, dimensions=int(AZURE_SEARCH_DIMENSIONS)
)


Expand Down
2 changes: 2 additions & 0 deletions docs/customizing_azd_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ By default this template will use the environment name as the prefix to prevent
| `AZURE_OPENAI_EMBEDDING_MODEL_NAME` | string | `text-embedding-ada-002` | Actual embedding model name |
| `AZURE_OPENAI_EMBEDDING_MODEL_VERSION` | string | `2` | Embedding model version |
| `AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY` | integer | `100` | Embedding model capacity (TPM in thousands) |
| `AZURE_SEARCH_DIMENSIONS` | integer | `1536` | Azure Search vector dimensions(Update dimensions for CosmosDB) |
| `USE_ADVANCED_IMAGE_PROCESSING` | boolean | `false` | Enable vision LLM and Computer Vision for images (must be false for PostgreSQL) |
| `ADVANCED_IMAGE_PROCESSING_MAX_IMAGES` | integer | `1` | Maximum images per vision model request |
| `AZURE_OPENAI_VISION_MODEL` | string | `gpt-4.1` | Vision model deployment name |
Expand Down Expand Up @@ -90,5 +91,6 @@ azd env set AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY 150
- `AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION=false`
- `USE_ADVANCED_IMAGE_PROCESSING=false`
- `ORCHESTRATION_STRATEGY=semantic_kernel` (recommended)
- `AZURE_SEARCH_DIMENSIONS=1536` (recommended)

2. **Region Compatibility**: Not all services are available in all regions. Verify service availability in your chosen region before deployment.
20 changes: 7 additions & 13 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,6 @@ param useAdvancedImageProcessing bool = false
@description('Optional. The maximum number of images to pass to the vision model in a single request.')
param advancedImageProcessingMaxImages int = 1

@description('Optional. Azure OpenAI Vision Model Deployment Name.')
param azureOpenAIVisionModel string = 'gpt-4.1'

@description('Optional. Azure OpenAI Vision Model Name.')
param azureOpenAIVisionModelName string = 'gpt-4.1'

@description('Optional. Azure OpenAI Vision Model Version.')
param azureOpenAIVisionModelVersion string = '2025-04-14'

@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.')
param azureOpenAIVisionModelCapacity int = 10

@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.')
@allowed([
'openai_function'
Expand Down Expand Up @@ -210,6 +198,9 @@ param azureOpenAIEmbeddingModelVersion string = '2'
@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 .')
param azureOpenAIEmbeddingModelCapacity int = 100

@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/search/cognitive-search-skill-azure-openai-embedding#supported-dimensions-by-modelname.(Only for databaseType=CosmosDB)')
param azureSearchDimensions string = '1536'

@description('Optional. Name of Computer Vision Resource (if useAdvancedImageProcessing=true).')
var computerVisionName string = 'cv-${solutionSuffix}'

Expand Down Expand Up @@ -858,7 +849,7 @@ module pgSqlDelayScript 'br/public:avm/res/resources/deployment-script:0.5.1' =
tags: tags
kind: 'AzurePowerShell'
enableTelemetry: enableTelemetry
scriptContent: 'start-sleep -Seconds 300'
scriptContent: 'start-sleep -Seconds 600'
azPowerShellVersion: '11.0'
timeout: 'PT15M'
cleanupPreference: 'Always'
Expand Down Expand Up @@ -1285,6 +1276,7 @@ module web 'modules/app/web.bicep' = {
MANAGED_IDENTITY_RESOURCE_ID: managedIdentityModule.outputs.resourceId
AZURE_CLIENT_ID: managedIdentityModule.outputs.clientId // Required so LangChain AzureSearch vector store authenticates with this user-assigned managed identity
APP_ENV: appEnvironment
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
},
databaseType == 'CosmosDB'
? {
Expand Down Expand Up @@ -1383,6 +1375,7 @@ module adminweb 'modules/app/adminweb.bicep' = {
MANAGED_IDENTITY_CLIENT_ID: managedIdentityModule.outputs.clientId
MANAGED_IDENTITY_RESOURCE_ID: managedIdentityModule.outputs.resourceId
APP_ENV: appEnvironment
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
},
databaseType == 'CosmosDB'
? {
Expand Down Expand Up @@ -1482,6 +1475,7 @@ module function 'modules/app/function.bicep' = {
AZURE_CLIENT_ID: managedIdentityModule.outputs.clientId // Required so LangChain AzureSearch vector store authenticates with this user-assigned managed identity
APP_ENV: appEnvironment
BACKEND_URL: backendUrl
AZURE_SEARCH_DIMENSIONS: azureSearchDimensions
},
databaseType == 'CosmosDB'
? {
Expand Down
Loading