Merge branch 'dev' into config
This commit is contained in:
commit
6fb02dc227
9 changed files with 31 additions and 57 deletions
|
|
@ -1,14 +1,21 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "langflow"
|
name = "langflow"
|
||||||
version = "0.0.44"
|
version = "0.0.45"
|
||||||
description = "A Python package with a built-in web application"
|
description = "A Python package with a built-in web application"
|
||||||
authors = ["Logspace <contact@logspace.ai>"]
|
authors = ["Logspace <contact@logspace.ai>"]
|
||||||
packages = [
|
maintainers = [
|
||||||
{ include = "langflow", from = "src/backend" },
|
"Gabriel Almeida <gabriel@logspace.ai>",
|
||||||
|
"Ibis Prevedello <ibiscp@gmail.com>",
|
||||||
|
"Lucas Eduoli <lucaseduoli@gmail.com>",
|
||||||
|
"Otávio Anovazzi <otavio2204@gmail.com>",
|
||||||
]
|
]
|
||||||
include = ["src/backend/langflow/*", "src/backend/langflow/**/*"]
|
repository = "https://github.com/logspace-ai/langflow"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
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]
|
[tool.poetry.scripts]
|
||||||
langflow = "langflow.__main__:main"
|
langflow = "langflow.__main__:main"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import platform
|
import platform
|
||||||
import re
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import typer
|
import typer
|
||||||
|
|
@ -18,42 +17,6 @@ def get_number_of_workers(workers=None):
|
||||||
return workers
|
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(
|
def serve(
|
||||||
host: str = "127.0.0.1", workers: int = 1, timeout: int = 60, port: int = 7860
|
host: str = "127.0.0.1", workers: int = 1, timeout: int = 60, port: int = 7860
|
||||||
):
|
):
|
||||||
|
|
@ -73,9 +36,6 @@ def serve(
|
||||||
"timeout": timeout,
|
"timeout": timeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Replace the port in index.html
|
|
||||||
replace_port(static_files_dir, host, port)
|
|
||||||
|
|
||||||
if platform.system() in ["Darwin", "Windows"]:
|
if platform.system() in ["Darwin", "Windows"]:
|
||||||
# Run using uvicorn on MacOS and Windows
|
# Run using uvicorn on MacOS and Windows
|
||||||
# Windows doesn't support gunicorn
|
# Windows doesn't support gunicorn
|
||||||
|
|
|
||||||
8
src/backend/langflow/utils/constants.py
Normal file
8
src/backend/langflow/utils/constants.py
Normal file
|
|
@ -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"]
|
||||||
|
|
@ -11,6 +11,8 @@ from langchain.agents.load_tools import (
|
||||||
_LLM_TOOLS,
|
_LLM_TOOLS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from langflow.utils import constants
|
||||||
|
|
||||||
|
|
||||||
def build_template_from_function(name: str, type_to_loader_dict: Dict):
|
def build_template_from_function(name: str, type_to_loader_dict: Dict):
|
||||||
classes = [
|
classes = [
|
||||||
|
|
@ -296,9 +298,9 @@ def format_dict(d, name: Optional[str] = None):
|
||||||
|
|
||||||
# Add options to openai
|
# Add options to openai
|
||||||
if name == "OpenAI" and key == "model_name":
|
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":
|
elif name == "OpenAIChat" and key == "model_name":
|
||||||
value["options"] = ["gpt-3.5-turbo", "gpt-4"]
|
value["options"] = constants.CHAT_OPENAI_MODELS
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,5 +54,5 @@
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"proxy": "http://localhost:7860"
|
"proxy": "http://backend:7860"
|
||||||
}
|
}
|
||||||
|
|
@ -5,9 +5,6 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>LangFLow</title>
|
<title>LangFLow</title>
|
||||||
<script>
|
|
||||||
window.sessionStorage.setItem("port","http://localhost:7860")
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body id='body' style="width: 100%; height:100%">
|
<body id='body' style="width: 100%; height:100%">
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
|
|
||||||
// Create a new flow with a default name if no flow is provided.
|
// Create a new flow with a default name if no flow is provided.
|
||||||
let newFlow: FlowType = {
|
let newFlow: FlowType = {
|
||||||
name: flow ? flow.name : "New Flow " + (flows.length===0?"":flows.length),
|
name: "New Flow",
|
||||||
id: id.toString(),
|
id: id.toString(),
|
||||||
data,
|
data,
|
||||||
chat: flow ? flow.chat : [],
|
chat: flow ? flow.chat : [],
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export default function DisclosureComponent({
|
||||||
{({ open }) => (
|
{({ open }) => (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<div className="select-none bg-gray-50 dark:bg-gray-700 dark:border-y-gray-600 w-full flex justify-between items-center -mt-px px-3 py-2 border-y border-y-gray-200">
|
<Disclosure.Button className="select-none bg-gray-50 dark:bg-gray-700 dark:border-y-gray-600 w-full flex justify-between items-center -mt-px px-3 py-2 border-y border-y-gray-200">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<Icon className="w-6 text-gray-800 dark:text-white" />
|
<Icon className="w-6 text-gray-800 dark:text-white" />
|
||||||
<span className="flex items-center text-sm text-gray-800 dark:text-white font-medium">
|
<span className="flex items-center text-sm text-gray-800 dark:text-white font-medium">
|
||||||
|
|
@ -27,15 +27,15 @@ export default function DisclosureComponent({
|
||||||
{x.Icon}
|
{x.Icon}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
<Disclosure.Button as="button">
|
<div>
|
||||||
<ChevronRightIcon
|
<ChevronRightIcon
|
||||||
className={`${
|
className={`${
|
||||||
open ? "rotate-90 transform" : ""
|
open ? "rotate-90 transform" : ""
|
||||||
} h-4 w-4 text-gray-800 dark:text-white`}
|
} h-4 w-4 text-gray-800 dark:text-white`}
|
||||||
/>
|
/>
|
||||||
</Disclosure.Button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Disclosure.Button>
|
||||||
</div>
|
</div>
|
||||||
<Disclosure.Panel as="div" className="-mt-px">
|
<Disclosure.Panel as="div" className="-mt-px">
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ export default function TabsManagerComponent() {
|
||||||
flow={null}
|
flow={null}
|
||||||
/>
|
/>
|
||||||
<div className="ml-auto mr-2 flex gap-3">
|
<div className="ml-auto mr-2 flex gap-3">
|
||||||
<button onClick={() => uploadFlow()} className="flex items-center gap-1 text-gray-400 hover:text-gray-500">
|
<button onClick={() => uploadFlow()} className="flex items-center gap-1 pr-2 border-gray-400 border-r text-sm text-gray-400 hover:text-gray-500">
|
||||||
Import <ArrowUpTrayIcon className="w-5 h-5" />
|
Import <ArrowUpTrayIcon className="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => downloadFlow()} className="flex items-center gap-1 text-gray-400 hover:text-gray-500">
|
<button onClick={() => downloadFlow()} className="flex items-center gap-1 mr-2 text-sm text-gray-400 hover:text-gray-500">
|
||||||
Export <ArrowDownTrayIcon className="h-5 w-5" />
|
Export <ArrowDownTrayIcon className="h-5 w-5" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue