fix: change color of output inspector when tool mode, change fuzzy search order, fix image download and some minor issues (#4625)
* Fixed output and input radius and icons colors when on tool mode * Replaced output format to be camel case * Fix expand not appearing after minimize and change code * Refactor chatView component and add FlowRunningSqueleton - Refactor chatView component to import useMemo from react - Add FlowRunningSqueleton component to display flow running indicator - fix gagging on flow running * format code * Fixed fuzzy search order * remove console log --------- Co-authored-by: anovazzi1 <otavio2204@gmail.com> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
This commit is contained in:
parent
88c059677e
commit
2881346400
13 changed files with 90 additions and 49 deletions
|
|
@ -25,8 +25,8 @@ class URLComponent(Component):
|
||||||
),
|
),
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="format",
|
name="format",
|
||||||
display_name="Output format",
|
display_name="Output Format",
|
||||||
info="Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
info="Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
||||||
options=["Text", "Raw HTML"],
|
options=["Text", "Raw HTML"],
|
||||||
value="Text",
|
value="Text",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -178,15 +178,15 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output format\",\n info=\"Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
||||||
},
|
},
|
||||||
"format": {
|
"format": {
|
||||||
"_input_type": "DropdownInput",
|
"_input_type": "DropdownInput",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"combobox": false,
|
"combobox": false,
|
||||||
"display_name": "Output format",
|
"display_name": "Output Format",
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
"info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
||||||
"name": "format",
|
"name": "format",
|
||||||
"options": ["Text", "Raw HTML"],
|
"options": ["Text", "Raw HTML"],
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
|
|
|
||||||
|
|
@ -1507,15 +1507,15 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output format\",\n info=\"Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
||||||
},
|
},
|
||||||
"format": {
|
"format": {
|
||||||
"_input_type": "DropdownInput",
|
"_input_type": "DropdownInput",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"combobox": false,
|
"combobox": false,
|
||||||
"display_name": "Output format",
|
"display_name": "Output Format",
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
"info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
||||||
"name": "format",
|
"name": "format",
|
||||||
"options": ["Text", "Raw HTML"],
|
"options": ["Text", "Raw HTML"],
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
|
|
@ -1627,15 +1627,15 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output format\",\n info=\"Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
||||||
},
|
},
|
||||||
"format": {
|
"format": {
|
||||||
"_input_type": "DropdownInput",
|
"_input_type": "DropdownInput",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"combobox": false,
|
"combobox": false,
|
||||||
"display_name": "Output format",
|
"display_name": "Output Format",
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
"info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
||||||
"name": "format",
|
"name": "format",
|
||||||
"options": ["Text", "Raw HTML"],
|
"options": ["Text", "Raw HTML"],
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
|
|
@ -1751,15 +1751,15 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output format\",\n info=\"Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
"value": "import re\n\nfrom langchain_community.document_loaders import AsyncHtmlLoader, WebBaseLoader\n\nfrom langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass URLComponent(Component):\n display_name = \"URL\"\n description = \"Fetch content from one or more URLs.\"\n icon = \"layout-template\"\n name = \"URL\"\n\n inputs = [\n MessageTextInput(\n name=\"urls\",\n display_name=\"URLs\",\n info=\"Enter one or more URLs, by clicking the '+' button.\",\n is_list=True,\n tool_mode=True,\n ),\n DropdownInput(\n name=\"format\",\n display_name=\"Output Format\",\n info=\"Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.\",\n options=[\"Text\", \"Raw HTML\"],\n value=\"Text\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"fetch_content\"),\n Output(display_name=\"Text\", name=\"text\", method=\"fetch_content_text\"),\n ]\n\n def ensure_url(self, string: str) -> str:\n \"\"\"Ensures the given string is a URL by adding 'http://' if it doesn't start with 'http://' or 'https://'.\n\n Raises an error if the string is not a valid URL.\n\n Parameters:\n string (str): The string to be checked and possibly modified.\n\n Returns:\n str: The modified string that is ensured to be a URL.\n\n Raises:\n ValueError: If the string is not a valid URL.\n \"\"\"\n if not string.startswith((\"http://\", \"https://\")):\n string = \"http://\" + string\n\n # Basic URL validation regex\n url_regex = re.compile(\n r\"^(https?:\\/\\/)?\" # optional protocol\n r\"(www\\.)?\" # optional www\n r\"([a-zA-Z0-9.-]+)\" # domain\n r\"(\\.[a-zA-Z]{2,})?\" # top-level domain\n r\"(:\\d+)?\" # optional port\n r\"(\\/[^\\s]*)?$\", # optional path\n re.IGNORECASE,\n )\n\n if not url_regex.match(string):\n msg = f\"Invalid URL: {string}\"\n raise ValueError(msg)\n\n return string\n\n def fetch_content(self) -> list[Data]:\n urls = [self.ensure_url(url.strip()) for url in self.urls if url.strip()]\n if self.format == \"Raw HTML\":\n loader = AsyncHtmlLoader(web_path=urls, encoding=\"utf-8\")\n else:\n loader = WebBaseLoader(web_paths=urls, encoding=\"utf-8\")\n docs = loader.load()\n data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]\n self.status = data\n return data\n\n def fetch_content_text(self) -> Message:\n data = self.fetch_content()\n\n result_string = data_to_text(\"{text}\", data)\n self.status = result_string\n return Message(text=result_string)\n"
|
||||||
},
|
},
|
||||||
"format": {
|
"format": {
|
||||||
"_input_type": "DropdownInput",
|
"_input_type": "DropdownInput",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"combobox": false,
|
"combobox": false,
|
||||||
"display_name": "Output format",
|
"display_name": "Output Format",
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Output format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
"info": "Output Format. Use 'Text' to extract the text from the HTML or 'Raw HTML' for the raw HTML content.",
|
||||||
"name": "format",
|
"name": "format",
|
||||||
"options": ["Text", "Raw HTML"],
|
"options": ["Text", "Raw HTML"],
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -34,6 +34,7 @@ export default function NodeInputField({
|
||||||
name = "",
|
name = "",
|
||||||
required = false,
|
required = false,
|
||||||
optionalHandle = null,
|
optionalHandle = null,
|
||||||
|
lastInput = false,
|
||||||
info = "",
|
info = "",
|
||||||
proxy,
|
proxy,
|
||||||
showNode,
|
showNode,
|
||||||
|
|
@ -108,6 +109,7 @@ export default function NodeInputField({
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative mt-1 flex min-h-10 w-full flex-wrap items-center justify-between px-5 py-2",
|
"relative mt-1 flex min-h-10 w-full flex-wrap items-center justify-between px-5 py-2",
|
||||||
|
lastInput ? "rounded-b-[0.69rem]" : "",
|
||||||
isToolMode && "bg-primary/10",
|
isToolMode && "bg-primary/10",
|
||||||
(name === "code" && type === "code") || (name.includes("code") && proxy)
|
(name === "code" && type === "code") || (name.includes("code") && proxy)
|
||||||
? "hidden"
|
? "hidden"
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ export default function NodeOutputField({
|
||||||
"relative mt-1 flex h-11 w-full flex-wrap items-center justify-between bg-muted px-5 py-2",
|
"relative mt-1 flex h-11 w-full flex-wrap items-center justify-between bg-muted px-5 py-2",
|
||||||
lastOutput ? "rounded-b-[0.69rem]" : "",
|
lastOutput ? "rounded-b-[0.69rem]" : "",
|
||||||
isToolMode && "bg-primary",
|
isToolMode && "bg-primary",
|
||||||
outputName === "component_as_tool" && "border-l-2 border-primary pl-2",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
|
|
@ -158,8 +157,12 @@ export default function NodeOutputField({
|
||||||
className={cn(
|
className={cn(
|
||||||
"icon-size",
|
"icon-size",
|
||||||
disabledOutput
|
disabledOutput
|
||||||
? "text-placeholder-foreground opacity-60"
|
? isToolMode
|
||||||
: "text-placeholder-foreground hover:text-foreground",
|
? "text-placeholder-foreground opacity-60"
|
||||||
|
: "text-placeholder-foreground hover:text-foreground"
|
||||||
|
: isToolMode
|
||||||
|
? "text-background hover:text-secondary-hover"
|
||||||
|
: "text-placeholder-foreground hover:text-primary-hover",
|
||||||
)}
|
)}
|
||||||
strokeWidth={ICON_STROKE_WIDTH}
|
strokeWidth={ICON_STROKE_WIDTH}
|
||||||
name={data.node?.outputs![index].hidden ? "EyeOff" : "Eye"}
|
name={data.node?.outputs![index].hidden ? "EyeOff" : "Eye"}
|
||||||
|
|
@ -215,9 +218,13 @@ export default function NodeOutputField({
|
||||||
<IconComponent
|
<IconComponent
|
||||||
className={cn(
|
className={cn(
|
||||||
"icon-size",
|
"icon-size",
|
||||||
displayOutputPreview && !unknownOutput
|
isToolMode
|
||||||
? "text-foreground hover:text-primary-hover"
|
? displayOutputPreview && !unknownOutput
|
||||||
: "cursor-not-allowed text-placeholder-foreground opacity-60",
|
? "text-background hover:text-secondary-hover"
|
||||||
|
: "cursor-not-allowed text-placeholder-foreground opacity-80"
|
||||||
|
: displayOutputPreview && !unknownOutput
|
||||||
|
? "text-foreground hover:text-primary-hover"
|
||||||
|
: "cursor-not-allowed text-placeholder-foreground opacity-60",
|
||||||
errorOutput ? "text-destructive" : "",
|
errorOutput ? "text-destructive" : "",
|
||||||
)}
|
)}
|
||||||
name={"ScanEye"}
|
name={"ScanEye"}
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,13 @@ export default function GenericNode({
|
||||||
data.node!.template[templateField]?.show &&
|
data.node!.template[templateField]?.show &&
|
||||||
!data.node!.template[templateField]?.advanced && (
|
!data.node!.template[templateField]?.advanced && (
|
||||||
<NodeInputField
|
<NodeInputField
|
||||||
|
lastInput={
|
||||||
|
idx ===
|
||||||
|
Object.keys(data.node!.template).filter(
|
||||||
|
(templateField) => templateField.charAt(0) !== "_",
|
||||||
|
).length -
|
||||||
|
1 && !(shownOutputs.length > 0 || showHiddenOutputs)
|
||||||
|
}
|
||||||
key={scapedJSONStringfy({
|
key={scapedJSONStringfy({
|
||||||
inputTypes: data.node!.template[templateField].input_types,
|
inputTypes: data.node!.template[templateField].input_types,
|
||||||
type: data.node!.template[templateField].type,
|
type: data.node!.template[templateField].type,
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,12 @@ import { TextShimmer } from "@/components/ui/TextShimmer";
|
||||||
import { ENABLE_NEW_LOGO } from "@/customization/feature-flags";
|
import { ENABLE_NEW_LOGO } from "@/customization/feature-flags";
|
||||||
import { track } from "@/customization/utils/analytics";
|
import { track } from "@/customization/utils/analytics";
|
||||||
import { useMessagesStore } from "@/stores/messagesStore";
|
import { useMessagesStore } from "@/stores/messagesStore";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
||||||
import useFlowStore from "../../../../stores/flowStore";
|
import useFlowStore from "../../../../stores/flowStore";
|
||||||
import { ChatMessageType } from "../../../../types/chat";
|
import { ChatMessageType } from "../../../../types/chat";
|
||||||
import { chatViewProps } from "../../../../types/components";
|
import { chatViewProps } from "../../../../types/components";
|
||||||
|
import FlowRunningSqueleton from "../flowRunningSqueleton";
|
||||||
import useDragAndDrop from "./chatInput/hooks/use-drag-and-drop";
|
import useDragAndDrop from "./chatInput/hooks/use-drag-and-drop";
|
||||||
import { useFileHandler } from "./chatInput/hooks/use-file-handler";
|
import { useFileHandler } from "./chatInput/hooks/use-file-handler";
|
||||||
import ChatInput from "./chatInput/newChatInput";
|
import ChatInput from "./chatInput/newChatInput";
|
||||||
|
|
@ -123,6 +124,8 @@ export default function ChatView({
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const flowRunningSkeletonMemo = useMemo(() => <FlowRunningSqueleton />, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex h-full w-full flex-col rounded-md"
|
className="flex h-full w-full flex-col rounded-md"
|
||||||
|
|
@ -179,18 +182,8 @@ export default function ChatView({
|
||||||
>
|
>
|
||||||
{lockChat &&
|
{lockChat &&
|
||||||
chatHistory.length > 0 &&
|
chatHistory.length > 0 &&
|
||||||
!(chatHistory[chatHistory.length - 1]?.category === "error") && (
|
!(chatHistory[chatHistory.length - 1]?.category === "error") &&
|
||||||
<div className="flex w-full gap-4 rounded-md p-2">
|
flowRunningSkeletonMemo}
|
||||||
<LogoIcon />
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div>
|
|
||||||
<TextShimmer className="" duration={1}>
|
|
||||||
Flow running...
|
|
||||||
</TextShimmer>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="m-auto w-5/6 max-w-[768px]">
|
<div className="m-auto w-5/6 max-w-[768px]">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { TextShimmer } from "@/components/ui/TextShimmer";
|
||||||
|
import LogoIcon from "../chatView/chatMessage/components/chatLogoIcon";
|
||||||
|
|
||||||
|
export default function FlowRunningSqueleton() {
|
||||||
|
return (
|
||||||
|
<div className="flex w-full gap-4 rounded-md p-2">
|
||||||
|
<LogoIcon />
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div>
|
||||||
|
<TextShimmer className="" duration={1}>
|
||||||
|
Flow running...
|
||||||
|
</TextShimmer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import ShadTooltip from "@/components/shadTooltipComponent";
|
import ShadTooltip from "@/components/shadTooltipComponent";
|
||||||
import { removeCountFromString } from "@/utils/utils";
|
import { removeCountFromString } from "@/utils/utils";
|
||||||
import React from "react";
|
|
||||||
import SidebarDraggableComponent from "../sidebarDraggableComponent";
|
import SidebarDraggableComponent from "../sidebarDraggableComponent";
|
||||||
|
|
||||||
const SidebarItemsList = ({
|
const SidebarItemsList = ({
|
||||||
|
|
@ -14,12 +13,13 @@ const SidebarItemsList = ({
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-1 py-2">
|
<div className="flex flex-col gap-1 py-2">
|
||||||
{Object.keys(dataFilter[item.name])
|
{Object.keys(dataFilter[item.name])
|
||||||
.sort((a, b) =>
|
.sort((a, b) => {
|
||||||
sensitiveSort(
|
const itemA = dataFilter[item.name][a];
|
||||||
dataFilter[item.name][a].display_name,
|
const itemB = dataFilter[item.name][b];
|
||||||
dataFilter[item.name][b].display_name,
|
return itemA.score && itemB.score
|
||||||
),
|
? itemA.score - itemB.score
|
||||||
)
|
: sensitiveSort(itemA.display_name, itemB.display_name);
|
||||||
|
})
|
||||||
.map((SBItemName, idx) => {
|
.map((SBItemName, idx) => {
|
||||||
const currentItem = dataFilter[item.name][SBItemName];
|
const currentItem = dataFilter[item.name][SBItemName];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ export function FlowSidebarComponent() {
|
||||||
const options = {
|
const options = {
|
||||||
keys: ["display_name", "description", "type", "category"],
|
keys: ["display_name", "description", "type", "category"],
|
||||||
threshold: 0.2,
|
threshold: 0.2,
|
||||||
|
includeScore: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fuseData = Object.entries(data).flatMap(([category, items]) =>
|
const fuseData = Object.entries(data).flatMap(([category, items]) =>
|
||||||
|
|
@ -169,8 +170,14 @@ export function FlowSidebarComponent() {
|
||||||
let combinedResults = {};
|
let combinedResults = {};
|
||||||
|
|
||||||
if (fuse) {
|
if (fuse) {
|
||||||
const fuseResults = fuse.search(search);
|
const fuseResults = fuse.search(search).map((result) => ({
|
||||||
setSortedCategories(fuseResults.map((result) => result.item.category));
|
...result,
|
||||||
|
item: { ...result.item, score: result.score },
|
||||||
|
}));
|
||||||
|
const fuseCategories = fuseResults.map(
|
||||||
|
(result) => result.item.category,
|
||||||
|
);
|
||||||
|
setSortedCategories(fuseCategories);
|
||||||
combinedResults = combinedResultsFn(fuseResults, data);
|
combinedResults = combinedResultsFn(fuseResults, data);
|
||||||
|
|
||||||
const traditionalResults = traditionalSearchMetadata(data, searchTerm);
|
const traditionalResults = traditionalSearchMetadata(data, searchTerm);
|
||||||
|
|
@ -182,9 +189,16 @@ export function FlowSidebarComponent() {
|
||||||
);
|
);
|
||||||
|
|
||||||
setSortedCategories(
|
setSortedCategories(
|
||||||
Object.keys(filteredData).filter(
|
Object.keys(filteredData)
|
||||||
(category) => Object.keys(filteredData[category]).length > 0,
|
.filter(
|
||||||
),
|
(category) => Object.keys(filteredData[category]).length > 0,
|
||||||
|
)
|
||||||
|
.toSorted(
|
||||||
|
(a, b) =>
|
||||||
|
fuseCategories.findIndex((value) => value === a) ??
|
||||||
|
0 - fuseCategories.findIndex((value) => value === b) ??
|
||||||
|
0,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ export default function NodeToolbarComponent({
|
||||||
updateNodeInternals(data.id);
|
updateNodeInternals(data.id);
|
||||||
}
|
}
|
||||||
function minimize() {
|
function minimize() {
|
||||||
if (isMinimal) {
|
if (isMinimal || !showNode) {
|
||||||
setShowNode((data.showNode ?? true) ? false : true);
|
setShowNode((data.showNode ?? true) ? false : true);
|
||||||
updateNodeInternals(data.id);
|
updateNodeInternals(data.id);
|
||||||
return;
|
return;
|
||||||
|
|
@ -661,7 +661,7 @@ export default function NodeToolbarComponent({
|
||||||
dataTestId="docs-button-modal"
|
dataTestId="docs-button-modal"
|
||||||
/>
|
/>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
{isMinimal && (
|
{(isMinimal || !showNode) && (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
value={"show"}
|
value={"show"}
|
||||||
data-testid={`${showNode ? "minimize" : "expand"}-button-modal`}
|
data-testid={`${showNode ? "minimize" : "expand"}-button-modal`}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ export type NodeInputFieldComponentType = {
|
||||||
name: string;
|
name: string;
|
||||||
required: boolean;
|
required: boolean;
|
||||||
optionalHandle: Array<String> | undefined | null;
|
optionalHandle: Array<String> | undefined | null;
|
||||||
|
lastInput?: boolean;
|
||||||
info: string;
|
info: string;
|
||||||
proxy: { field: string; id: string } | undefined;
|
proxy: { field: string; id: string } | undefined;
|
||||||
showNode: boolean;
|
showNode: boolean;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue