From 4016c2857307f4d28366b6f83815df74ebcfe60a Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 27 Oct 2023 11:43:12 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(store.py):=20add=20metadata?= =?UTF-8?q?=20to=20component=20before=20uploading=20to=20improve=20data=20?= =?UTF-8?q?integrity=20and=20analysis=20capabilities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/store.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/api/v1/store.py b/src/backend/langflow/api/v1/store.py index 16fceb6bc..8ef597573 100644 --- a/src/backend/langflow/api/v1/store.py +++ b/src/backend/langflow/api/v1/store.py @@ -66,8 +66,17 @@ def create_component( ): try: # We need to add the metadata using the Component.data - # - + # data is a dict that contains 'nodes' key. + # each node has an id like "SomeType-RANDOMSTRING" + # we need to create a metadata dict with SomeType as key + # and the value is the count this type appears in the nodes + # e.g. + # { + # "SomeType": 1 + # } + names = [node["id"].split("-")[0] for node in component.data["nodes"]] + metadata = {name: names.count(name) for name in names} + component.metadata = metadata return store_service.upload(store_api_Key, component) except Exception as exc: raise HTTPException(status_code=400, detail=str(exc))