Skip to content

Commit

Permalink
create collection once
Browse files Browse the repository at this point in the history
  • Loading branch information
rayshaw001 authored Jan 22, 2025
1 parent 57e6d89 commit 87f16fc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/core/rag/datasource/vdb/vector_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def create(self, texts: Optional[list] = None, **kwargs):
if texts:
for i in range(0, len(texts), max_batch_documents):
batch_documents = texts[i : i + max_batch_documents]
self.add_texts(batch_documents, duplicate_check=True, **kwargs)
batch_contents = [document.page_content for document in batch_documents]
batch_embeddings = self._embeddings.embed_documents(batch_contents)
if i < max_batch_documents:
self._vector_processor.create(texts=batch_documents, embeddings=batch_embeddings, **kwargs)
else:
self._vector_processor.add_texts(texts=batch_documents, embeddings=batch_embeddings, **kwargs)

def add_texts(self, documents: list[Document], **kwargs):
if kwargs.get("duplicate_check", False):
Expand Down

0 comments on commit 87f16fc

Please sign in to comment.