Skip to content

Commit

Permalink
update Weaviate to support multi tenancy (langchain-ai#11842)
Browse files Browse the repository at this point in the history
- **Description:** update Weaviate to support multi tenancy
  - **Issue:** 9956
  - **Dependencies:** 
  - **Tag maintainer:** hwchase17
  - **Twitter handle:** dsx1986_
  • Loading branch information
dsx1986 authored Oct 19, 2023
1 parent f818ec4 commit ed62984
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libs/langchain/langchain/vectorstores/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def similarity_search_by_text(
query_obj = self._client.query.get(self._index_name, self._query_attrs)
if kwargs.get("where_filter"):
query_obj = query_obj.with_where(kwargs.get("where_filter"))
if kwargs.get("tenant"):
query_obj = query_obj.with_tenant(kwargs.get("tenant"))
if kwargs.get("additional"):
query_obj = query_obj.with_additional(kwargs.get("additional"))
result = query_obj.with_near_text(content).with_limit(k).do()
Expand All @@ -228,6 +230,8 @@ def similarity_search_by_vector(
query_obj = self._client.query.get(self._index_name, self._query_attrs)
if kwargs.get("where_filter"):
query_obj = query_obj.with_where(kwargs.get("where_filter"))
if kwargs.get("tenant"):
query_obj = query_obj.with_tenant(kwargs.get("tenant"))
if kwargs.get("additional"):
query_obj = query_obj.with_additional(kwargs.get("additional"))
result = query_obj.with_near_vector(vector).with_limit(k).do()
Expand Down Expand Up @@ -304,6 +308,8 @@ def max_marginal_relevance_search_by_vector(
query_obj = self._client.query.get(self._index_name, self._query_attrs)
if kwargs.get("where_filter"):
query_obj = query_obj.with_where(kwargs.get("where_filter"))
if kwargs.get("tenant"):
query_obj = query_obj.with_tenant(kwargs.get("tenant"))
results = (
query_obj.with_additional("vector")
.with_near_vector(vector)
Expand Down Expand Up @@ -343,6 +349,8 @@ def similarity_search_with_score(
query_obj = self._client.query.get(self._index_name, self._query_attrs)
if kwargs.get("where_filter"):
query_obj = query_obj.with_where(kwargs.get("where_filter"))
if kwargs.get("tenant"):
query_obj = query_obj.with_tenant(kwargs.get("tenant"))

embedded_query = self._embedding.embed_query(query)
if not self._by_text:
Expand Down

0 comments on commit ed62984

Please sign in to comment.