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 @@ -1297,7 +1297,6 @@ def test_text_only_messages(self) -> None:
assert result[0].content[0].text == "hello"

def test_image_uri_content(self) -> None:
from agent_framework import Content

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line uses Content.from_uri(...) but the local from agent_framework import Content import was removed in this hunk and no module-level import for Content is visible in the diff. If Content is not already imported at the top of this file, all six affected test methods will fail with NameError. Please verify a module-level import exists, or add one.

img = Content.from_uri(uri="https://example.com/photo.png", media_type="image/png")
messages = [Message(role="user", contents=[img])]
Expand All @@ -1309,7 +1308,6 @@ def test_image_uri_content(self) -> None:
assert result[0].content[0].image.url == "https://example.com/photo.png"

def test_mixed_text_and_image_content(self) -> None:
from agent_framework import Content

text = Content.from_text("describe this image")
img = Content.from_uri(uri="https://example.com/img.jpg", media_type="image/jpeg")
Expand All @@ -1319,15 +1317,13 @@ def test_mixed_text_and_image_content(self) -> None:
assert len(result[0].content) == 2

def test_skips_non_text_non_image_content(self) -> None:
from agent_framework import Content

error = Content.from_error(message="oops")
messages = [Message(role="user", contents=[error])]
result = AzureAISearchContextProvider._prepare_messages_for_kb_search(messages)
assert len(result) == 0 # message had no usable content

def test_skips_empty_text(self) -> None:
from agent_framework import Content

empty = Content.from_text("")
messages = [Message(role="user", contents=[empty])]
Expand All @@ -1341,7 +1337,6 @@ def test_fallback_to_msg_text_when_no_contents(self) -> None:
assert result[0].content[0].text == "fallback text"

def test_data_uri_image(self) -> None:
from agent_framework import Content

img = Content.from_data(data=b"\x89PNG", media_type="image/png")
messages = [Message(role="user", contents=[img])]
Expand All @@ -1352,7 +1347,6 @@ def test_data_uri_image(self) -> None:
assert isinstance(result[0].content[0], KnowledgeBaseMessageImageContent)

def test_non_image_uri_skipped(self) -> None:
from agent_framework import Content

pdf = Content.from_uri(uri="https://example.com/doc.pdf", media_type="application/pdf")
messages = [Message(role="user", contents=[pdf])]
Expand Down Expand Up @@ -1568,9 +1562,7 @@ def test_references_become_annotations(self) -> None:
KnowledgeBaseMessage(role="assistant", content=[KnowledgeBaseMessageTextContent(text="answer")]),
],
references=[
KnowledgeBaseWebReference(
id="ref-1", activity_source=0, url="https://example.com", title="Example"
),
KnowledgeBaseWebReference(id="ref-1", activity_source=0, url="https://example.com", title="Example"),
],
)
result = AzureAISearchContextProvider._parse_messages_from_kb_response(response)
Expand Down
28 changes: 28 additions & 0 deletions python/packages/azure-cosmos/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Azure Cosmos DB Package (agent-framework-azure-cosmos)

Azure Cosmos DB history provider integration for Agent Framework.

## Main Classes

- **`CosmosHistoryProvider`** - Persistent conversation history storage backed by Azure Cosmos DB

## Usage

```python
from agent_framework_azure_cosmos import CosmosHistoryProvider

provider = CosmosHistoryProvider(
endpoint="https://<account>.documents.azure.com:443/",
credential="<key-or-token-credential>",
database_name="agent-framework",
container_name="chat-history",
)
```

Container name is configured on the provider. `session_id` is used as the partition key.

## Import Path

```python
from agent_framework_azure_cosmos import CosmosHistoryProvider
```
21 changes: 21 additions & 0 deletions python/packages/azure-cosmos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

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
38 changes: 38 additions & 0 deletions python/packages/azure-cosmos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Microsoft. All rights reserved.

import importlib.metadata

from ._history_provider import CosmosHistoryProvider

try:
__version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0" # Fallback for development mode

__all__ = [
"CosmosHistoryProvider",
"__version__",
]
Loading
Loading