38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from langflow.custom import Component
|
|
from langflow.field_typing import Text
|
|
from langflow.inputs import StrInput
|
|
from langflow.template import Output
|
|
|
|
|
|
class CombineTextComponent(Component):
|
|
display_name = "Combine Text"
|
|
description = "Concatenate two text sources into a single text chunk using a specified delimiter."
|
|
icon = "merge"
|
|
|
|
inputs = [
|
|
StrInput(
|
|
name="text1",
|
|
display_name="First Text",
|
|
info="The first text input to concatenate.",
|
|
),
|
|
StrInput(
|
|
name="text2",
|
|
display_name="Second Text",
|
|
info="The second text input to concatenate.",
|
|
),
|
|
StrInput(
|
|
name="delimiter",
|
|
display_name="Delimiter",
|
|
info="A string used to separate the two text inputs. Defaults to a whitespace.",
|
|
default=" ",
|
|
),
|
|
]
|
|
|
|
outputs = [
|
|
Output(display_name="Combined Text", name="combined_text", method="combine_texts"),
|
|
]
|
|
|
|
def combine_texts(self) -> Text:
|
|
combined = self.delimiter.join([self.text1, self.text2])
|
|
self.status = combined
|
|
return combined
|