@ -17,7 +17,6 @@ CONNECTION_STRING = PGVector.connection_string_from_db_params(
password = os . environ . get ( " TEST_PGVECTOR_PASSWORD " , " postgres " ) ,
password = os . environ . get ( " TEST_PGVECTOR_PASSWORD " , " postgres " ) ,
)
)
ADA_TOKEN_COUNT = 1536
ADA_TOKEN_COUNT = 1536
@ -186,6 +185,27 @@ def test_pgvector_with_filter_in_set() -> None:
]
]
def test_pgvector_with_filter_nin_set ( ) - > None :
""" Test end to end construction and search. """
texts = [ " foo " , " bar " , " baz " ]
metadatas = [ { " page " : str ( i ) } for i in range ( len ( texts ) ) ]
docsearch = PGVector . from_texts (
texts = texts ,
collection_name = " test_collection_filter " ,
embedding = FakeEmbeddingsWithAdaDimension ( ) ,
metadatas = metadatas ,
connection_string = CONNECTION_STRING ,
pre_delete_collection = True ,
)
output = docsearch . similarity_search_with_score (
" foo " , k = 2 , filter = { " page " : { " NIN " : [ " 1 " ] } }
)
assert output == [
( Document ( page_content = " foo " , metadata = { " page " : " 0 " } ) , 0.0 ) ,
( Document ( page_content = " baz " , metadata = { " page " : " 2 " } ) , 0.0013003906671379406 ) ,
]
def test_pgvector_delete_docs ( ) - > None :
def test_pgvector_delete_docs ( ) - > None :
""" Add and delete documents. """
""" Add and delete documents. """
texts = [ " foo " , " bar " , " baz " ]
texts = [ " foo " , " bar " , " baz " ]