From 01027cb7a350cc230e072f4b3f19ba857e59ec81 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Tue, 18 Jun 2024 21:25:04 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(loading.py):=20Fix=20bug=20wher?= =?UTF-8?q?e=20custom=20component=20outputs=20and=20results=20were=20not?= =?UTF-8?q?=20properly=20assigned?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 (base.py): Fix issue where outputs were not initialized causing potential errors --- src/backend/base/langflow/graph/vertex/base.py | 2 ++ src/backend/base/langflow/interface/initialize/loading.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/graph/vertex/base.py b/src/backend/base/langflow/graph/vertex/base.py index 1d1bda739..ad6a823a9 100644 --- a/src/backend/base/langflow/graph/vertex/base.py +++ b/src/backend/base/langflow/graph/vertex/base.py @@ -60,6 +60,7 @@ class Vertex: self.graph = graph self._data = data self.base_type: Optional[str] = base_type + self.outputs: List[Dict] = [] self._parse_data() self._built_object = UnbuiltObject() self._built_result = None @@ -190,6 +191,7 @@ class Vertex: else: self.outputs = self.data["node"].get("outputs", []) self.output = self.data["node"]["base_classes"] + self.display_name = self.data["node"].get("display_name", self.id.split("-")[0]) self.description = self.data["node"].get("description", "") diff --git a/src/backend/base/langflow/interface/initialize/loading.py b/src/backend/base/langflow/interface/initialize/loading.py index 4f4d5338c..7c29ddf27 100644 --- a/src/backend/base/langflow/interface/initialize/loading.py +++ b/src/backend/base/langflow/interface/initialize/loading.py @@ -1,12 +1,10 @@ import inspect import json import os -import warnings from typing import TYPE_CHECKING, Any, Type import orjson from loguru import logger -from pydantic import PydanticDeprecatedSince20 from langflow.custom.eval import eval_custom_component_code from langflow.schema import Data @@ -164,4 +162,6 @@ async def build_custom_component(params: dict, custom_component: "CustomComponen artifact_type = get_artifact_type(custom_component.repr_value or raw, build_result) raw = post_process_raw(raw, artifact_type) artifact = {"repr": custom_repr, "raw": raw, "type": artifact_type} + custom_component._artifacts = {custom_component.vertex.outputs[0].get("name"): artifact} + custom_component._results = {custom_component.vertex.outputs[0].get("name"): build_result} return custom_component, build_result, artifact