Skip to content

Commit

Permalink
Added ability to pass in dictionary schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dhanshew72 committed Aug 1, 2024
1 parent a76c606 commit 535bc47
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/weaviate/langchain_weaviate/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(
index_name: Optional[str],
text_key: str,
embedding: Optional[Embeddings] = None,
schema: Optional[dict] = None,
attributes: Optional[List[str]] = None,
relevance_score_fn: Optional[
Callable[[float], float]
Expand All @@ -113,12 +114,15 @@ def __init__(
if attributes is not None:
self._query_attrs.extend(attributes)

schema = _default_schema(self._index_name)
schema["MultiTenancyConfig"] = {"enabled": use_multi_tenancy}
if not schema:
self.schema = _default_schema(self._index_name)
self.schema["MultiTenancyConfig"] = {"enabled": use_multi_tenancy}
else:
self.schema = schema

# check whether the index already exists
if not client.collections.exists(self._index_name):
client.collections.create_from_dict(schema)
client.collections.create_from_dict(self.schema)

# store collection for convenience
# this does not actually send a request to weaviate
Expand Down

0 comments on commit 535bc47

Please sign in to comment.