Registry /
azure / azure-ai-language-questionanswering
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
QuestionAnsweringClient
✓ from azure.ai.language.questionanswering import QuestionAnsweringClient
✗ from azure.ai.language.questionanswering.models import QuestionAnsweringClient
Client class is in the top-level module, not models
AnswersFromTextOptions
✓ from azure.ai.language.questionanswering.models import AnswersFromTextOptions
✗ from azure.ai.language.questionanswering import AnswersFromTextOptions
Model classes are under .models
AnswersOptions
✓ from azure.ai.language.questionanswering.models import AnswersOptions
Authenticate using endpoint and key, then query a knowledge base.
import os
from azure.ai.language.questionanswering import QuestionAnsweringClient
from azure.core.credentials import AzureKeyCredential
endpoint = os.environ.get('AZURE_QA_ENDPOINT', '')
credential = AzureKeyCredential(os.environ.get('AZURE_QA_KEY', ''))
client = QuestionAnsweringClient(endpoint, credential)
response = client.get_answers(
question="What is a good pet?",
project_name="SampleProject",
deployment_name="production"
)
if response.answers:
print(response.answers[0].answer)
Errors
Common errors & fixes
AttributeError: 'QuestionAnsweringClient' object has no attribute 'get_answers'
Using an older version of the library (<1.0.0) where method was `query_knowledgebase`
fixUpgrade to version 1.1.0 and use `get_answers` method.
azure.core.exceptions.ResourceNotFoundError: (NotFound) The specified project does not exist.
`project_name` or `deployment_name` missing or incorrect
fixEnsure both parameters are provided and match exactly the names in Azure AI Language resource.
TypeError: get_answers() got an unexpected keyword argument 'top'
Using `top` parameter which was renamed to `top_answers` in version 1.1.0
fixReplace `top` with `top_answers` in the call.
Upgrade
Version history
1.1.0latest on PyPI · released Oct 13, 2022
Audit
Dependencies
azure-corerequiredHTTP pipeline and authentication
azure-identityoptionalDefaultAzureCredential for auth