🐛 (loading.py): Fix bug where custom component outputs and results were not properly assigned

🐛 (base.py): Fix issue where outputs were not initialized causing potential errors
This commit is contained in:
ogabrielluiz 2024-06-18 21:25:04 -03:00
commit 01027cb7a3
2 changed files with 4 additions and 2 deletions

View file

@ -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", "")

View file

@ -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