From d846d806ccd6c904927967afcc92f2c53e04fe5f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 2 Mar 2024 01:18:43 -0300 Subject: [PATCH] Add TextToRecordComponent to convert text to a Record --- .../components/utilities/TextToRecord.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/backend/langflow/components/utilities/TextToRecord.py diff --git a/src/backend/langflow/components/utilities/TextToRecord.py b/src/backend/langflow/components/utilities/TextToRecord.py new file mode 100644 index 000000000..e176e15f5 --- /dev/null +++ b/src/backend/langflow/components/utilities/TextToRecord.py @@ -0,0 +1,29 @@ +from typing import Optional + +from langflow import CustomComponent +from langflow.field_typing import Text +from langflow.schema import Record + + +class TextToRecordComponent(CustomComponent): + display_name = "Text to Record" + description = "Converts text to a Record." + + def build_config(self): + return { + "text": { + "display_name": "Text", + "info": "The text to convert to a record.", + }, + "data": { + "display_name": "Data", + "info": "The optional data to include in the record.", + }, + } + + def build( + self, + text: Text, + data: Optional[dict] = {}, + ) -> Record: + return Record(text=text, data=data)