From 22d90800c86799a3a385b73ba09608c9b6565e0a Mon Sep 17 00:00:00 2001 From: Pashva Mehta <61597430+pashva@users.noreply.github.com> Date: Mon, 29 Jan 2024 06:23:31 +0530 Subject: [PATCH] community: Fixed schema discrepancy in from_texts function for weaviate vectorstore (#16693) * Description: Fixed schema discrepancy in **from_texts** function for weaviate vectorstore which created a redundant property "key" inside a class. * Issue: Fixed: https://github.com/langchain-ai/langchain/issues/16692 * Twitter handle: @pashvamehta1 --- libs/community/langchain_community/vectorstores/weaviate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/weaviate.py b/libs/community/langchain_community/vectorstores/weaviate.py index 119e7bc0d7e..8d4e6e472b9 100644 --- a/libs/community/langchain_community/vectorstores/weaviate.py +++ b/libs/community/langchain_community/vectorstores/weaviate.py @@ -25,12 +25,12 @@ if TYPE_CHECKING: import weaviate -def _default_schema(index_name: str) -> Dict: +def _default_schema(index_name: str, text_key: str) -> Dict: return { "class": index_name, "properties": [ { - "name": "text", + "name": text_key, "dataType": ["text"], } ], @@ -460,7 +460,7 @@ class Weaviate(VectorStore): client.batch.configure(batch_size=batch_size) index_name = index_name or f"LangChain_{uuid4().hex}" - schema = _default_schema(index_name) + schema = _default_schema(index_name, text_key) # check whether the index already exists if not client.schema.exists(index_name): client.schema.create_class(schema)