@@ -154,3 +154,36 @@ def test_insert_chunks_with_precomputed_embeddings(client_with_empty_registry, e
154
154
assert len (response .chunks ) > 0
155
155
assert response .chunks [0 ].metadata ["document_id" ] == "doc1"
156
156
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