feat: Add option to disable vector store caching (#6713)

* add possibility to user cache or not vector stores - default is cached

* update started projects

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* updating vector store template

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-02-24 16:22:05 -03:00 committed by GitHub
commit 05935ed2f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2090 additions and 776 deletions

View file

@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
from langflow.custom import Component
from langflow.field_typing import Text, VectorStore
from langflow.helpers.data import docs_to_data
from langflow.inputs.inputs import BoolInput
from langflow.io import DataInput, MultilineInput, Output
from langflow.schema import Data, DataFrame
@ -23,7 +24,9 @@ def check_cached_vector_store(f):
@wraps(f)
def check_cached(self, *args, **kwargs):
if self._cached_vector_store is not None:
should_cache = getattr(self, "should_cache_vector_store", True)
if should_cache and self._cached_vector_store is not None:
return self._cached_vector_store
result = f(self, *args, **kwargs)
@ -62,6 +65,14 @@ class LCVectorStoreComponent(Component):
display_name="Search Query",
tool_mode=True,
),
BoolInput(
name="should_cache_vector_store",
display_name="Cache Vector Store",
value=True,
advanced=True,
info="If True, the vector store will be cached for the current build of the component. "
"This is useful for components that have multiple output methods and want to share the same vector store.",
),
]
outputs = [

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long