Emulator tests + sample for embedding generation
Parent: 46729
Depends on: 46733, 46734, 46735
Goal
End-to-end smoke against the emulator (or a live Cosmos account once the gateway change ships) for a hybrid-search query that uses embedding_generator. Lives under sdk/cosmos/azure-cosmos/tests/ and sdk/cosmos/azure-cosmos/samples/.
Pre-requisite
This issue cannot be fully exercised end-to-end until the gateway change is live in either the emulator or a deployable backend, because Python has no serviceinterop fast path — it always asks the gateway for the query plan. The work itself can land behind the new feature flag (gated on embedding_generator being set) without breaking existing customers.
Scope
- Extend
tests/test_query_hybrid_search.py and tests/test_query_hybrid_search_async.py with at least one case that:
- Issues a query expected to be rewritten with
embeddingParameterMap.
- Passes a mock generator that returns deterministic vectors (e.g.
[float(i) for i in range(D)]).
- Asserts the response is non-empty and the per-partition query was issued with the parameter populated. (One way:
mock_send_request interception on the connection.)
- Skips with a clear message when the gateway version doesn't yet support
EmbeddingGeneration.
- New sample under
samples/:
embedding_generation_sample.py (sync)
embedding_generation_sample_async.py (async)
- Shows how to implement an
EmbeddingGenerator (a stub that returns [0.0] * 1536 is fine for the sample), and how to pass it to query_items.
- CHANGELOG entry under the current unreleased version, calling out:
- New
EmbeddingGenerator / AsyncEmbeddingGenerator protocols.
- New
embedding_generator keyword on Container.query_items / ContainerProxy.query_items.
- Dependency on the gateway change (link parent issue).
Files touched
sdk/cosmos/azure-cosmos/tests/test_query_hybrid_search.py
sdk/cosmos/azure-cosmos/tests/test_query_hybrid_search_async.py
sdk/cosmos/azure-cosmos/samples/embedding_generation_sample.py (new)
sdk/cosmos/azure-cosmos/samples/embedding_generation_sample_async.py (new)
sdk/cosmos/azure-cosmos/CHANGELOG.md
Acceptance
- Emulator tests pass with a real or stubbed generator and document the gateway-version skip path.
- Samples run cleanly (or print "skipped: gateway support required" when not available).
- CHANGELOG entry is approved by the package's CODEOWNERS.
Emulator tests + sample for embedding generation
Parent: 46729
Depends on: 46733, 46734, 46735
Goal
End-to-end smoke against the emulator (or a live Cosmos account once the gateway change ships) for a hybrid-search query that uses
embedding_generator. Lives undersdk/cosmos/azure-cosmos/tests/andsdk/cosmos/azure-cosmos/samples/.Pre-requisite
This issue cannot be fully exercised end-to-end until the gateway change is live in either the emulator or a deployable backend, because Python has no
serviceinteropfast path — it always asks the gateway for the query plan. The work itself can land behind the new feature flag (gated onembedding_generatorbeing set) without breaking existing customers.Scope
tests/test_query_hybrid_search.pyandtests/test_query_hybrid_search_async.pywith at least one case that:embeddingParameterMap.[float(i) for i in range(D)]).mock_send_requestinterception on the connection.)EmbeddingGeneration.samples/:embedding_generation_sample.py(sync)embedding_generation_sample_async.py(async)EmbeddingGenerator(a stub that returns[0.0] * 1536is fine for the sample), and how to pass it toquery_items.EmbeddingGenerator/AsyncEmbeddingGeneratorprotocols.embedding_generatorkeyword onContainer.query_items/ContainerProxy.query_items.Files touched
sdk/cosmos/azure-cosmos/tests/test_query_hybrid_search.pysdk/cosmos/azure-cosmos/tests/test_query_hybrid_search_async.pysdk/cosmos/azure-cosmos/samples/embedding_generation_sample.py(new)sdk/cosmos/azure-cosmos/samples/embedding_generation_sample_async.py(new)sdk/cosmos/azure-cosmos/CHANGELOG.mdAcceptance