diff --git a/src/backend/langflow/api/endpoints.py b/src/backend/langflow/api/endpoints.py index 02a775630..021a81ca8 100644 --- a/src/backend/langflow/api/endpoints.py +++ b/src/backend/langflow/api/endpoints.py @@ -1,5 +1,5 @@ -from importlib.metadata import version import logging +from importlib.metadata import version from fastapi import APIRouter, HTTPException diff --git a/src/backend/langflow/api/validate.py b/src/backend/langflow/api/validate.py index de50896cb..0e2a7752c 100644 --- a/src/backend/langflow/api/validate.py +++ b/src/backend/langflow/api/validate.py @@ -54,4 +54,4 @@ def post_validate_node(node_id: str, data: dict): return json.dumps({"valid": True, "params": str(node._built_object_repr())}) except Exception as e: logger.exception(e) - return json.dumps({"valid": False}) + return json.dumps({"valid": False, "params": str(e)}) diff --git a/src/backend/langflow/interface/run.py b/src/backend/langflow/interface/run.py index a20587b54..ca6e0908e 100644 --- a/src/backend/langflow/interface/run.py +++ b/src/backend/langflow/interface/run.py @@ -3,12 +3,12 @@ import io from typing import Any, Dict, List, Tuple from chromadb.errors import NotEnoughElementsException # type: ignore +from langchain.schema import AgentAction from langflow.api.callback import AsyncStreamingLLMCallbackHandler, StreamingLLMCallbackHandler # type: ignore from langflow.cache.base import compute_dict_hash, load_cache, memoize_dict from langflow.graph.graph import Graph from langflow.utils.logger import logger -from langchain.schema import AgentAction def load_langchain_object(data_graph, is_first_message=False): diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 85e7810a1..71c10c539 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -1,4 +1,12 @@ -import { BugAntIcon, Cog6ToothIcon, ExclamationCircleIcon, InformationCircleIcon, TrashIcon } from "@heroicons/react/24/outline"; +import { + BugAntIcon, + CheckCircleIcon, + Cog6ToothIcon, + EllipsisHorizontalCircleIcon, + ExclamationCircleIcon, + InformationCircleIcon, + TrashIcon, +} from "@heroicons/react/24/outline"; import { classNames, nodeColors, nodeIcons, toNormalCase } from "../../utils"; import ParameterComponent from "./components/parameterComponent"; import { typesContext } from "../../contexts/typesContext"; @@ -12,11 +20,11 @@ import { TabsContext } from "../../contexts/tabsContext"; import { debounce } from "../../utils"; import Tooltip from "../../components/TooltipComponent"; export default function GenericNode({ - data, - selected, + data, + selected, }: { - data: NodeDataType; - selected: boolean; + data: NodeDataType; + selected: boolean; }) { const { setErrorData } = useContext(alertContext); const showError = useRef(true); @@ -30,32 +38,28 @@ export default function GenericNode({ const { reactFlowInstance } = useContext(typesContext); const [params, setParams] = useState([]); - useEffect(() => { - if (reactFlowInstance) { - setParams(Object.values(reactFlowInstance.toObject())); - } - }, [save]); + useEffect(() => { + if (reactFlowInstance) { + setParams(Object.values(reactFlowInstance.toObject())); + } + }, [save]); - const validateNode = useCallback( - debounce(async () => { - try { - const response = await fetch(`/validate/node/${data.id}`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(reactFlowInstance.toObject()), - }); + const validateNode = useCallback( + debounce(async () => { + try { + const response = await fetch(`/validate/node/${data.id}`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(reactFlowInstance.toObject()), + }); if (response.status === 200) { let jsonResponse = await response.json(); let jsonResponseParsed = await JSON.parse(jsonResponse); console.log(jsonResponseParsed); - if(jsonResponseParsed.valid){ - setValidationStatus(jsonResponseParsed.params); - } else { - setValidationStatus("error"); - } + setValidationStatus(jsonResponseParsed); } } catch (error) { // console.error("Error validating node:", error); @@ -70,31 +74,22 @@ export default function GenericNode({ } }, [params, validateNode]); - useEffect(() => { - if (validationStatus !== "error") { - setIsValid(true); - } else { - setIsValid(false); + if (!Icon) { + if (showError.current) { + setErrorData({ + title: data.type + ? `The ${data.type} node could not be rendered, please review your json file` + : "There was a node that can't be rendered, please review your json file", + }); + showError.current = false; } - }, [validationStatus]); - - if (!Icon) { - if (showError.current) { - setErrorData({ - title: data.type - ? `The ${data.type} node could not be rendered, please review your json file` - : "There was a node that can't be rendered, please review your json file", - }); - showError.current = false; - } - deleteNode(data.id); - return; - } + deleteNode(data.id); + return; + } return (