fix: astradb ingests twice (#2573)
This commit is contained in:
parent
7dcc716811
commit
8339fcf0d8
1 changed files with 6 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
@ -224,6 +225,8 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
|
|||
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
|
||||
|
|
@ -266,8 +269,7 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
|
|||
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}")
|
||||
|
|
@ -300,6 +302,5 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
|
|||
}
|
||||
|
||||
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…
Add table
Add a link
Reference in a new issue