Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ed0994b
generated code
Qi-2077 Sep 24, 2025
c42a2a8
feat(authoring): initialize standalone azure-ai-language-questionansw…
Qi-2077 Sep 24, 2025
eafd591
update setup file
Qi-2077 Sep 24, 2025
e360f73
update import path in test files
Qi-2077 Sep 24, 2025
d02b409
update tests, samples, readme
Qi-2077 Sep 25, 2025
fcb634e
migrating test recordings out of the azure-sdk-for-python repository
Qi-2077 Sep 25, 2025
e4c2f0f
update cspell
Qi-2077 Sep 26, 2025
862631d
fix host mismatch
Qi-2077 Sep 26, 2025
3949428
Merge branch 'qiyin/sdk-cqa-python-beta' of https://github.com/Azure/…
Qi-2077 Sep 26, 2025
f482e37
update readme and remove generated code
Qi-2077 Sep 28, 2025
2661b06
update sample readme
Qi-2077 Sep 28, 2025
34b9cab
1. QuestionAnsweringProjectMetadate -> QuestionAnsweringProject
Qi-2077 Oct 13, 2025
ba9bdf6
rename begin_import_method in samples
Qi-2077 Oct 13, 2025
4d7592f
update
Qi-2077 Oct 13, 2025
afb0270
fix comments, get-> list, add overload
Qi-2077 Oct 27, 2025
27f46d1
apiview changes
Amichelangelo Oct 28, 2025
89f1e33
fix circle import issue
Amichelangelo Oct 28, 2025
b151b76
fix broken link
Qi-2077 Oct 29, 2025
b0e9a49
add type ignore
Amichelangelo Oct 29, 2025
2b4f1fc
analyze iuuse
Qi-2077 Oct 29, 2025
f691eec
update get_[operation]_status to private
Qi-2077 Nov 3, 2025
bf0e0ea
update
Qi-2077 Nov 3, 2025
1e80bff
update
Qi-2077 Nov 4, 2025
d262c9c
update assest
Qi-2077 Nov 7, 2025
6f496f6
update the dependencies
Qi-2077 Nov 13, 2025
29bd056
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
Qi-2077 Nov 13, 2025
3f36d8a
fix cspell
Qi-2077 Nov 13, 2025
40bcfe4
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
Qi-2077 Nov 13, 2025
edec273
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
Qi-2077 Nov 13, 2025
19097b4
add azure-ai-language-questionanswering to shared_requirements.txt
Qi-2077 Nov 13, 2025
1d832b8
move down the pylint tag
Qi-2077 Nov 13, 2025
122ede7
move down the pylint tag
Qi-2077 Nov 13, 2025
0cf9df5
Merge branch 'main' into qiyin/sdk-cqa-python-beta
sarkar-rajarshi Nov 14, 2025
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
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"sdk/ai/azure-ai-voicelive/samples/**"
],
"words": [
"qnas",
"msedge",
"spinup",
"cibuildwheel",
Expand Down Expand Up @@ -530,7 +531,7 @@
"logprobs",
"pyaudio",
"PyAudio",
"libasound",
"libasound",
"ingraph"
],
"overrides": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Release History

## 1.0.0b1

### Features Added
- Initial preview release of `azure-ai-language-questionanswering-authoring` separated from the combined `azure-ai-language-questionanswering` package.
- Supports project listing, creation, update, deletion, import/export, deployments, synonym/source/QnA management operations aligned with the TypeSpec service definition (includes preview API version 2025-05-15-preview where applicable).

### Other Changes
- Generated from TypeSpec definitions in `specification\cognitiveservices\data-plane\LanguageQuestionAnsweringAuthoring`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include *.md
include LICENSE
include azure/ai/language/questionanswering/authoring/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
include azure/ai/language/__init__.py
include azure/ai/language/questionanswering/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Azure AI Language Question Answering Authoring client library for Python

The `azure-ai-language-questionanswering-authoring` package provides **authoring / management capabilities** for Azure AI Language Question Answering: create and configure projects, add knowledge sources, manage QnA pairs and synonyms, and deploy versions. Runtime (query) operations live in the separate `azure-ai-language-questionanswering` package.

> NOTE: This is a preview (`1.0.0b1`) targeting a preview service API version (`2025-05-15-preview`). APIs, models, and LRO result payloads may change before GA.

[Product documentation][product_docs]

## Getting started

### Prerequisites

- Python 3.9+ (preview requires 3.9 or later)
- An Azure subscription
- An Azure AI Language resource with Question Answering enabled (custom subdomain endpoint recommended for AAD)

### Install the package

```bash
pip install --pre azure-ai-language-questionanswering-authoring
```

Optional (for Azure Active Directory auth):

```bash
pip install azure-identity
```

### Authenticate the client

You can authenticate with:

1. Azure Active Directory via `DefaultAzureCredential` (recommended)
2. A resource key via `AzureKeyCredential` (quick start / local experimentation)

AAD example:
```python
from azure.identity import DefaultAzureCredential
from azure.ai.language.questionanswering.authoring import QuestionAnsweringAuthoringClient

endpoint = "https://<resource-name>.cognitiveservices.azure.com"
credential = DefaultAzureCredential()
client = QuestionAnsweringAuthoringClient(endpoint, credential)
```

Key credential example:
```python
from azure.core.credentials import AzureKeyCredential
from azure.ai.language.questionanswering.authoring import QuestionAnsweringAuthoringClient

client = QuestionAnsweringAuthoringClient(
endpoint="https://<resource-name>.cognitiveservices.azure.com",
credential=AzureKeyCredential("<api-key>")
)
```

## Key concepts

- **Project**: A logical container for your knowledge sources, QnA pairs, synonyms, and deployments.
- **Knowledge Source**: A URL/file describing content from which QnA pairs can be extracted.
- **QnA Record**: A question and its answer plus metadata/alternative questions.
- **Synonyms**: Word alteration groups to normalize variations in user questions.
- **Deployment**: A named (e.g., `production`) deployed snapshot of your project used by runtime clients.
- **Long‑running operation (LRO)**: Certain operations (update sources/QnAs, import, export, deploy) return an `LROPoller`. In the current preview these resolve to `None`—treat `.result()` strictly as a completion signal.

## Examples

Below are minimal synchronous examples. More complete samples (including async equivalents) are in the samples directory. Environment variables used by samples: `AZURE_QUESTIONANSWERING_ENDPOINT`, `AZURE_QUESTIONANSWERING_KEY`.

### Create a project
```python
metadata = {
"language": "en",
"description": "FAQ project",
"settings": {"defaultAnswer": "no answer"},
"multilingualResource": True,
}
client.create_project(project_name="FAQ", body=metadata)
```

### List projects
```python
for proj in client.list_projects():
print(proj.get("projectName"), proj.get("lastModifiedDateTime"))
```

### Add / update a knowledge source
```python
from azure.ai.language.questionanswering.authoring.models import UpdateSourceRecord,UpdateQnaSourceRecord

poller = client.begin_update_sources(
project_name="FAQ",
body=[
UpdateSourceRecord(
op="add",
value=UpdateQnaSourceRecord(
display_name="ContosoFAQ",
source="https://contoso.com/faq",
source_uri="https://contoso.com/faq",
source_kind="url",
content_structure_kind="unstructured",
refresh=False,
),
)
],
)
poller.result()
```

### Add a QnA pair
```python
from azure.ai.language.questionanswering.authoring.models import UpdateQnaRecord,QnaRecord

poller = client.begin_update_qnas(
project_name="FAQ",
body=[
UpdateQnaRecord(
op="add",
value=QnaRecord(
id=1,
answer="Use the Azure SDKs.",
source="manual",
questions=["How do I use Azure services in .NET?"],
),
)
],
)
poller.result()
```

### Set synonyms
```python
from azure.ai.language.questionanswering.authoring.models import SynonymAssets,WordAlterations

client.update_synonyms(
project_name="FAQ",
body=SynonymAssets(
value=[
WordAlterations(alterations=["qnamaker", "qna maker"]),
WordAlterations(alterations=["qna", "question and answer"]),
]
),
)
```

### Deploy
```python
client.begin_deploy_project(project_name="FAQ", deployment_name="production").result()
```

### Export / Import
```python
export_poller = client.begin_export(project_name="FAQ", format="json")
export_poller.result() # current preview returns None

from azure.ai.language.questionanswering.authoring.models import ImportJobOptions,Assets,ImportQnaRecord
assets = ImportJobOptions(
assets=Assets(
qnas=[
ImportQnaRecord(
id=1,
answer="Example answer",
source="https://contoso.com/faq",
questions=["Example question?"],
)
]
)
)
client.begin_import_assets(project_name="FAQ", body=assets, format="json").result()
```

## Troubleshooting

### Errors
Service errors raise `HttpResponseError` (or subclasses) from `azure-core`. Check the `.status_code` / `.message` for details.

```python
from azure.core.exceptions import HttpResponseError

try:
client.list_projects()
except HttpResponseError as e:
print("Request failed:", e.message)
```

### Logging
Enable basic logging:
```python
import logging
logging.basicConfig(level=logging.INFO)
```
For request/response details set environment variable `AZURE_LOG_LEVEL=info` or pass `logging_enable=True` per operation.

## Next steps

- Explore the full samples
- Learn about Question Answering concepts in [product documentation][product_docs]

## Contributing

See [CONTRIBUTING.md][contributing] for instructions on building, testing, and contributing.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit <https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][coc_faq] or contact <mailto:opencode@microsoft.com> with any additional questions or comments.

<!-- LINKS -->
[product_docs]: https://learn.microsoft.com/azure/ai-services/language-service/question-answering/overview
[contributing]: https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"apiVersion": "2025-05-15-preview"
}
Loading