From 29a1af74e51b431abbb33655f58ed6ad24d12dd7 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Fri, 17 Mar 2023 13:22:28 -0300 Subject: [PATCH 01/31] fix: added instructions for import/export --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 56b01a1a0..83da79a33 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,18 @@ Creating flows with LangFlow is easy. Simply drag sidebar components onto the ca Explore by editing prompt parameters, link chains and agents, track an agent's thought process, and export your flow. +Once you're done, you can export your flow as a JSON file to use with LangChain. +To do so, click the "Export" button in the top right corner of the canvas, then +in Python, you can load the flow with: + +```python +from langflow import load_flow_from_json + +flow = load_flow_from_json("path/to/flow.json") +# Now you can use it like any chain +flow("Hey, have you heard of LangFlow?") +``` + ## 👋 Contributing From 154522388323d52a622d3c9a28933bc91cf10147 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Sat, 18 Mar 2023 14:19:58 -0300 Subject: [PATCH 02/31] fix: add the option to pass protocol in the host --- src/backend/langflow/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index c93de7667..73f6106d6 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -23,7 +23,13 @@ def replace_port(static_files_dir, host, port): # 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 - new_string = f'setItem("port","http://{host}:{port}")' + + # Check if the host is http or https + if "http" in host: + new_string = f'setItem("port","{host}:{port}")' + else: + new_string = f'setItem("port","http://{host}:{port}")' + with open(static_files_dir / "index.html", "r") as f: index_html = f.read() # using regex to replace the port From 5f024dc52c5b5ad5da800301efef53fda7530302 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Sat, 18 Mar 2023 17:54:57 -0300 Subject: [PATCH 03/31] fix: added logging --- src/backend/langflow/__main__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 73f6106d6..cf2a2f8a0 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -7,6 +7,9 @@ from langflow.main import create_app import typer from fastapi.staticfiles import StaticFiles from pathlib import Path +import logging + +logger = logging.getLogger(__name__) def get_number_of_workers(workers=None): @@ -25,10 +28,11 @@ def replace_port(static_files_dir, host, port): # This is a hacky way to do it, but it works # Check if the host is http or https - if "http" in host: - new_string = f'setItem("port","{host}:{port}")' - else: - new_string = f'setItem("port","http://{host}:{port}")' + 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() From 7e08751bb152eef9c1e5c4088fc77d7c1132f3f7 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Sat, 18 Mar 2023 18:22:51 -0300 Subject: [PATCH 04/31] fix: added tag to allow http --- src/frontend/public/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/frontend/public/index.html b/src/frontend/public/index.html index c1953d6b8..655da154e 100644 --- a/src/frontend/public/index.html +++ b/src/frontend/public/index.html @@ -4,6 +4,7 @@ + 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} />
- -