mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-12 14:23:58 +00:00
community: enable SupabaseVectorStore to support extended table fields (#21762)
Thank you for contributing to LangChain! - [x] **PR title**: "community: enable SupabaseVectorStore to support extended table fields" - [x] **PR message**: - Added extension fields to the function _add_vectors so that users can add other custom fields when insert a record into the database. eg:  --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
2316635add
commit
bd39b2ccdf
@ -151,7 +151,9 @@ class SupabaseVectorStore(VectorStore):
|
||||
embeddings = embedding.embed_documents(texts)
|
||||
ids = [str(uuid.uuid4()) for _ in texts]
|
||||
docs = cls._texts_to_documents(texts, metadatas)
|
||||
cls._add_vectors(client, table_name, embeddings, docs, ids, chunk_size)
|
||||
cls._add_vectors(
|
||||
client, table_name, embeddings, docs, ids, chunk_size, **kwargs
|
||||
)
|
||||
|
||||
return cls(
|
||||
client=client,
|
||||
@ -324,6 +326,7 @@ class SupabaseVectorStore(VectorStore):
|
||||
documents: List[Document],
|
||||
ids: List[str],
|
||||
chunk_size: int,
|
||||
**kwargs: Any,
|
||||
) -> List[str]:
|
||||
"""Add vectors to Supabase table."""
|
||||
|
||||
@ -333,10 +336,10 @@ class SupabaseVectorStore(VectorStore):
|
||||
"content": documents[idx].page_content,
|
||||
"embedding": embedding,
|
||||
"metadata": documents[idx].metadata, # type: ignore
|
||||
**kwargs,
|
||||
}
|
||||
for idx, embedding in enumerate(vectors)
|
||||
]
|
||||
|
||||
id_list: List[str] = []
|
||||
for i in range(0, len(rows), chunk_size):
|
||||
chunk = rows[i : i + chunk_size]
|
||||
|
Loading…
Reference in New Issue
Block a user