From fe1ce49203da0a8fd40d73d524e43fdcf6762871 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 13:09:15 -0300 Subject: [PATCH 1/9] fix: deactivate replace_port --- src/backend/langflow/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index cf2a2f8a0..9d57dc9fd 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -74,7 +74,7 @@ def serve( } # Replace the port in index.html - replace_port(static_files_dir, host, port) + # replace_port(static_files_dir, host, port) if platform.system() in ["Darwin", "Windows"]: # Run using uvicorn on MacOS and Windows From 51ec2a0fe040a46a83ef4193d26808b34594edc7 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 13:12:48 -0300 Subject: [PATCH 2/9] fix: removing replace_port function --- src/backend/langflow/__main__.py | 39 -------------------------------- 1 file changed, 39 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 9d57dc9fd..6f848dca6 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -18,42 +18,6 @@ def get_number_of_workers(workers=None): return workers -def replace_port(static_files_dir, host, port): - # Load index.html from frontend directory - # In it there is a script tag that sets the base url - # like so setItem("port", "http://localhost:7860") - # localhost could be anything so we need to verify for string - # we need to set the base url to the port that the server is running on - # so that the frontend can make requests to the backend - # This is a hacky way to do it, but it works - - # Check if the host is http or https - logger.info(f"host: {host}") - logger.info(f"port: {port}") - url = f"{host}:{port}" if "http" in host else f"http://{host}:{port}" - logger.info(f"url: {url}") - new_string = f'setItem("port","{url}")' - - with open(static_files_dir / "index.html", "r") as f: - index_html = f.read() - # using regex to replace the port - index_html = re.sub( - r"setItem\(\"port\",.*\)", - new_string, - index_html, - ) - with open(static_files_dir / "index.html", "w") as f: - f.write(index_html) - # Verify that the port was replaced - with open(static_files_dir / "index.html", "r") as f: - index_html = f.read() - if new_string not in index_html: - raise ValueError( - "The port was not replaced in index.html. " - "Please check the regex in main.py" - ) - - def serve( host: str = "127.0.0.1", workers: int = 1, timeout: int = 60, port: int = 7860 ): @@ -73,9 +37,6 @@ def serve( "timeout": timeout, } - # Replace the port in index.html - # replace_port(static_files_dir, host, port) - if platform.system() in ["Darwin", "Windows"]: # Run using uvicorn on MacOS and Windows # Windows doesn't support gunicorn From f5486823c1b61ded3257c7f5ae0394142009332e Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 13:13:12 -0300 Subject: [PATCH 3/9] bump version to 0.0.45 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 239ab37a5..615caf12d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.0.44" +version = "0.0.45" description = "A Python package with a built-in web application" authors = ["Logspace "] packages = [ From c390a4750494699ac844d284639abb531030182d Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 20:54:05 -0300 Subject: [PATCH 4/9] feat: added constants file to support model types and others --- src/backend/langflow/utils/constants.py | 8 ++++++++ src/backend/langflow/utils/util.py | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/backend/langflow/utils/constants.py diff --git a/src/backend/langflow/utils/constants.py b/src/backend/langflow/utils/constants.py new file mode 100644 index 000000000..73a50ce40 --- /dev/null +++ b/src/backend/langflow/utils/constants.py @@ -0,0 +1,8 @@ +OPENAI_MODELS = [ + "text-davinci-003", + "text-davinci-002", + "text-curie-001", + "text-babbage-001", + "text-ada-001", +] +CHAT_OPENAI_MODELS = ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k"] diff --git a/src/backend/langflow/utils/util.py b/src/backend/langflow/utils/util.py index 5d13e931d..18fdf658d 100644 --- a/src/backend/langflow/utils/util.py +++ b/src/backend/langflow/utils/util.py @@ -11,6 +11,8 @@ from langchain.agents.load_tools import ( ) from typing import Optional, Dict +from backend.langflow.utils.constants import CHAT_OPENAI_MODELS, OPENAI_MODELS + def build_template_from_function(name: str, type_to_loader_dict: Dict): classes = [ @@ -296,9 +298,9 @@ def format_dict(d, name: Optional[str] = None): # Add options to openai if name == "OpenAI" and key == "model_name": - value["options"] = ["text-davinci-003", "text-davinci-002"] + value["options"] = OPENAI_MODELS elif name == "OpenAIChat" and key == "model_name": - value["options"] = ["gpt-3.5-turbo", "gpt-4"] + value["options"] = CHAT_OPENAI_MODELS return d From 049ab2b39beabbd4adff9a4719f685ea3712d426 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 20:56:15 -0300 Subject: [PATCH 5/9] fix: changed import and linting --- src/backend/langflow/__main__.py | 1 - src/backend/langflow/utils/util.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 6f848dca6..3da26667d 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -1,6 +1,5 @@ import multiprocessing import platform -import re from langflow.main import create_app diff --git a/src/backend/langflow/utils/util.py b/src/backend/langflow/utils/util.py index 18fdf658d..dae450f0c 100644 --- a/src/backend/langflow/utils/util.py +++ b/src/backend/langflow/utils/util.py @@ -11,7 +11,7 @@ from langchain.agents.load_tools import ( ) from typing import Optional, Dict -from backend.langflow.utils.constants import CHAT_OPENAI_MODELS, OPENAI_MODELS +from langflow.utils import constants def build_template_from_function(name: str, type_to_loader_dict: Dict): @@ -298,9 +298,9 @@ def format_dict(d, name: Optional[str] = None): # Add options to openai if name == "OpenAI" and key == "model_name": - value["options"] = OPENAI_MODELS + value["options"] = constants.OPENAI_MODELS elif name == "OpenAIChat" and key == "model_name": - value["options"] = CHAT_OPENAI_MODELS + value["options"] = constants.CHAT_OPENAI_MODELS return d From 08d8fffb8fea9ad2a0a1274c4a3eaa92eb15aba8 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 20 Mar 2023 21:08:57 -0300 Subject: [PATCH 6/9] fix: adding maintainers and other configs --- pyproject.toml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 615caf12d..8f4395abe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,12 +3,19 @@ name = "langflow" version = "0.0.45" description = "A Python package with a built-in web application" authors = ["Logspace "] -packages = [ - { include = "langflow", from = "src/backend" }, +maintainers = [ + "Gabriel Almeida ", + "Ibis Prevedello ", + "Lucas Eduoli ", + "Otávio Anovazzi ", ] -include = ["src/backend/langflow/*", "src/backend/langflow/**/*"] +repository = "https://github.com/logspace-ai/langflow" license = "MIT" readme = "README.md" +keywords = ["nlp", "langchain", "openai", "gpt", "gui"] +packages = [{ include = "langflow", from = "src/backend" }] +include = ["src/backend/langflow/*", "src/backend/langflow/**/*"] + [tool.poetry.scripts] langflow = "langflow.__main__:main" From c8ef7ba54564409535d26c725e84de050ca6bf2c Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 21 Mar 2023 17:05:12 -0300 Subject: [PATCH 7/9] some ui updates --- src/frontend/public/index.html | 3 --- src/frontend/src/contexts/tabsContext.tsx | 2 +- .../pages/FlowPage/components/tabsManagerComponent/index.tsx | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/frontend/public/index.html b/src/frontend/public/index.html index 1aa066669..57757fb21 100644 --- a/src/frontend/public/index.html +++ b/src/frontend/public/index.html @@ -5,9 +5,6 @@ LangFLow - diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 3f6cbbf0b..1bab447b8 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -131,7 +131,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { // Create a new flow with a default name if no flow is provided. let newFlow: FlowType = { - name: flow ? flow.name : "New Flow " + (flows.length===0?"":flows.length), + name: "New Flow", id: id.toString(), data, chat: flow ? flow.chat : [], diff --git a/src/frontend/src/pages/FlowPage/components/tabsManagerComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/tabsManagerComponent/index.tsx index 6396b753f..79240f720 100644 --- a/src/frontend/src/pages/FlowPage/components/tabsManagerComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/tabsManagerComponent/index.tsx @@ -50,10 +50,10 @@ export default function TabsManagerComponent() { flow={null} />
- - ))} - +
- +
- + {children}