mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
c37f74f898
* Created cosmos history provider * add marker * Python: address Cosmos PR feedback - address provider/test/sample review feedback and cleanup typing - add cosmos integration test coverage and skip gating - add dedicated cosmos emulator jobs to python merge/integration workflows - switch cosmos workflow execution to package poe integration-tests task Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Python: handle empty Cosmos session id - replace default partition fallback for empty session_id - log warning and generate GUID when session_id is empty - update unit tests to validate GUID fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix sample * fix cross partition query --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 lines
1.2 KiB
Markdown
39 lines
1.2 KiB
Markdown
# Get Started with Microsoft Agent Framework Azure Cosmos DB
|
|
|
|
Please install this package via pip:
|
|
|
|
```bash
|
|
pip install agent-framework-azure-cosmos --pre
|
|
```
|
|
|
|
## Azure Cosmos DB History Provider
|
|
|
|
The Azure Cosmos DB integration provides `CosmosHistoryProvider` for persistent conversation history storage.
|
|
|
|
### Basic Usage Example
|
|
|
|
```python
|
|
from azure.identity.aio import DefaultAzureCredential
|
|
from agent_framework_azure_cosmos import CosmosHistoryProvider
|
|
|
|
provider = CosmosHistoryProvider(
|
|
endpoint="https://<account>.documents.azure.com:443/",
|
|
credential=DefaultAzureCredential(),
|
|
database_name="agent-framework",
|
|
container_name="chat-history",
|
|
)
|
|
```
|
|
|
|
Credentials follow the same pattern used by other Azure connectors in the repository:
|
|
|
|
- Pass a credential object (for example `DefaultAzureCredential`)
|
|
- Or pass a key string directly
|
|
- Or set `AZURE_COSMOS_KEY` in the environment
|
|
|
|
Container naming behavior:
|
|
|
|
- Container name is configured on the provider (`container_name` or `AZURE_COSMOS_CONTAINER_NAME`)
|
|
- `session_id` is used as the Cosmos partition key for reads/writes
|
|
|
|
See `samples/cosmos_history_provider.py` for a runnable package-local example.
|