Skip to content

Commit

Permalink
fix: Add vector_fields to Azure OpenAI On Your Data (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecheta authored May 22, 2024
1 parent 44af6fd commit 5483f92
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions code/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def conversation_with_data(conversation: Request, env_helper: EnvHelper):
if env_helper.AZURE_SEARCH_CONTENT_COLUMNS
else []
),
"vector_fields": [
env_helper.AZURE_SEARCH_CONTENT_VECTOR_COLUMNS
],
"title_field": env_helper.AZURE_SEARCH_TITLE_COLUMN or None,
"url_field": env_helper.AZURE_SEARCH_URL_COLUMN or None,
"filepath_field": (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def test_post_makes_correct_call_to_azure_openai(
"index_name": app_config.get("AZURE_SEARCH_INDEX"),
"fields_mapping": {
"content_fields": ["content"],
"vector_fields": [
app_config.get(
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS"
)
],
"title_field": "title",
"url_field": "url",
"filepath_field": "filepath",
Expand Down
5 changes: 5 additions & 0 deletions code/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
AZURE_SEARCH_INDEX = "mock-search-index"
AZURE_SEARCH_SERVICE = "mock-search-service"
AZURE_SEARCH_CONTENT_COLUMNS = "field1|field2"
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS = "vector-column"
AZURE_SEARCH_TITLE_COLUMN = "title"
AZURE_SEARCH_FILENAME_COLUMN = "filename"
AZURE_SEARCH_URL_COLUMN = "url"
Expand Down Expand Up @@ -66,6 +67,9 @@ def env_helper_mock():
env_helper.AZURE_SEARCH_INDEX = AZURE_SEARCH_INDEX
env_helper.AZURE_SEARCH_SERVICE = AZURE_SEARCH_SERVICE
env_helper.AZURE_SEARCH_CONTENT_COLUMNS = AZURE_SEARCH_CONTENT_COLUMNS
env_helper.AZURE_SEARCH_CONTENT_VECTOR_COLUMNS = (
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS
)
env_helper.AZURE_SEARCH_TITLE_COLUMN = AZURE_SEARCH_TITLE_COLUMN
env_helper.AZURE_SEARCH_FILENAME_COLUMN = AZURE_SEARCH_FILENAME_COLUMN
env_helper.AZURE_SEARCH_URL_COLUMN = AZURE_SEARCH_URL_COLUMN
Expand Down Expand Up @@ -547,6 +551,7 @@ def test_conversation_azure_byod_returns_correct_response_when_streaming_with_da
"index_name": AZURE_SEARCH_INDEX,
"fields_mapping": {
"content_fields": ["field1", "field2"],
"vector_fields": [AZURE_SEARCH_CONTENT_VECTOR_COLUMNS],
"title_field": AZURE_SEARCH_TITLE_COLUMN,
"url_field": AZURE_SEARCH_URL_COLUMN,
"filepath_field": AZURE_SEARCH_FILENAME_COLUMN,
Expand Down
8 changes: 8 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ param azureSearchEnableInDomain string = 'false'
@description('Content columns')
param azureSearchContentColumns string = 'content'

@description('Vector columns')
param azureSearchVectorColumns string = 'content_vector'

@description('Filename column')
param azureSearchFilenameColumn string = 'filename'

Expand Down Expand Up @@ -541,6 +544,7 @@ module web './app/web.bicep' = if (hostingModel == 'code') {
AZURE_SEARCH_TOP_K: azureSearchTopK
AZURE_SEARCH_ENABLE_IN_DOMAIN: azureSearchEnableInDomain
AZURE_SEARCH_CONTENT_COLUMNS: azureSearchContentColumns
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS: azureSearchVectorColumns
AZURE_SEARCH_FILENAME_COLUMN: azureSearchFilenameColumn
AZURE_SEARCH_FILTER: azureSearchFilter
AZURE_SEARCH_TITLE_COLUMN: azureSearchTitleColumn
Expand Down Expand Up @@ -613,6 +617,7 @@ module web_docker './app/web.bicep' = if (hostingModel == 'container') {
AZURE_SEARCH_TOP_K: azureSearchTopK
AZURE_SEARCH_ENABLE_IN_DOMAIN: azureSearchEnableInDomain
AZURE_SEARCH_CONTENT_COLUMNS: azureSearchContentColumns
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS: azureSearchVectorColumns
AZURE_SEARCH_FILENAME_COLUMN: azureSearchFilenameColumn
AZURE_SEARCH_FILTER: azureSearchFilter
AZURE_SEARCH_TITLE_COLUMN: azureSearchTitleColumn
Expand Down Expand Up @@ -684,6 +689,7 @@ module adminweb './app/adminweb.bicep' = if (hostingModel == 'code') {
AZURE_SEARCH_TOP_K: azureSearchTopK
AZURE_SEARCH_ENABLE_IN_DOMAIN: azureSearchEnableInDomain
AZURE_SEARCH_CONTENT_COLUMNS: azureSearchContentColumns
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS: azureSearchVectorColumns
AZURE_SEARCH_FILENAME_COLUMN: azureSearchFilenameColumn
AZURE_SEARCH_FILTER: azureSearchFilter
AZURE_SEARCH_TITLE_COLUMN: azureSearchTitleColumn
Expand Down Expand Up @@ -755,6 +761,7 @@ module adminweb_docker './app/adminweb.bicep' = if (hostingModel == 'container')
AZURE_SEARCH_TOP_K: azureSearchTopK
AZURE_SEARCH_ENABLE_IN_DOMAIN: azureSearchEnableInDomain
AZURE_SEARCH_CONTENT_COLUMNS: azureSearchContentColumns
AZURE_SEARCH_CONTENT_VECTOR_COLUMNS: azureSearchVectorColumns
AZURE_SEARCH_FILENAME_COLUMN: azureSearchFilenameColumn
AZURE_SEARCH_FILTER: azureSearchFilter
AZURE_SEARCH_TITLE_COLUMN: azureSearchTitleColumn
Expand Down Expand Up @@ -1065,6 +1072,7 @@ output AZURE_SEARCH_INDEX_IS_PRECHUNKED string = azureSearchIndexIsPrechunked
output AZURE_SEARCH_TOP_K string = azureSearchTopK
output AZURE_SEARCH_ENABLE_IN_DOMAIN string = azureSearchEnableInDomain
output AZURE_SEARCH_CONTENT_COLUMNS string = azureSearchContentColumns
output AZURE_SEARCH_CONTENT_VECTOR_COLUMNS string = azureSearchVectorColumns
output AZURE_SEARCH_FILENAME_COLUMN string = azureSearchFilenameColumn
output AZURE_SEARCH_FILTER string = azureSearchFilter
output AZURE_SEARCH_TITLE_COLUMN string = azureSearchTitleColumn
Expand Down
17 changes: 16 additions & 1 deletion infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.27.1.19265",
"templateHash": "6490847733397864992"
"templateHash": "6027201902589320671"
}
},
"parameters": {
Expand Down Expand Up @@ -141,6 +141,13 @@
"description": "Content columns"
}
},
"azureSearchVectorColumns": {
"type": "string",
"defaultValue": "content_vector",
"metadata": {
"description": "Vector columns"
}
},
"azureSearchFilenameColumn": {
"type": "string",
"defaultValue": "filename",
Expand Down Expand Up @@ -2014,6 +2021,7 @@
"AZURE_SEARCH_TOP_K": "[parameters('azureSearchTopK')]",
"AZURE_SEARCH_ENABLE_IN_DOMAIN": "[parameters('azureSearchEnableInDomain')]",
"AZURE_SEARCH_CONTENT_COLUMNS": "[parameters('azureSearchContentColumns')]",
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS": "[parameters('azureSearchVectorColumns')]",
"AZURE_SEARCH_FILENAME_COLUMN": "[parameters('azureSearchFilenameColumn')]",
"AZURE_SEARCH_FILTER": "[parameters('azureSearchFilter')]",
"AZURE_SEARCH_TITLE_COLUMN": "[parameters('azureSearchTitleColumn')]",
Expand Down Expand Up @@ -2966,6 +2974,7 @@
"AZURE_SEARCH_TOP_K": "[parameters('azureSearchTopK')]",
"AZURE_SEARCH_ENABLE_IN_DOMAIN": "[parameters('azureSearchEnableInDomain')]",
"AZURE_SEARCH_CONTENT_COLUMNS": "[parameters('azureSearchContentColumns')]",
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS": "[parameters('azureSearchVectorColumns')]",
"AZURE_SEARCH_FILENAME_COLUMN": "[parameters('azureSearchFilenameColumn')]",
"AZURE_SEARCH_FILTER": "[parameters('azureSearchFilter')]",
"AZURE_SEARCH_TITLE_COLUMN": "[parameters('azureSearchTitleColumn')]",
Expand Down Expand Up @@ -3917,6 +3926,7 @@
"AZURE_SEARCH_TOP_K": "[parameters('azureSearchTopK')]",
"AZURE_SEARCH_ENABLE_IN_DOMAIN": "[parameters('azureSearchEnableInDomain')]",
"AZURE_SEARCH_CONTENT_COLUMNS": "[parameters('azureSearchContentColumns')]",
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS": "[parameters('azureSearchVectorColumns')]",
"AZURE_SEARCH_FILENAME_COLUMN": "[parameters('azureSearchFilenameColumn')]",
"AZURE_SEARCH_FILTER": "[parameters('azureSearchFilter')]",
"AZURE_SEARCH_TITLE_COLUMN": "[parameters('azureSearchTitleColumn')]",
Expand Down Expand Up @@ -4859,6 +4869,7 @@
"AZURE_SEARCH_TOP_K": "[parameters('azureSearchTopK')]",
"AZURE_SEARCH_ENABLE_IN_DOMAIN": "[parameters('azureSearchEnableInDomain')]",
"AZURE_SEARCH_CONTENT_COLUMNS": "[parameters('azureSearchContentColumns')]",
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS": "[parameters('azureSearchVectorColumns')]",
"AZURE_SEARCH_FILENAME_COLUMN": "[parameters('azureSearchFilenameColumn')]",
"AZURE_SEARCH_FILTER": "[parameters('azureSearchFilter')]",
"AZURE_SEARCH_TITLE_COLUMN": "[parameters('azureSearchTitleColumn')]",
Expand Down Expand Up @@ -11008,6 +11019,10 @@
"type": "string",
"value": "[parameters('azureSearchContentColumns')]"
},
"AZURE_SEARCH_CONTENT_VECTOR_COLUMNS": {
"type": "string",
"value": "[parameters('azureSearchVectorColumns')]"
},
"AZURE_SEARCH_FILENAME_COLUMN": {
"type": "string",
"value": "[parameters('azureSearchFilenameColumn')]"
Expand Down

0 comments on commit 5483f92

Please sign in to comment.