mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 17:08:47 +00:00
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
This commit is contained in:
parent
ba70630829
commit
22d90800c8
@ -25,12 +25,12 @@ if TYPE_CHECKING:
|
|||||||
import weaviate
|
import weaviate
|
||||||
|
|
||||||
|
|
||||||
def _default_schema(index_name: str) -> Dict:
|
def _default_schema(index_name: str, text_key: str) -> Dict:
|
||||||
return {
|
return {
|
||||||
"class": index_name,
|
"class": index_name,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "text",
|
"name": text_key,
|
||||||
"dataType": ["text"],
|
"dataType": ["text"],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -460,7 +460,7 @@ class Weaviate(VectorStore):
|
|||||||
client.batch.configure(batch_size=batch_size)
|
client.batch.configure(batch_size=batch_size)
|
||||||
|
|
||||||
index_name = index_name or f"LangChain_{uuid4().hex}"
|
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
|
# check whether the index already exists
|
||||||
if not client.schema.exists(index_name):
|
if not client.schema.exists(index_name):
|
||||||
client.schema.create_class(schema)
|
client.schema.create_class(schema)
|
||||||
|
Loading…
Reference in New Issue
Block a user