diff --git a/pyproject.toml b/pyproject.toml index 9d5d13d01..ebabe274d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,21 @@ [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 = [ - { 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" diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index fd0479961..ea9386d7f 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -1,7 +1,6 @@ import logging import multiprocessing import platform -import re from pathlib import Path import typer @@ -18,42 +17,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 +36,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 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 d15aefe0c..45f992e04 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 ( _LLM_TOOLS, ) +from langflow.utils import constants + 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"] = constants.OPENAI_MODELS elif name == "OpenAIChat" and key == "model_name": - value["options"] = ["gpt-3.5-turbo", "gpt-4"] + value["options"] = constants.CHAT_OPENAI_MODELS return d diff --git a/src/frontend/package.json b/src/frontend/package.json index 01be61167..9afe85ebc 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -54,5 +54,5 @@ "last 1 safari version" ] }, - "proxy": "http://localhost:7860" + "proxy": "http://backend:7860" } \ No newline at end of file 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/DisclosureComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/DisclosureComponent/index.tsx index 17ff7de1a..5cddda2f8 100644 --- a/src/frontend/src/pages/FlowPage/components/DisclosureComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/DisclosureComponent/index.tsx @@ -14,7 +14,7 @@ export default function DisclosureComponent({ {({ open }) => ( <>
-
+
@@ -27,15 +27,15 @@ export default function DisclosureComponent({ {x.Icon} ))} - +
- +
-
+
{children} 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} />
- -