Merge branch 'two_edges' of personal:langflow-ai/langflow into two_edges

This commit is contained in:
anovazzi1 2024-06-18 13:04:45 -03:00
commit cc7a08c52a
3 changed files with 16 additions and 7 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, 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,7 +139,8 @@ class ChromaVectorStoreComponent(LCVectorStoreComponent):
collection_name=self.collection_name, collection_name=self.collection_name,
) )
self.status = chroma_collection_to_data(chroma.get(self.limit)) self._add_documents_to_vector_store(chroma)
self.status = chroma_collection_to_data(chroma.get(limit=self.limit))
return chroma return chroma
def _add_documents_to_vector_store(self, vector_store: "Chroma") -> None: def _add_documents_to_vector_store(self, vector_store: "Chroma") -> None:
@ -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

View file

@ -75,9 +75,14 @@ def get_message(payload):
def build_logs(vertex, result) -> dict: def build_logs(vertex, result) -> dict:
logs = dict() logs = dict()
payload = result[0]._results component_instance = result[0]
for index, output in enumerate(vertex.outputs): for index, output in enumerate(vertex.outputs):
output_result = payload.get(output["name"]) if component_instance.status is None:
payload = component_instance._results
output_result = payload.get(output["name"])
else:
payload = component_instance._artifacts
output_result = payload.get(output["name"]).get("raw")
message = get_message(output_result) message = get_message(output_result)
_type = get_type(output_result) _type = get_type(output_result)