From 603bca019ceaae807bc87185d54ef9af5c35320c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 29 Feb 2024 23:09:42 -0300 Subject: [PATCH] Refactor ShouldRunNext component to handle boolean response properly --- src/backend/langflow/components/utilities/ShouldRunNext.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/components/utilities/ShouldRunNext.py b/src/backend/langflow/components/utilities/ShouldRunNext.py index b9ae3b048..995f1cb43 100644 --- a/src/backend/langflow/components/utilities/ShouldRunNext.py +++ b/src/backend/langflow/components/utilities/ShouldRunNext.py @@ -1,5 +1,6 @@ # Implement ShouldRunNext component from typing import Text + from langchain_core.prompts import PromptTemplate from langflow import CustomComponent @@ -42,8 +43,10 @@ class ShouldRunNext(CustomComponent): result = result.get("response") if result.lower() not in ["true", "false"]: - raise ValueError("The prompt should generate a boolean response (True or False).") + raise ValueError( + "The prompt should generate a boolean response (True or False)." + ) # The string should be the words true or false # if not raise an error bool_result = result.lower() == "true" - return {"condition": bool_result, "result": kwargs} + return {"path": bool_result, "result": kwargs}