fix: templates were not being processed correctly

This commit is contained in:
Gabriel Almeida 2023-04-08 08:55:46 -03:00 committed by Gabriel Luiz Freitas Almeida
commit 46b2409526
3 changed files with 11 additions and 3 deletions

View file

@ -12,6 +12,7 @@ from langflow.graph.utils import load_file
from langflow.interface import loading
from langflow.interface.listing import ALL_TYPES_DICT
from langflow.utils.logger import logger
import warnings
class Node:
@ -119,7 +120,13 @@ class Node:
params[key] = edges[0].source
elif value["required"] or value.get("value"):
params[key] = value["value"]
# If value does not have value this still passes
# but then gives a keyError
# so we need to check if value has value
new_value = value.get("value")
if new_value is None:
warnings.warn(f"Value for {key} in {self.node_type} is None. ")
params[key] = new_value
# Add _type to params
self.params = params

View file

@ -1 +1 @@
DIRECT_TYPES = ["str", "bool", "code", "int", "float", "Any"]
DIRECT_TYPES = ["str", "bool", "code", "int", "float", "Any", "prompt"]

View file

@ -75,7 +75,8 @@ class PromptNode(Node):
for param in prompt_params:
prompt_text = self.params[param]
variables = extract_input_variables_from_prompt(prompt_text)
if self.params["input_variables"] is None:
self.params["input_variables"] = []
self.params["input_variables"].extend(variables)
self.params["input_variables"] = list(set(self.params["input_variables"]))