Skip to content

Commit 535bc47

Browse files
committed
Added ability to pass in dictionary schema
1 parent a76c606 commit 535bc47

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libs/weaviate/langchain_weaviate/vectorstores.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __init__(
9191
index_name: Optional[str],
9292
text_key: str,
9393
embedding: Optional[Embeddings] = None,
94+
schema: Optional[dict] = None,
9495
attributes: Optional[List[str]] = None,
9596
relevance_score_fn: Optional[
9697
Callable[[float], float]
@@ -113,12 +114,15 @@ def __init__(
113114
if attributes is not None:
114115
self._query_attrs.extend(attributes)
115116

116-
schema = _default_schema(self._index_name)
117-
schema["MultiTenancyConfig"] = {"enabled": use_multi_tenancy}
117+
if not schema:
118+
self.schema = _default_schema(self._index_name)
119+
self.schema["MultiTenancyConfig"] = {"enabled": use_multi_tenancy}
120+
else:
121+
self.schema = schema
118122

119123
# check whether the index already exists
120124
if not client.collections.exists(self._index_name):
121-
client.collections.create_from_dict(schema)
125+
client.collections.create_from_dict(self.schema)
122126

123127
# store collection for convenience
124128
# this does not actually send a request to weaviate

0 commit comments

Comments
 (0)