Skip to content

Commit

Permalink
Fix weaviate client 4.4rc1 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm207 committed Jan 30, 2024
1 parent 60abd8f commit 7f515de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions langchain_weaviate/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/test_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})]

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7f515de

Please sign in to comment.