Skip to content

Commit 6138487

Browse files
Python: Phase 2: Embedding clients for Ollama, Bedrock, and Azure AI Inference (#4207)
* Phase 2: Embedding clients for Ollama, Bedrock, and Azure AI Inference Add embedding client implementations to existing provider packages: - OllamaEmbeddingClient: Text embeddings via Ollama's embed API - BedrockEmbeddingClient: Text embeddings via Amazon Titan on Bedrock - AzureAIInferenceEmbeddingClient: Text and image embeddings via Azure AI Inference, supporting Content | str input with separate model IDs for text (AZURE_AI_INFERENCE_EMBEDDING_MODEL_ID) and image (AZURE_AI_INFERENCE_IMAGE_EMBEDDING_MODEL_ID) endpoints Additional changes: - Rename EmbeddingCoT -> EmbeddingT, EmbeddingOptionsCoT -> EmbeddingOptionsT - Add otel_provider_name passthrough to all embedding clients - Register integration pytest marker in all packages - Add lazy-loading namespace exports for Ollama and Bedrock embeddings - Add image embedding sample using Cohere-embed-v3-english - Add azure-ai-inference dependency to azure-ai package Part of #1188 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix mypy duplicate name and ruff lint issues - Rename second 'vector' variable to 'img_vector' in image embedding loop - Combine nested with statements in tests - Remove unused result assignments in tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * updates from feedback * Fix CI failures in embedding usage handling - Fix Azure AI embedding mypy issues by normalizing vectors to list[float], safely accumulating optional usage token fields, and filtering None entries before constructing GeneratedEmbeddings - Avoid Bandit false positive by initializing usage details as an empty dict - Update OpenAI embedding tests to assert canonical usage keys (input_token_count/total_token_count) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e3a5b91 commit 6138487

44 files changed

Lines changed: 1836 additions & 34 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/features/vector-stores-and-embeddings/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ This feature ports the vector store abstractions, embedding generator abstractio
140140

141141
## Implementation Phases
142142

143-
### Phase 1: Core Embedding Abstractions & OpenAI Implementation
143+
### Phase 1: Core Embedding Abstractions & OpenAI Implementation ✅ DONE
144144
**Goal:** Establish the embedding generator abstraction and ship one working implementation.
145145
**Mergeable:** Yes — adds new types/protocols, no breaking changes.
146+
**Status:** Merged via PR #4153. Closes sub-issue #4163.
146147

147148
#### 1.1 — Embedding types in `_types.py`
148149
- `EmbeddingInputT` TypeVar (default `str`) — generic input type for embedding generation

python/packages/a2a/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ environments = [
3737

3838
[tool.uv-dynamic-versioning]
3939
fallback-version = "0.0.0"
40+
4041
[tool.pytest.ini_options]
4142
testpaths = 'tests'
4243
addopts = "-ra -q -r fEX"
@@ -46,6 +47,9 @@ filterwarnings = [
4647
"ignore:Support for class-based `config` is deprecated:DeprecationWarning:pydantic.*"
4748
]
4849
timeout = 120
50+
markers = [
51+
"integration: marks tests as integration tests that require external services",
52+
]
4953

5054
[tool.ruff]
5155
extend = "../../pyproject.toml"
@@ -79,6 +83,7 @@ exclude_dirs = ["tests"]
7983
[tool.poe]
8084
executor.type = "uv"
8185
include = "../../shared_tasks.toml"
86+
8287
[tool.poe.tasks]
8388
mypy = "mypy --config-file $POE_ROOT/pyproject.toml agent_framework_a2a"
8489
test = "pytest --cov=agent_framework_a2a --cov-report=term-missing:skip-covered tests"

python/packages/ag-ui/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ packages = ["agent_framework_ag_ui", "agent_framework_ag_ui_examples"]
4545
asyncio_mode = "auto"
4646
testpaths = ["tests/ag_ui"]
4747
pythonpath = ["."]
48+
markers = [
49+
"integration: marks tests as integration tests that require external services",
50+
]
4851

4952
[tool.ruff]
5053
line-length = 120

python/packages/anthropic/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ environments = [
3737

3838
[tool.uv-dynamic-versioning]
3939
fallback-version = "0.0.0"
40+
4041
[tool.pytest.ini_options]
4142
testpaths = 'tests'
4243
addopts = "-ra -q -r fEX"
@@ -46,6 +47,9 @@ filterwarnings = [
4647
"ignore:Support for class-based `config` is deprecated:DeprecationWarning:pydantic.*"
4748
]
4849
timeout = 120
50+
markers = [
51+
"integration: marks tests as integration tests that require external services",
52+
]
4953

5054
[tool.ruff]
5155
extend = "../../pyproject.toml"
@@ -80,6 +84,7 @@ exclude_dirs = ["tests"]
8084
[tool.poe]
8185
executor.type = "uv"
8286
include = "../../shared_tasks.toml"
87+
8388
[tool.poe.tasks]
8489
mypy = "mypy --config-file $POE_ROOT/pyproject.toml agent_framework_anthropic"
8590
test = "pytest --cov=agent_framework_anthropic --cov-report=term-missing:skip-covered -n auto --dist worksteal tests"

python/packages/azure-ai-search/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ filterwarnings = [
4747
"ignore:Support for class-based `config` is deprecated:DeprecationWarning:pydantic.*"
4848
]
4949
timeout = 120
50+
markers = [
51+
"integration: marks tests as integration tests that require external services",
52+
]
5053

5154
[tool.ruff]
5255
extend = "../../pyproject.toml"
@@ -82,6 +85,7 @@ exclude_dirs = ["tests"]
8285
[tool.poe]
8386
executor.type = "uv"
8487
include = "../../shared_tasks.toml"
88+
8589
[tool.poe.tasks]
8690
mypy = "mypy --config-file $POE_ROOT/pyproject.toml agent_framework_azure_ai_search"
8791
test = "pytest --cov=agent_framework_azure_ai_search --cov-report=term-missing:skip-covered tests"

python/packages/azure-ai/agent_framework_azure_ai/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
from ._agent_provider import AzureAIAgentsProvider
66
from ._chat_client import AzureAIAgentClient, AzureAIAgentOptions
77
from ._client import AzureAIClient, AzureAIProjectAgentOptions, RawAzureAIClient
8+
from ._embedding_client import (
9+
AzureAIInferenceEmbeddingClient,
10+
AzureAIInferenceEmbeddingOptions,
11+
AzureAIInferenceEmbeddingSettings,
12+
RawAzureAIInferenceEmbeddingClient,
13+
)
814
from ._foundry_memory_provider import FoundryMemoryProvider
915
from ._project_provider import AzureAIProjectAgentProvider
1016
from ._shared import AzureAISettings
@@ -19,10 +25,14 @@
1925
"AzureAIAgentOptions",
2026
"AzureAIAgentsProvider",
2127
"AzureAIClient",
28+
"AzureAIInferenceEmbeddingClient",
29+
"AzureAIInferenceEmbeddingOptions",
30+
"AzureAIInferenceEmbeddingSettings",
2231
"AzureAIProjectAgentOptions",
2332
"AzureAIProjectAgentProvider",
2433
"AzureAISettings",
2534
"FoundryMemoryProvider",
2635
"RawAzureAIClient",
36+
"RawAzureAIInferenceEmbeddingClient",
2737
"__version__",
2838
]

0 commit comments

Comments
 (0)