PromptComponent now handles Record inputs

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-19 16:28:32 -03:00
commit d413b2b6fc

View file

@ -1,6 +1,7 @@
from langchain_core.prompts import PromptTemplate
from langflow import CustomComponent
from langflow.field_typing import Prompt, TemplateField, Text
from langflow.schema import Record
class PromptComponent(CustomComponent):
@ -20,6 +21,10 @@ class PromptComponent(CustomComponent):
**kwargs,
) -> Text:
prompt_template = PromptTemplate.from_template(template)
for key, value in kwargs.copy().items():
if isinstance(value, Record):
kwargs[key] = value.text
try:
formated_prompt = prompt_template.format(**kwargs)
except Exception as exc: