Update CombineTextComponent to concatenate two text sources
This commit is contained in:
parent
87adaa4255
commit
e564991040
1 changed files with 11 additions and 8 deletions
|
|
@ -1,25 +1,28 @@
|
|||
from langflow.interface.custom.custom_component import CustomComponent
|
||||
from langflow.field_typing import Text
|
||||
|
||||
|
||||
class CombineTextComponent(CustomComponent):
|
||||
display_name = "Combine Text"
|
||||
description = "Concatenate multiple text sources into a single text chunk using a specified delimiter."
|
||||
description = "Concatenate two text sources into a single text chunk using a specified delimiter."
|
||||
icon = "merge"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"texts": {
|
||||
"display_name": "Texts",
|
||||
"info": "Multiple text inputs to concatenate.",
|
||||
"text1": {
|
||||
"display_name": "First Text",
|
||||
"info": "The first text input to concatenate.",
|
||||
},
|
||||
"text2": {
|
||||
"display_name": "Second Text",
|
||||
"info": "The second text input to concatenate.",
|
||||
},
|
||||
"delimiter": {
|
||||
"display_name": "Delimiter",
|
||||
"info": "A string used to separate each text input. Defaults to a whitespace.",
|
||||
"info": "A string used to separate the two text inputs. Defaults to a whitespace.",
|
||||
},
|
||||
}
|
||||
|
||||
def build(self, texts: list[str], delimiter: str = " ") -> Text:
|
||||
combined = delimiter.join(texts)
|
||||
def build(self, text1: str, text2: str, delimiter: str = " ") -> Text:
|
||||
combined = delimiter.join([text1, text2])
|
||||
self.status = combined
|
||||
return combined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue