Merge pull request #10 from logspace-ai/dev
Use uvicorn on macOS to avoid making the user set env variable
This commit is contained in:
commit
feb83ffe46
15 changed files with 2218 additions and 3466 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -6,6 +6,9 @@ yarn-debug.log*
|
|||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
|
|
@ -230,5 +233,5 @@ venv.bak/
|
|||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
# Poetry
|
||||
.testenv/*
|
||||
8
Makefile
8
Makefile
|
|
@ -18,7 +18,7 @@ format:
|
|||
lint:
|
||||
poetry run mypy .
|
||||
poetry run black . --check
|
||||
poetry run ruff .
|
||||
poetry run ruff . --fix
|
||||
|
||||
install_frontend:
|
||||
cd langflow/frontend && npm install
|
||||
|
|
@ -29,7 +29,13 @@ build_frontend:
|
|||
build:
|
||||
make install_frontend
|
||||
make build_frontend
|
||||
cp -r langflow/frontend/build langflow/backend/langflow_backend/frontend
|
||||
poetry build --format sdist
|
||||
rm -rf langflow/backend/langflow_backend/frontend
|
||||
|
||||
publish:
|
||||
make build
|
||||
poetry publish
|
||||
|
||||
help:
|
||||
@echo '----'
|
||||
|
|
|
|||
18
README.md
18
README.md
|
|
@ -4,21 +4,17 @@
|
|||
|
||||
~ A User Interface For [LangChain](https://github.com/hwchase17/langchain) ~
|
||||
|
||||
|
||||
<p>
|
||||
<img alt="GitHub Contributors" src="https://img.shields.io/github/contributors/logspace-ai/langflow" />
|
||||
<img alt="GitHub Last Commit" src="https://img.shields.io/github/last-commit/logspace-ai/langflow" />
|
||||
<!-- <img alt="GitHub Language Count" src="https://img.shields.io/github/languages/count/logspace-ai/langflow" /> -->
|
||||
<img alt="" src="https://img.shields.io/github/repo-size/logspace-ai/langflow" />
|
||||
<!-- <img alt="GitHub Issues" src="https://img.shields.io/github/issues/logspace-ai/langflow" /> -->
|
||||
<!-- <img alt="GitHub Closed Issues" src="https://img.shields.io/github/issues-closed/logspace-ai/langflow" /> -->
|
||||
<!-- <img alt="GitHub Pull Requests" src="https://img.shields.io/github/issues-pr/logspace-ai/langflow" /> -->
|
||||
<!-- <img alt="GitHub Closed Pull Requests" src="https://img.shields.io/github/issues-pr-closed/logspace-ai/langflow" /> -->
|
||||
<!-- <img alt="GitHub Commit Activity (Year)" src="https://img.shields.io/github/commit-activity/y/logspace-ai/langflow" /> -->
|
||||
<img alt="GitHub Issues" src="https://img.shields.io/github/issues/logspace-ai/langflow" />
|
||||
<img alt="GitHub Pull Requests" src="https://img.shields.io/github/issues-pr/logspace-ai/langflow" />
|
||||
<img alt="Github License" src="https://img.shields.io/github/license/logspace-ai/langflow" />
|
||||
</p>
|
||||
|
||||

|
||||
<a href="https://github.com/logspace-ai/langflow">
|
||||
<img width="100%" src="https://github.com/logspace-ai/langflow/blob/main/img/langflow-demo.gif?raw=true"></a>
|
||||
|
||||
LangFlow is a GUI for [LangChain](https://github.com/hwchase17/langchain), designed with [react-flow](https://github.com/wbkd/react-flow) to provide an effortless way to experiment and prototype flows with drag-and-drop components and a chat box.
|
||||
|
||||
|
|
@ -32,18 +28,16 @@ Next, run:
|
|||
|
||||
`python -m langflow` or just `langflow`
|
||||
|
||||
|
||||
## 🎨 Creating Flows
|
||||
|
||||
Creating flows with LangFlow is easy. Simply drag sidebar components onto the canvas and connect them together to create your pipeline. LangFlow provides a range of [LangChain components](https://langchain.readthedocs.io/en/latest/reference.html) to choose from, including LLMs, prompt serializers, agents, and chains.
|
||||
Creating flows with LangFlow is easy. Simply drag sidebar components onto the canvas and connect them together to create your pipeline. LangFlow provides a range of [LangChain components](https://langchain.readthedocs.io/en/latest/reference.html) to choose from, including LLMs, prompt serializers, agents, and chains.
|
||||
|
||||
Explore by editing prompt parameters, link chains and agents, track an agent's thought process, and export your flow.
|
||||
|
||||
|
||||
## 👋 Contributing
|
||||
|
||||
We welcome contributions from developers of all levels to our open-source project on GitHub. If you'd like to contribute, please check our contributing guidelines and help make LangFlow more accessible.
|
||||
|
||||
We welcome contributions from developers of all levels to our open-source project on GitHub. If you'd like to contribute, please check our contributing guidelines and help make LangFlow more accessible.
|
||||
|
||||
## 📄 License
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
from langflow_backend.interface.loading import load_flow_from_json
|
||||
3
langflow/backend/.gitignore
vendored
3
langflow/backend/.gitignore
vendored
|
|
@ -4,6 +4,9 @@ __pycache__/
|
|||
*$py.class
|
||||
notebooks
|
||||
|
||||
# frontend
|
||||
langflow_backend/frontend
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
from langflow_backend.interface.loading import load_flow_from_json # noqa
|
||||
|
|
@ -1,42 +1,51 @@
|
|||
import multiprocessing
|
||||
import platform
|
||||
|
||||
from langflow_backend.main import create_app
|
||||
|
||||
import typer
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from pathlib import Path
|
||||
|
||||
from langflow.server import LangflowApplication
|
||||
|
||||
def get_number_of_workers(workers=None):
|
||||
if workers == -1:
|
||||
workers = (multiprocessing.cpu_count() * 2) + 1
|
||||
return workers
|
||||
|
||||
|
||||
def serve(
|
||||
workers: int = None,
|
||||
timeout: int = None,
|
||||
workers: int = 1,
|
||||
timeout: int = 60,
|
||||
):
|
||||
app = create_app()
|
||||
# get the directory of the current file
|
||||
path = Path(__file__).parent
|
||||
static_files_dir = path / "frontend/build"
|
||||
static_files_dir = path / "frontend"
|
||||
app.mount(
|
||||
"/",
|
||||
StaticFiles(directory=static_files_dir, html=True),
|
||||
name="static",
|
||||
)
|
||||
if not workers:
|
||||
workers = 1
|
||||
elif workers == -1:
|
||||
workers = (multiprocessing.cpu_count() * 2) + 1
|
||||
|
||||
if not timeout:
|
||||
timeout = 60
|
||||
|
||||
host = "127.0.0.1"
|
||||
port = 5003
|
||||
options = {
|
||||
"bind": "0.0.0.0:5003",
|
||||
"workers": workers,
|
||||
"bind": f"{host}:{port}",
|
||||
"workers": get_number_of_workers(workers),
|
||||
"worker_class": "uvicorn.workers.UvicornWorker",
|
||||
"timeout": timeout,
|
||||
}
|
||||
|
||||
LangflowApplication(app, options).run()
|
||||
if platform.system() == "Darwin":
|
||||
# Run using uvicorn on MacOS
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host=host, port=port, log_level="info")
|
||||
else:
|
||||
from langflow_backend.server import LangflowApplication
|
||||
|
||||
LangflowApplication(app, options).run()
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -120,7 +120,7 @@ def get_tool_signature(name: str):
|
|||
template["aiosession"]["required"] = False
|
||||
template["aiosession"]["show"] = False
|
||||
|
||||
template["_type"] = tool_type
|
||||
template["_type"] = tool_type # type: ignore
|
||||
|
||||
return {
|
||||
"template": template,
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ app = create_app()
|
|||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host="0.0.0.0", port=5003)
|
||||
uvicorn.run(app, host="127.0.0.1", port=5003)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from gunicorn.app.base import BaseApplication
|
||||
from gunicorn.app.base import BaseApplication # type: ignore
|
||||
|
||||
|
||||
class LangflowApplication(BaseApplication):
|
||||
2354
langflow/backend/poetry.lock
generated
2354
langflow/backend/poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,28 +0,0 @@
|
|||
[tool.poetry]
|
||||
name = "langflow-backend"
|
||||
version = "0.0.22"
|
||||
description = "Backend for Langflow"
|
||||
authors = ["Ibis Prevedello <ibiscp@gmail.com>", "Gabriel Almeida <gabrielf.almeida90@gmail.com>"]
|
||||
packages = [
|
||||
{ include = "langflow_backend" },
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
openai = "^0.26.5"
|
||||
fastapi = "^0.91.0"
|
||||
uvicorn = "^0.20.0"
|
||||
beautifulsoup4 = "^4.11.2"
|
||||
google-search-results = "^2.4.1"
|
||||
google-api-python-client = "^2.79.0"
|
||||
langchain = {git = "https://github.com/ibiscp/langchain.git", rev = "ibis"}
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.1.0"
|
||||
ipykernel = "^6.21.2"
|
||||
mypy = "^1.1.1"
|
||||
ruff = "^0.0.254"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
3173
poetry.lock
generated
3173
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,31 +1,39 @@
|
|||
[tool.poetry]
|
||||
name = "langflow"
|
||||
version = "0.0.1"
|
||||
version = "0.0.27"
|
||||
description = "A Python package with a built-in web application"
|
||||
authors = ["Ibis Prevedello <ibiscp@gmail.com>", "Gabriel Almeida <gabrielf.almeida90@gmail.com>","Otávio Anovazzi <otavio2204@gmail.com>"]
|
||||
authors = ["Ibis Prevedello <ibiscp@gmail.com>",
|
||||
"Gabriel Almeida <gabrielf.almeida90@gmail.com>",
|
||||
"Otávio Anovazzi <otavio2204@gmail.com>",
|
||||
"Lucas Eduoli <lucaseduoli@gmail.com"]
|
||||
packages = [
|
||||
{ include = "langflow"},
|
||||
{ include = "langflow_backend", from = "langflow/backend" },
|
||||
]
|
||||
include = ["langflow/frontend/build/*", "langflow/frontend/build/**/*"]
|
||||
exclude = ["langflow/frontend/node_modules/*", "langflow/frontend/src/*"]
|
||||
include = ["langflow/backend/langflow_backend/*", "langflow/backend/langflow_backend/**/*"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
langflow = "langflow.__main__:main"
|
||||
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ruff = "^0.0.254"
|
||||
black = "^23.1.0"
|
||||
mypy = "^1.1.1"
|
||||
pytest = "^7.2.2"
|
||||
pytest-cov = "^4.0.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
langflow = "langflow_backend.__main__:main"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
openai = "^0.26.5"
|
||||
fastapi = "^0.91.0"
|
||||
uvicorn = "^0.20.0"
|
||||
beautifulsoup4 = "^4.11.2"
|
||||
google-search-results = "^2.4.1"
|
||||
google-api-python-client = "^2.79.0"
|
||||
langchain_ibis = "0.0.100"
|
||||
typer = "^0.7.0"
|
||||
gunicorn = "^20.1.0"
|
||||
langflow_backend = {path = "langflow/backend"}
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.1.0"
|
||||
ipykernel = "^6.21.2"
|
||||
mypy = "^1.1.1"
|
||||
ruff = "^0.0.254"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from pathlib import Path
|
||||
from langflow import load_flow_from_json
|
||||
from langflow_backend import load_flow_from_json
|
||||
|
||||
|
||||
def test_load_flow_from_json():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue