From 99bc9f01ba2b19170f76e12618e74d3bf5f27a94 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 7 Jul 2023 01:34:37 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(custom.py):=20evaluate=20ite?= =?UTF-8?q?ms=20in=20split=5Fitem=20list=20using=20ast.literal=5Feval=20to?= =?UTF-8?q?=20handle=20cases=20where=20items=20are=20not=20strings=20The?= =?UTF-8?q?=20code=20now=20uses=20ast.literal=5Feval=20to=20evaluate=20eac?= =?UTF-8?q?h=20item=20in=20the=20split=5Fitem=20list.=20This=20is=20done?= =?UTF-8?q?=20to=20handle=20cases=20where=20the=20items=20are=20not=20stri?= =?UTF-8?q?ngs=20and=20cannot=20be=20directly=20converted=20to=20their=20r?= =?UTF-8?q?espective=20types.=20This=20ensures=20that=20the=20output=5Flis?= =?UTF-8?q?t=20contains=20correctly=20evaluated=20items.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/custom/custom.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/langflow/interface/custom/custom.py b/src/backend/langflow/interface/custom/custom.py index 8985945a9..05d9b732a 100644 --- a/src/backend/langflow/interface/custom/custom.py +++ b/src/backend/langflow/interface/custom/custom.py @@ -88,6 +88,14 @@ class CustomComponent(BaseModel): # If there isn't a type, append None else: split_item.append(None) + for i in range(len(split_item)): + try: + # Try to evaluate the item + split_item[i] = ast.literal_eval(split_item[i]) + except ValueError: + # If it fails, just pass + pass + output_list.append(split_item) return output_list