diff --git a/langchain_weaviate/vectorstores.py b/langchain_weaviate/vectorstores.py index 77e2432..19eca88 100644 --- a/langchain_weaviate/vectorstores.py +++ b/langchain_weaviate/vectorstores.py @@ -157,7 +157,7 @@ def add_texts( f"Tenant {tenant} does not exist in index {self._index_name}. " "Creating tenant." ) - tenant_objs = [weaviate.classes.Tenant(name=tenant)] + tenant_objs = [weaviate.classes.tenants.Tenant(name=tenant)] self._collection.tenants.create(tenants=tenant_objs) ids = [] @@ -167,7 +167,7 @@ def add_texts( texts = list(texts) embeddings = self._embedding.embed_documents(texts) - with self._client.batch as batch: + with self._client.batch.dynamic() as batch: for i, text in enumerate(texts): data_properties = {self._text_key: text} if metadatas is not None: @@ -259,7 +259,7 @@ def _perform_search( merged_props = { **obj.properties, **filtered_metadata, - **({"vector": obj.vector} if obj.vector else {}), + **({"vector": obj.vector["default"]} if obj.vector else {}), } doc = Document(page_content=text, metadata=merged_props) if not return_score: @@ -486,7 +486,7 @@ def delete( if ids is None: raise ValueError("No ids provided to delete.") - id_filter = weaviate.classes.Filter.by_id().contains_any(ids) + id_filter = weaviate.classes.query.Filter.by_id().contains_any(ids) with self._tenant_context(tenant) as collection: collection.data.delete_many(where=id_filter) diff --git a/tests/integration_tests/test_vectorstores.py b/tests/integration_tests/test_vectorstores.py index a043c1d..471adaf 100644 --- a/tests/integration_tests/test_vectorstores.py +++ b/tests/integration_tests/test_vectorstores.py @@ -111,7 +111,7 @@ def test_similarity_search_with_metadata_and_filter( texts, embedding_openai, metadatas=metadatas, client=weaviate_client ) output = docsearch.similarity_search( - "foo", k=2, filters=weaviate.classes.Filter.by_property("page").equal(0) + "foo", k=2, filters=weaviate.classes.query.Filter.by_property("page").equal(0) ) assert output == [Document(page_content="foo", metadata={"page": 0})] @@ -240,7 +240,7 @@ def test_max_marginal_relevance_search_with_filter( texts, embedding_openai, metadatas=metadatas, client=weaviate_client ) - is_page_0_filter = weaviate.classes.Filter.by_property("page").equal(0) + is_page_0_filter = weaviate.classes.query.Filter.by_property("page").equal(0) # if lambda=1 the algorithm should be equivalent to standard ranking standard_ranking = docsearch.similarity_search("foo", k=2, filters=is_page_0_filter) output = docsearch.max_marginal_relevance_search( @@ -444,7 +444,7 @@ def test_tenant_exists( ) -> None: index_name = "TestTenant" tenant_name = "Foo" - tenant = weaviate.classes.Tenant(name=tenant_name) + tenant = weaviate.classes.tenants.Tenant(name=tenant_name) # a collection with mt enabled docsearch_with_mt = WeaviateVectorStore(