qdrant: new Qdrant implementation (#24164)

This commit is contained in:
Anush
2024-07-12 08:22:02 +05:30
committed by GitHub
parent 35784d1c33
commit 7014d07cab
8 changed files with 1082 additions and 35 deletions

View File

@@ -31,29 +31,7 @@ def assert_documents_equals(actual: List[Document], expected: List[Document]):
assert actual_doc.metadata == expected_doc.metadata
class FakeEmbeddings(Embeddings):
"""Fake embeddings functionality for testing."""
def embed_documents(self, texts: List[str]) -> List[List[float]]:
"""Return simple embeddings.
Embeddings encode each text as its index."""
return [[float(1.0)] * 9 + [float(i)] for i in range(len(texts))]
async def aembed_documents(self, texts: List[str]) -> List[List[float]]:
return self.embed_documents(texts)
def embed_query(self, text: str) -> List[float]:
"""Return constant query embeddings.
Embeddings are identical to embed_documents(texts)[0].
Distance to each text will be that text's index,
as it was passed to embed_documents."""
return [float(1.0)] * 9 + [float(0.0)]
async def aembed_query(self, text: str) -> List[float]:
return self.embed_query(text)
class ConsistentFakeEmbeddings(FakeEmbeddings):
class ConsistentFakeEmbeddings(Embeddings):
"""Fake embeddings which remember all the texts seen so far to return consistent
vectors for the same texts."""