Refactor ShouldRunNext component to handle boolean response properly
This commit is contained in:
parent
803d51ac25
commit
603bca019c
1 changed files with 5 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
# Implement ShouldRunNext component
|
# Implement ShouldRunNext component
|
||||||
from typing import Text
|
from typing import Text
|
||||||
|
|
||||||
from langchain_core.prompts import PromptTemplate
|
from langchain_core.prompts import PromptTemplate
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
|
|
@ -42,8 +43,10 @@ class ShouldRunNext(CustomComponent):
|
||||||
result = result.get("response")
|
result = result.get("response")
|
||||||
|
|
||||||
if result.lower() not in ["true", "false"]:
|
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
|
# The string should be the words true or false
|
||||||
# if not raise an error
|
# if not raise an error
|
||||||
bool_result = result.lower() == "true"
|
bool_result = result.lower() == "true"
|
||||||
return {"condition": bool_result, "result": kwargs}
|
return {"path": bool_result, "result": kwargs}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue