refactor: Add SelectivePassThroughComponent to experimental components and update ChromaVectorStoreComponent

This commit is contained in:
Rodrigo 2024-06-18 12:55:36 -03:00
commit 24c5275899
2 changed files with 8 additions and 4 deletions

View file

@ -13,6 +13,8 @@ from .SplitText import SplitTextComponent
from .SQLExecutor import SQLExecutorComponent from .SQLExecutor import SQLExecutorComponent
from .SubFlow import SubFlowComponent from .SubFlow import SubFlowComponent
from .ConditionalRouter import ConditionalRouterComponent from .ConditionalRouter import ConditionalRouterComponent
from .SelectivePassThrough import SelectivePassThroughComponent
__all__ = [ __all__ = [
"AgentComponent", "AgentComponent",
@ -30,4 +32,5 @@ __all__ = [
"SplitTextComponent", "SplitTextComponent",
"SQLExecutorComponent", "SQLExecutorComponent",
"SubFlowComponent", "SubFlowComponent",
"SelectivePassThroughComponent",
] ]

View file

@ -7,7 +7,7 @@ from loguru import logger
from langflow.base.vectorstores.model import LCVectorStoreComponent from langflow.base.vectorstores.model import LCVectorStoreComponent
from langflow.base.vectorstores.utils import chroma_collection_to_data from langflow.base.vectorstores.utils import chroma_collection_to_data
from langflow.inputs import BoolInput, DataInput, DropdownInput, HandleInput, IntInput, MessageInput, StrInput from langflow.inputs import BoolInput, DataInput, DropdownInput, HandleInput, IntInput, MessageInput, StrInput, TextInput
from langflow.schema import Data from langflow.schema import Data
if TYPE_CHECKING: if TYPE_CHECKING:
@ -39,7 +39,7 @@ class ChromaVectorStoreComponent(LCVectorStoreComponent):
display_name="Code", display_name="Code",
advanced=True, advanced=True,
), ),
MessageInput( TextInput(
name="search_query", name="search_query",
display_name="Search Query", display_name="Search Query",
is_list=True, is_list=True,
@ -139,6 +139,7 @@ class ChromaVectorStoreComponent(LCVectorStoreComponent):
collection_name=self.collection_name, collection_name=self.collection_name,
) )
self._add_documents_to_vector_store(chroma)
self.status = chroma_collection_to_data(chroma.get(self.limit)) self.status = chroma_collection_to_data(chroma.get(self.limit))
return chroma return chroma
@ -177,7 +178,7 @@ class ChromaVectorStoreComponent(LCVectorStoreComponent):
""" """
Search for documents in the Chroma vector store. Search for documents in the Chroma vector store.
""" """
if not self.search_query.text: if not self.search_query:
self.status = "" self.status = ""
return return
@ -194,6 +195,6 @@ class ChromaVectorStoreComponent(LCVectorStoreComponent):
self.search_query = self.search_query[0] self.search_query = self.search_query[0]
search_results = self.search_with_vector_store( search_results = self.search_with_vector_store(
self.search_query.text, self.search_type, vector_store, k=self.number_of_results self.search_query, self.search_type, vector_store, k=self.number_of_results
) )
return search_results return search_results