Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/cognitivelanguage/azure-ai-language-questionanswering-authoring",
"Tag": "python/cognitivelanguage/azure-ai-language-questionanswering-authoring_401205f3a4"
"Tag": "python/cognitivelanguage/azure-ai-language-questionanswering-authoring_ab8ff6ade9"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def test_add_source(self, recorded_test, qna_authoring_creds): # type: ignore[n
)
project_name = "IsaacNewton"
AuthoringTestHelper.create_test_project(client, project_name=project_name)
source_display_name = "MicrosoftFAQ"
source_display_name = "SurfaceBookUserGuide"
update_source_ops = [
_models.UpdateSourceRecord(
{
"op": "add",
"value": {
"displayName": source_display_name,
"source": "https://www.microsoft.com/en-in/software-download/faq",
"sourceUri": "https://www.microsoft.com/en-in/software-download/faq",
"source": "https://download.microsoft.com/download/7/B/1/7B10C82E-F520-4080-8516-5CF0D803EEE0/surface-book-user-guide-EN.pdf",
"sourceUri": "https://download.microsoft.com/download/7/B/1/7B10C82E-F520-4080-8516-5CF0D803EEE0/surface-book-user-guide-EN.pdf",
"sourceKind": "url",
"contentStructureKind": "unstructured",
"refresh": False,
Expand Down Expand Up @@ -92,3 +92,40 @@ def test_add_synonym(self, recorded_test, qna_authoring_creds): # type: ignore[
("qnamaker" in s.get("alterations", []) and "qna maker" in s.get("alterations", []))
for s in client.list_synonyms(project_name=project_name)
)

def test_add_qna_with_explicitlytaggedheading(self, recorded_test, qna_authoring_creds): # type: ignore[name-defined] # pylint: disable=unused-argument
client = QuestionAnsweringAuthoringClient(
qna_authoring_creds["endpoint"], AzureKeyCredential(qna_authoring_creds["key"])
)
project_name = "IsaacNewton"
AuthoringTestHelper.create_test_project(client, project_name=project_name)
update_qna_ops = [
_models.UpdateQnaRecord(
{
"op": "add",
"value": {
"id": 0,
"answer": "Check the battery level in Settings.",
"questions": ["How do I check the battery level?"],
"metadata": {"explicitlytaggedheading": "check the battery level"},
},
}
)
]
poller = client.begin_update_qnas( # pylint: disable=no-value-for-parameter
project_name=project_name,
qnas=cast(list[_models.UpdateQnaRecord], update_qna_ops),
content_type="application/json",
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type] # pylint: disable=using-constant-test
)
poller.result()
deploy_poller = client.begin_deploy_project(
project_name=project_name,
deployment_name="production",
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type] # pylint: disable=using-constant-test
)
deploy_poller.result()
assert any(
(q.get("metadata") or {}).get("explicitlytaggedheading") == "check the battery level"
for q in client.list_qnas(project_name=project_name)
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ async def test_add_source(self, recorded_test, qna_authoring_creds): # type: ig
await AuthoringAsyncTestHelper.create_test_project(
client, project_name=project_name, polling_interval=0 if self.is_playback else None # pylint: disable=using-constant-test
)
source_display_name = "SurfaceBookUserGuide"
update_source_ops = [
_models.UpdateSourceRecord(
{
"op": "add",
"value": {
"displayName": "MicrosoftFAQ",
"source": "https://www.microsoft.com/en-in/software-download/faq",
"sourceUri": "https://www.microsoft.com/en-in/software-download/faq",
"displayName": source_display_name,
"source": "https://download.microsoft.com/download/7/B/1/7B10C82E-F520-4080-8516-5CF0D803EEE0/surface-book-user-guide-EN.pdf",
"sourceUri": "https://download.microsoft.com/download/7/B/1/7B10C82E-F520-4080-8516-5CF0D803EEE0/surface-book-user-guide-EN.pdf",
"sourceKind": "url",
"contentStructureKind": "unstructured",
"refresh": False,
Expand All @@ -44,7 +45,7 @@ async def test_add_source(self, recorded_test, qna_authoring_creds): # type: ig
await poller.result()
found = False
async for s in client.list_sources(project_name=project_name):
if s.get("displayName") == "MicrosoftFAQ":
if s.get("displayName") == source_display_name:
found = True
assert found

Expand Down Expand Up @@ -110,3 +111,45 @@ async def test_add_synonym(self, recorded_test, qna_authoring_creds): # type: i
if "qnamaker" in s.get("alterations", []) and "qna maker" in s.get("alterations", []):
found = True
assert found

@pytest.mark.asyncio
async def test_add_qna_with_explicitlytaggedheading(self, recorded_test, qna_authoring_creds): # type: ignore[name-defined] # pylint: disable=unused-argument
client = QuestionAnsweringAuthoringClient(
qna_authoring_creds["endpoint"], AzureKeyCredential(qna_authoring_creds["key"])
)
project_name = "IsaacNewton"
async with client:
await AuthoringAsyncTestHelper.create_test_project(
client, project_name=project_name, polling_interval=0 if self.is_playback else None # pylint: disable=using-constant-test
)
update_qna_ops = [
_models.UpdateQnaRecord(
{
"op": "add",
"value": {
"id": 0,
"answer": "Check the battery level in Settings.",
"questions": ["How do I check the battery level?"],
"metadata": {"explicitlytaggedheading": "check the battery level"},
},
}
)
]
poller = await client.begin_update_qnas( # pylint: disable=no-value-for-parameter
project_name=project_name,
qnas=cast(list[_models.UpdateQnaRecord], update_qna_ops),
content_type="application/json",
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type] # pylint: disable=using-constant-test
)
await poller.result()
deploy_poller = await client.begin_deploy_project(
project_name=project_name,
deployment_name="production",
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type] # pylint: disable=using-constant-test
)
await deploy_poller.result()
found = False
async for qna in client.list_qnas(project_name=project_name):
if (qna.get("metadata") or {}).get("explicitlytaggedheading") == "check the battery level":
found = True
assert found
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/cognitivelanguage/azure-ai-language-questionanswering",
"Tag": "python/cognitivelanguage/azure-ai-language-questionanswering_4cf6afbd99"
"Tag": "python/cognitivelanguage/azure-ai-language-questionanswering_ce9b04d392"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_query_knowledgebase_with_answerspan(self, recorded_test, qna_creds): #
assert answer.short_answer.confidence is not None

def test_query_knowledgebase_filter(self, recorded_test, qna_creds): # pylint: disable=unused-argument
deployment_name = "production"
filters = QueryFilters(
metadata_filter=MetadataFilter(
metadata=[
Expand All @@ -71,9 +72,17 @@ def test_query_knowledgebase_filter(self, recorded_test, qna_creds): # pylint: d
response = client.get_answers(
query_params,
project_name=qna_creds["qna_project"],
deployment_name="test",
deployment_name=deployment_name,
)
assert response.answers
assert any(
(a.metadata or {}).get("explicitlytaggedheading") == "check the battery level"
for a in response.answers
)
assert any(
(a.metadata or {}).get("explicitlytaggedheading") == "make your battery last"
for a in response.answers
)

def test_query_knowledgebase_only_id(self, recorded_test, qna_creds): # pylint: disable=unused-argument
client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async def test_query_knowledgebase_with_short_answer(self, recorded_test, qna_cr

@pytest.mark.asyncio
async def test_query_knowledgebase_filter(self, recorded_test, qna_creds): # pylint: disable=unused-argument
deployment_name = "production"
filters = QueryFilters(
metadata_filter=MetadataFilter(
metadata=[
Expand All @@ -76,23 +77,9 @@ async def test_query_knowledgebase_filter(self, recorded_test, qna_creds): # pyl
response = await client.get_answers(
params,
project_name=qna_creds["qna_project"],
deployment_name="production",
deployment_name=deployment_name,
)
assert response.answers
assert any( # pylint: disable=use-a-generator
[
a
for a in response.answers
if (a.metadata or {}).get("explicitlytaggedheading") == "check the battery level"
]
)
assert any( # pylint: disable=use-a-generator
[
a
for a in response.answers
if (a.metadata or {}).get("explicitlytaggedheading") == "make your battery last"
]
)

@pytest.mark.asyncio
async def test_query_knowledgebase_overload_errors(self): # negative parameter validation
Expand Down
Loading