refactor: replace StrInput with TextInput

This commit is contained in:
ogabrielluiz 2024-06-17 12:59:58 -03:00
commit 8aa97ccd98
13 changed files with 57 additions and 62 deletions

View file

@ -7,7 +7,7 @@ from loguru import logger
from langflow.base.curl.parse import parse_context from langflow.base.curl.parse import parse_context
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import DropdownInput, IntInput, NestedDictInput, StrInput from langflow.inputs import DropdownInput, IntInput, NestedDictInput, TextInput
from langflow.schema import Data from langflow.schema import Data
from langflow.schema.dotdict import dotdict from langflow.schema.dotdict import dotdict
from langflow.template import Output from langflow.template import Output
@ -19,13 +19,13 @@ class APIRequestComponent(Component):
icon = "Globe" icon = "Globe"
inputs = [ inputs = [
StrInput( TextInput(
name="urls", name="urls",
display_name="URLs", display_name="URLs",
is_list=True, is_list=True,
info="Enter one or more URLs, separated by commas.", info="Enter one or more URLs, separated by commas.",
), ),
StrInput( TextInput(
name="curl", name="curl",
display_name="Curl", display_name="Curl",
info="Paste a curl command to populate the fields.", info="Paste a curl command to populate the fields.",

View file

@ -2,7 +2,7 @@ from typing import List, Optional
from langflow.base.data.utils import parallel_load_data, parse_text_file_to_data, retrieve_file_paths from langflow.base.data.utils import parallel_load_data, parse_text_file_to_data, retrieve_file_paths
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import StrInput, IntInput, BoolInput from langflow.inputs import TextInput, IntInput, BoolInput
from langflow.template import Output from langflow.template import Output
from langflow.schema import Data from langflow.schema import Data
@ -13,12 +13,12 @@ class DirectoryComponent(Component):
icon = "folder" icon = "folder"
inputs = [ inputs = [
StrInput( TextInput(
name="path", name="path",
display_name="Path", display_name="Path",
info="Path to the directory to load files from.", info="Path to the directory to load files from.",
), ),
StrInput( TextInput(
name="types", name="types",
display_name="Types", display_name="Types",
info="File types to load. Leave empty to load all types.", info="File types to load. Leave empty to load all types.",

View file

@ -1,12 +1,12 @@
import re
from langchain_community.document_loaders.web_base import WebBaseLoader from langchain_community.document_loaders.web_base import WebBaseLoader
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import StrInput from langflow.inputs import TextInput
from langflow.schema import Data from langflow.schema import Data
from langflow.template import Output from langflow.template import Output
import re
class URLComponent(Component): class URLComponent(Component):
display_name = "URL" display_name = "URL"
@ -14,7 +14,7 @@ class URLComponent(Component):
icon = "layout-template" icon = "layout-template"
inputs = [ inputs = [
StrInput( TextInput(
name="urls", name="urls",
display_name="URLs", display_name="URLs",
info="Enter one or more URLs, separated by commas.", info="Enter one or more URLs, separated by commas.",

View file

@ -2,7 +2,7 @@ from langchain_openai.embeddings.base import OpenAIEmbeddings
from langflow.base.models.model import LCModelComponent from langflow.base.models.model import LCModelComponent
from langflow.field_typing import Embeddings from langflow.field_typing import Embeddings
from langflow.inputs import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, SecretStrInput, StrInput from langflow.inputs import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, SecretStrInput, TextInput
from langflow.template import Output from langflow.template import Output
@ -24,8 +24,8 @@ class OpenAIEmbeddingsComponent(LCModelComponent):
info="Default query parameters to use for the API request.", info="Default query parameters to use for the API request.",
), ),
IntInput(name="chunk_size", display_name="Chunk Size", advanced=True, value=1000), IntInput(name="chunk_size", display_name="Chunk Size", advanced=True, value=1000),
StrInput(name="client", display_name="Client", advanced=True), TextInput(name="client", display_name="Client", advanced=True),
StrInput(name="deployment", display_name="Deployment", advanced=True), TextInput(name="deployment", display_name="Deployment", advanced=True),
IntInput(name="embedding_ctx_length", display_name="Embedding Context Length", advanced=True, value=1536), IntInput(name="embedding_ctx_length", display_name="Embedding Context Length", advanced=True, value=1536),
IntInput(name="max_retries", display_name="Max Retries", value=3, advanced=True), IntInput(name="max_retries", display_name="Max Retries", value=3, advanced=True),
DropdownInput( DropdownInput(
@ -43,17 +43,17 @@ class OpenAIEmbeddingsComponent(LCModelComponent):
SecretStrInput(name="openai_api_base", display_name="OpenAI API Base", advanced=True), SecretStrInput(name="openai_api_base", display_name="OpenAI API Base", advanced=True),
SecretStrInput(name="openai_api_key", display_name="OpenAI API Key"), SecretStrInput(name="openai_api_key", display_name="OpenAI API Key"),
SecretStrInput(name="openai_api_type", display_name="OpenAI API Type", advanced=True), SecretStrInput(name="openai_api_type", display_name="OpenAI API Type", advanced=True),
StrInput(name="openai_api_version", display_name="OpenAI API Version", advanced=True), TextInput(name="openai_api_version", display_name="OpenAI API Version", advanced=True),
StrInput( TextInput(
name="openai_organization", name="openai_organization",
display_name="OpenAI Organization", display_name="OpenAI Organization",
advanced=True, advanced=True,
), ),
StrInput(name="openai_proxy", display_name="OpenAI Proxy", advanced=True), TextInput(name="openai_proxy", display_name="OpenAI Proxy", advanced=True),
FloatInput(name="request_timeout", display_name="Request Timeout", advanced=True), FloatInput(name="request_timeout", display_name="Request Timeout", advanced=True),
BoolInput(name="show_progress_bar", display_name="Show Progress Bar", advanced=True), BoolInput(name="show_progress_bar", display_name="Show Progress Bar", advanced=True),
BoolInput(name="skip_empty", display_name="Skip Empty", advanced=True), BoolInput(name="skip_empty", display_name="Skip Empty", advanced=True),
StrInput( TextInput(
name="tiktoken_model_name", name="tiktoken_model_name",
display_name="TikToken Model Name", display_name="TikToken Model Name",
advanced=True, advanced=True,

View file

@ -1,20 +1,21 @@
from langflow.custom import Component from langflow.custom import Component
from langflow.field_typing import Text from langflow.field_typing import Text
from langflow.inputs import BoolInput, DropdownInput, StrInput from langflow.inputs import BoolInput, DropdownInput, TextInput
from langflow.template import Output from langflow.template import Output
class SelectivePassThroughComponent(Component): class SelectivePassThroughComponent(Component):
display_name = "Selective Pass Through" display_name = "Selective Pass Through"
description = "Passes the specified value if a specified condition is met." description = "Passes the specified value if a specified condition is met."
icon = "filter" icon = "filter"
inputs = [ inputs = [
StrInput( TextInput(
name="input_value", name="input_value",
display_name="Input Value", display_name="Input Value",
info="The primary input value to evaluate.", info="The primary input value to evaluate.",
), ),
StrInput( TextInput(
name="comparison_value", name="comparison_value",
display_name="Comparison Value", display_name="Comparison Value",
info="The value to compare against the input value.", info="The value to compare against the input value.",
@ -25,7 +26,7 @@ class SelectivePassThroughComponent(Component):
options=["equals", "not equals", "contains", "starts with", "ends with"], options=["equals", "not equals", "contains", "starts with", "ends with"],
info="Condition to evaluate the input value.", info="Condition to evaluate the input value.",
), ),
StrInput( TextInput(
name="value_to_pass", name="value_to_pass",
display_name="Value to Pass", display_name="Value to Pass",
info="The value to pass if the condition is met.", info="The value to pass if the condition is met.",

View file

@ -1,7 +1,7 @@
from typing import List from typing import List
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import IntInput, StrInput, HandleInput from langflow.inputs import HandleInput, IntInput, TextInput
from langflow.schema import Data from langflow.schema import Data
from langflow.template import Output from langflow.template import Output
from langflow.utils.util import unescape_string from langflow.utils.util import unescape_string
@ -13,45 +13,40 @@ class SplitContentComponent(Component):
icon = "split" icon = "split"
inputs = [ inputs = [
HandleInput( HandleInput(name="data", display_name="Data", info="Data with text to split.", input_types=["Data"]),
name="data", TextInput(
display_name="Data",
info="Data with text to split.",
input_types=["Data"]
),
StrInput(
name="content_key", name="content_key",
display_name="Content Key", display_name="Content Key",
info="The key to access the text content in the Data object.", info="The key to access the text content in the Data object.",
value="content", value="content",
), ),
StrInput( TextInput(
name="separator", name="separator",
display_name="Separator", display_name="Separator",
info='The character to split on. Defaults to "\n".', info='The character to split on. Defaults to "\n".',
value="\n", value="\n",
advanced=True advanced=True,
), ),
IntInput( IntInput(
name="chunk_size", name="chunk_size",
display_name="Chunk Size", display_name="Chunk Size",
info="The target length (in number of characters) of each chunk.", info="The target length (in number of characters) of each chunk.",
value=0, value=0,
advanced=True advanced=True,
), ),
IntInput( IntInput(
name="min_chunk_size", name="min_chunk_size",
display_name="Minimum Chunk Size", display_name="Minimum Chunk Size",
info="The minimum size of chunks. Smaller chunks will be merged.", info="The minimum size of chunks. Smaller chunks will be merged.",
value=0, value=0,
advanced=True advanced=True,
), ),
IntInput( IntInput(
name="max_chunk_size", name="max_chunk_size",
display_name="Maximum Chunk Size", display_name="Maximum Chunk Size",
info="The maximum size of chunks. Larger chunks will be split.", info="The maximum size of chunks. Larger chunks will be split.",
value=0, value=0,
advanced=True advanced=True,
), ),
] ]
@ -70,9 +65,9 @@ class SplitContentComponent(Component):
buffer = "" buffer = ""
for row in data: for row in data:
content = row.data.get(content_key, '') content = row.data.get(content_key, "")
if chunk_size > 0: if chunk_size > 0:
chunks = [content[i:i + chunk_size] for i in range(0, len(content), chunk_size)] chunks = [content[i : i + chunk_size] for i in range(0, len(content), chunk_size)]
else: else:
chunks = content.split(separator) chunks = content.split(separator)

View file

@ -1,6 +1,6 @@
from langflow.custom import Component from langflow.custom import Component
from langflow.field_typing import Text from langflow.field_typing import Text
from langflow.inputs import BoolInput, DropdownInput, StrInput from langflow.inputs import BoolInput, DropdownInput, TextInput
from langflow.template import Output from langflow.template import Output
@ -10,12 +10,12 @@ class TextOperatorComponent(Component):
icon = "equal" icon = "equal"
inputs = [ inputs = [
StrInput( TextInput(
name="input_text", name="input_text",
display_name="Input Text", display_name="Input Text",
info="The primary text input for the operation.", info="The primary text input for the operation.",
), ),
StrInput( TextInput(
name="match_text", name="match_text",
display_name="Match Text", display_name="Match Text",
info="The text input to compare against.", info="The text input to compare against.",
@ -33,13 +33,13 @@ class TextOperatorComponent(Component):
value=False, value=False,
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="true_output", name="true_output",
display_name="True Output", display_name="True Output",
info="The output to return or display when the comparison is true.", info="The output to return or display when the comparison is true.",
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="false_output", name="false_output",
display_name="False Output", display_name="False Output",
info="The output to return or display when the comparison is false.", info="The output to return or display when the comparison is false.",

View file

@ -1,6 +1,5 @@
from langflow.custom import Component from langflow.custom import Component
from langflow.field_typing import Text from langflow.field_typing import Text, TextInput
from langflow.inputs import StrInput
from langflow.template import Output from langflow.template import Output
@ -10,17 +9,17 @@ class CombineTextComponent(Component):
icon = "merge" icon = "merge"
inputs = [ inputs = [
StrInput( TextInput(
name="text1", name="text1",
display_name="First Text", display_name="First Text",
info="The first text input to concatenate.", info="The first text input to concatenate.",
), ),
StrInput( TextInput(
name="text2", name="text2",
display_name="Second Text", display_name="Second Text",
info="The second text input to concatenate.", info="The second text input to concatenate.",
), ),
StrInput( TextInput(
name="delimiter", name="delimiter",
display_name="Delimiter", display_name="Delimiter",
info="A string used to separate the two text inputs. Defaults to a whitespace.", info="A string used to separate the two text inputs. Defaults to a whitespace.",

View file

@ -1,6 +1,6 @@
# from langflow.field_typing import Data # from langflow.field_typing import Data
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import StrInput from langflow.inputs import TextInput
from langflow.schema import Data from langflow.schema import Data
from langflow.template import Output from langflow.template import Output
@ -12,7 +12,7 @@ class CustomComponent(Component):
icon = "custom_components" icon = "custom_components"
inputs = [ inputs = [
StrInput(name="input_value", display_name="Input Value", value="Hello, World!"), TextInput(name="input_value", display_name="Input Value", value="Hello, World!"),
] ]
outputs = [ outputs = [

View file

@ -1,7 +1,7 @@
from typing import List from typing import List
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import StrInput, HandleInput from langflow.inputs import HandleInput, TextInput
from langflow.schema import Data from langflow.schema import Data
from langflow.template import Output from langflow.template import Output
@ -18,7 +18,7 @@ class FilterDataComponent(Component):
info="Data object to filter.", info="Data object to filter.",
input_types=["Message", "Data"], input_types=["Message", "Data"],
), ),
StrInput( TextInput(
name="filter_criteria", name="filter_criteria",
display_name="Filter Criteria", display_name="Filter Criteria",
info="List of keys to filter by.", info="List of keys to filter by.",

View file

@ -1,11 +1,11 @@
from typing import List from typing import List
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs import DropdownInput, StrInput, IntInput from langflow.field_typing import Text
from langflow.template import Output from langflow.inputs import DropdownInput, IntInput, TextInput
from langflow.memory import get_messages from langflow.memory import get_messages
from langflow.schema import Data from langflow.schema import Data
from langflow.field_typing import Text from langflow.template import Output
class MemoryComponent(Component): class MemoryComponent(Component):
@ -22,7 +22,7 @@ class MemoryComponent(Component):
info="Type of sender.", info="Type of sender.",
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="sender_name", name="sender_name",
display_name="Sender Name", display_name="Sender Name",
info="Name of the sender.", info="Name of the sender.",
@ -35,7 +35,7 @@ class MemoryComponent(Component):
info="Number of messages to retrieve.", info="Number of messages to retrieve.",
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="session_id", name="session_id",
display_name="Session ID", display_name="Session ID",
info="Session ID of the chat history.", info="Session ID of the chat history.",

View file

@ -1,8 +1,8 @@
from langflow.base.io.chat import ChatComponent from langflow.base.io.chat import ChatComponent
from langflow.inputs import DropdownInput, StrInput from langflow.field_typing import Text
from langflow.inputs import DropdownInput, TextInput
from langflow.schema.message import Message from langflow.schema.message import Message
from langflow.template import Output from langflow.template import Output
from langflow.field_typing import Text
class ChatInput(ChatComponent): class ChatInput(ChatComponent):
@ -11,7 +11,7 @@ class ChatInput(ChatComponent):
icon = "ChatInput" icon = "ChatInput"
inputs = [ inputs = [
StrInput( TextInput(
name="input_value", name="input_value",
display_name="Text", display_name="Text",
multiline=True, multiline=True,
@ -27,7 +27,7 @@ class ChatInput(ChatComponent):
info="Type of sender.", info="Type of sender.",
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="sender_name", name="sender_name",
type=str, type=str,
display_name="Sender Name", display_name="Sender Name",
@ -35,7 +35,7 @@ class ChatInput(ChatComponent):
value="User", value="User",
advanced=True, advanced=True,
), ),
StrInput( TextInput(
name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True
), ),
] ]

View file

@ -1,6 +1,6 @@
from langflow.base.io.text import TextComponent from langflow.base.io.text import TextComponent
from langflow.field_typing import Text from langflow.field_typing import Text
from langflow.inputs import StrInput from langflow.inputs import TextInput
from langflow.template import Output from langflow.template import Output
@ -10,7 +10,7 @@ class TextInputComponent(TextComponent):
icon = "type" icon = "type"
inputs = [ inputs = [
StrInput( TextInput(
name="input_value", name="input_value",
display_name="Text", display_name="Text",
info="Text to be passed as input.", info="Text to be passed as input.",