Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: astradb ingests twice #2573

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/backend/base/langflow/components/vectorstores/AstraDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
),
]

def _build_vector_store_no_ingest(self):
def _build_vector_store(self):
# cache the vector store to avoid re-initializing and ingest data again
if self._cached_vectorstore:
return self._cached_vectorstore

Expand Down Expand Up @@ -224,6 +225,8 @@ def _build_vector_store_no_ingest(self):
except Exception as e:
raise ValueError(f"Error initializing AstraDBVectorStore: {str(e)}") from e

self._add_documents_to_vector_store(vector_store)

self._cached_vectorstore = vector_store

return vector_store
Expand Down Expand Up @@ -266,8 +269,7 @@ def _build_search_args(self):
return args

def search_documents(self) -> list[Data]:
vector_store = self._build_vector_store_no_ingest()
self._add_documents_to_vector_store(vector_store)
vector_store = self._build_vector_store()

logger.debug(f"Search input: {self.search_input}")
logger.debug(f"Search type: {self.search_type}")
Expand Down Expand Up @@ -300,6 +302,5 @@ def get_retriever_kwargs(self):
}

def build_vector_store(self):
vector_store = self._build_vector_store_no_ingest()
self._add_documents_to_vector_store(vector_store)
vector_store = self._build_vector_store()
return vector_store
Loading