Skip to content

Commit 0922c27

Browse files
authored
Add new strictness setting for search (microsoft#270)
Co-authored-by: Sarah Widder <[email protected]>
1 parent bb16ff2 commit 0922c27

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ AZURE_SEARCH_URL_COLUMN=
1313
AZURE_SEARCH_VECTOR_COLUMNS=
1414
AZURE_SEARCH_QUERY_TYPE=simple
1515
AZURE_SEARCH_PERMITTED_GROUPS_COLUMN=
16+
AZURE_SEARCH_STRICTNESS=3
1617
AZURE_OPENAI_RESOURCE=
1718
AZURE_OPENAI_MODEL=
1819
AZURE_OPENAI_KEY=

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Please see the [section below](#add-an-identity-provider) for important informat
6464
- `AZURE_SEARCH_VECTOR_COLUMNS`
6565
- `AZURE_SEARCH_QUERY_TYPE`
6666
- `AZURE_SEARCH_PERMITTED_GROUPS_COLUMN`
67+
- `AZURE_SEARCH_STRICTNESS`
6768
- `AZURE_OPENAI_EMBEDDING_ENDPOINT`
6869
- `AZURE_OPENAI_EMBEDDING_KEY`
6970

@@ -142,6 +143,7 @@ Note: settings starting with `AZURE_SEARCH` are only needed when using Azure Ope
142143
|AZURE_SEARCH_URL_COLUMN||Field from your Azure Cognitive Search index that contains a URL for the document, e.g. an Azure Blob Storage URI. This value is not currently used.|
143144
|AZURE_SEARCH_VECTOR_COLUMNS||List of fields in your Azure Cognitive Search index that contain vector embeddings of your documents to use when formulating a bot response. Represent these as a string joined with "|", e.g. `"product_description|product_manual"`|
144145
|AZURE_SEARCH_PERMITTED_GROUPS_COLUMN||Field from your Azure Cognitive Search index that contains AAD group IDs that determine document-level access control.|
146+
|AZURE_SEARCH_STRICTNESS|3|Integer from 1 to 5 specifying the strictness for the model limiting responses to your data.|
145147
|AZURE_OPENAI_RESOURCE||the name of your Azure OpenAI resource|
146148
|AZURE_OPENAI_MODEL||The name of your model deployment|
147149
|AZURE_OPENAI_ENDPOINT||The endpoint of your Azure OpenAI resource.|

app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def assets(path):
4343
AZURE_SEARCH_VECTOR_COLUMNS = os.environ.get("AZURE_SEARCH_VECTOR_COLUMNS")
4444
AZURE_SEARCH_QUERY_TYPE = os.environ.get("AZURE_SEARCH_QUERY_TYPE")
4545
AZURE_SEARCH_PERMITTED_GROUPS_COLUMN = os.environ.get("AZURE_SEARCH_PERMITTED_GROUPS_COLUMN")
46+
AZURE_SEARCH_STRICTNESS = os.environ.get("AZURE_SEARCH_STRICTNESS", 3)
4647

4748
# AOAI Integration Settings
4849
AZURE_OPENAI_RESOURCE = os.environ.get("AZURE_OPENAI_RESOURCE")
@@ -187,7 +188,8 @@ def prepare_body_headers_with_data(request):
187188
"roleInformation": AZURE_OPENAI_SYSTEM_MESSAGE,
188189
"embeddingEndpoint": AZURE_OPENAI_EMBEDDING_ENDPOINT,
189190
"embeddingKey": AZURE_OPENAI_EMBEDDING_KEY,
190-
"filter": filter
191+
"filter": filter,
192+
"strictness": int(AZURE_SEARCH_STRICTNESS)
191193
}
192194
}
193195
]

infrastructure/deployment.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@
230230
"description": "Azure Search Permitted Groups Field"
231231
}
232232
},
233+
"AzureSearchStrictness": {
234+
"type": "int",
235+
"defaultValue": 3,
236+
"allowedValues": [
237+
1,
238+
2,
239+
3,
240+
4,
241+
5
242+
],
243+
"metadata": {
244+
"description": "Azure Search Strictness"
245+
}
246+
},
233247
"AzureOpenAIEmbeddingEndpoint": {
234248
"type": "string",
235249
"defaultValue": "",
@@ -398,6 +412,10 @@
398412
"name": "AZURE_SEARCH_PERMITTED_GROUPS_COLUMN",
399413
"value": "[parameters('AzureSearchPermittedGroupsField')]"
400414
},
415+
{
416+
"name": "AZURE_SEARCH_STRICTNESS",
417+
"value": "[parameters('AzureSearchStrictness')]"
418+
},
401419
{
402420
"name": "AZURE_OPENAI_EMBEDDING_ENDPOINT",
403421
"value": "[parameters('AzureOpenAIEmbeddingEndpoint')]"

0 commit comments

Comments
 (0)