Add TextToRecordComponent to convert text to a Record
This commit is contained in:
parent
dc8ad28418
commit
d846d806cc
1 changed files with 29 additions and 0 deletions
29
src/backend/langflow/components/utilities/TextToRecord.py
Normal file
29
src/backend/langflow/components/utilities/TextToRecord.py
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue