Skip to content

Commit adc3736

Browse files
test: added integeration test that queries for identical vectors and verifies no divide by zero exception occurs
1 parent f5d2108 commit adc3736

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/integration/vector_io/test_vector_io.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,36 @@ def test_insert_chunks_with_precomputed_embeddings(client_with_empty_registry, e
154154
assert len(response.chunks) > 0
155155
assert response.chunks[0].metadata["document_id"] == "doc1"
156156
assert response.chunks[0].metadata["source"] == "precomputed"
157+
158+
159+
def test_query_returns_valid_object_when_identical_to_embedding_in_vdb(client_with_empty_registry, embedding_model_id):
160+
vector_db_id = "test_precomputed_embeddings_db"
161+
client_with_empty_registry.vector_dbs.register(
162+
vector_db_id=vector_db_id,
163+
embedding_model=embedding_model_id,
164+
embedding_dimension=384,
165+
)
166+
167+
chunks_with_embeddings = [
168+
Chunk(
169+
content="duplicate",
170+
metadata={"document_id": "doc1", "source": "precomputed"},
171+
embedding=[0.1] * 384,
172+
),
173+
]
174+
175+
client_with_empty_registry.vector_io.insert(
176+
vector_db_id=vector_db_id,
177+
chunks=chunks_with_embeddings,
178+
)
179+
180+
response = client_with_empty_registry.vector_io.query(
181+
vector_db_id=vector_db_id,
182+
query="duplicate",
183+
)
184+
185+
# Verify the top result is the expected document
186+
assert response is not None
187+
assert len(response.chunks) > 0
188+
assert response.chunks[0].metadata["document_id"] == "doc1"
189+
assert response.chunks[0].metadata["source"] == "precomputed"

0 commit comments

Comments
 (0)