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:
parent
87886fbbac
commit
05935ed2f3
3 changed files with 2090 additions and 776 deletions
|
|
@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
||||||
from langflow.custom import Component
|
from langflow.custom import Component
|
||||||
from langflow.field_typing import Text, VectorStore
|
from langflow.field_typing import Text, VectorStore
|
||||||
from langflow.helpers.data import docs_to_data
|
from langflow.helpers.data import docs_to_data
|
||||||
|
from langflow.inputs.inputs import BoolInput
|
||||||
from langflow.io import DataInput, MultilineInput, Output
|
from langflow.io import DataInput, MultilineInput, Output
|
||||||
from langflow.schema import Data, DataFrame
|
from langflow.schema import Data, DataFrame
|
||||||
|
|
||||||
|
|
@ -23,7 +24,9 @@ def check_cached_vector_store(f):
|
||||||
|
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def check_cached(self, *args, **kwargs):
|
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
|
return self._cached_vector_store
|
||||||
|
|
||||||
result = f(self, *args, **kwargs)
|
result = f(self, *args, **kwargs)
|
||||||
|
|
@ -62,6 +65,14 @@ class LCVectorStoreComponent(Component):
|
||||||
display_name="Search Query",
|
display_name="Search Query",
|
||||||
tool_mode=True,
|
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 = [
|
outputs = [
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue