diff --git a/Dockerfile b/Dockerfile index cbef555ba..6a1b7d4eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM logspace/backend_build as backend_build +# FROM logspace/backend_build as backend_build FROM logspace/frontend_build as frontend_build # `python-base` sets up all our shared environment variables @@ -41,29 +41,26 @@ RUN apt-get update \ build-essential libpq-dev git # install poetry - respects $POETRY_VERSION & $POETRY_HOME -RUN curl -sSL https://install.python-poetry.org | python3 - +# RUN curl -sSL https://install.python-poetry.org | python3 - # copy project requirement files here to ensure they will be cached. WORKDIR /app COPY pyproject.toml ./ -#poetry.lock +# copy langflow +COPY ./langflow ./langflow # Copy files from frontend COPY --from=frontend_build /app/build /app/langflow/frontend/build/ -# Copy files from backend and install -COPY --from=backend_build /app/dist/*.whl /app/dist/ -# Copy cli.py -COPY langflow/cli.py /app/langflow/ # RUN pip install langflow-0.0.17-py3-none-any.whl -RUN poetry install +RUN pip install . # RUN poetry add dist/langflow-0.0.17-py3-none-any.whl # RUN rm *.whl # RUN poetry build -# EXPOSE 80 +EXPOSE 5003 -# CMD [ "langchain" ] +CMD [ "langflow" ] diff --git a/dev.Dockerfile b/dev.Dockerfile new file mode 100644 index 000000000..dbe066f37 --- /dev/null +++ b/dev.Dockerfile @@ -0,0 +1,20 @@ +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10 + +WORKDIR /app + +# Install Poetry +RUN apt-get update && apt-get install -y curl +RUN curl -sSL https://install.python-poetry.org | python3 - +# Add Poetry to PATH +ENV PATH="${PATH}:/root/.local/bin" +# Copy the pyproject.toml and poetry.lock files +COPY poetry.lock pyproject.toml ./ +# Copy the rest of the application codes +COPY ./ ./ + + +# install dependencies +RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi + + +CMD ["uvicorn", "langflow.cli:app", "--host", "0.0.0.0", "--port", "5003"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..c01f16c26 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3' + +services: + backend: + build: + context: ./ + dockerfile: ./dev.Dockerfile + ports: + - "5003:5003" + volumes: + - ./:/app + environment: + - PYTHONPATH=/langflow # add this line to set PYTHONPATH + + frontend: + build: ./langflow/frontend + ports: + - "3000:3000" + volumes: + - ./langflow/frontend:/app diff --git a/langflow/__init__.py b/langflow/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/langflow/cli.py b/langflow/cli.py index 4cdc9445e..99805b3e5 100644 --- a/langflow/cli.py +++ b/langflow/cli.py @@ -1,25 +1,27 @@ -from fastapi import FastAPI +from langflow.backend.app import create_app + +import typer +import uvicorn from fastapi.staticfiles import StaticFiles from pathlib import Path -from langflow.backend.app import create_app - -# get the directory of the current file -path = Path(__file__).parent -static_files_dir = path / "frontend/build" app = create_app() -app.mount( - "/", - StaticFiles(directory=static_files_dir, html=True), - name="static", -) + +def serve(port: int = 5003): + # get the directory of the current file + path = Path(__file__).parent + static_files_dir = path / "frontend/build" + app.mount( + "/", + StaticFiles(directory=static_files_dir, html=True), + name="static", + ) + uvicorn.run(app, port=port) def main(): - import uvicorn - - uvicorn.run(app, host="localhost", port=80) + typer.run(serve) if __name__ == "__main__": diff --git a/langflow/frontend/src/App.tsx b/langflow/frontend/src/App.tsx index 51b2b0f2e..e34d24ac0 100644 --- a/langflow/frontend/src/App.tsx +++ b/langflow/frontend/src/App.tsx @@ -8,7 +8,6 @@ import SuccessAlert from "./alerts/success"; import ExtraSidebar from "./components/ExtraSidebarComponent"; import { alertContext } from "./contexts/alertContext"; import { locationContext } from "./contexts/locationContext"; -import Sidebar from "./components/SidebarComponent"; import Header from "./components/HeaderComponent"; import TabsManagerComponent from "./pages/FlowPage/components/tabsManagerComponent"; @@ -36,38 +35,45 @@ export default function App() { setSuccessOpen, } = useContext(alertContext); - const [alertsList, setAlertsList] = useState,link?:string},id:string}>>([]); +// Initialize state variable for the list of alerts +const [alertsList, setAlertsList] = useState,link?:string},id:string}>>([]); - useEffect(() => { - if (errorOpen && errorData) { - setErrorOpen(false); - setAlertsList((old) => { - let newAlertsList = [ - ...old, - { type: "error", data: _.cloneDeep(errorData), id: _.uniqueId() }, - ]; - return newAlertsList; - }); - } else if (noticeOpen && noticeData) { - setNoticeOpen(false); - setAlertsList((old) => { - let newAlertsList = [ - ...old, - { type: "notice", data: _.cloneDeep(noticeData), id: _.uniqueId() }, - ]; - return newAlertsList; - }); - } else if (successOpen && successData) { - setSuccessOpen(false); - setAlertsList((old) => { - let newAlertsList = [ - ...old, - { type: "success", data: _.cloneDeep(successData), id: _.uniqueId() }, - ]; - return newAlertsList; - }); - } - }, [_, errorData, errorOpen, noticeData, noticeOpen, setErrorOpen, setNoticeOpen, setSuccessOpen, successData, successOpen]); +// Use effect hook to update alertsList when a new alert is added +useEffect(() => { + // If there is an error alert open with data, add it to the alertsList + if (errorOpen && errorData) { + setErrorOpen(false); + setAlertsList((old) => { + let newAlertsList = [ + ...old, + { type: "error", data: _.cloneDeep(errorData), id: _.uniqueId() }, + ]; + return newAlertsList; + }); + } + // If there is a notice alert open with data, add it to the alertsList + else if (noticeOpen && noticeData) { + setNoticeOpen(false); + setAlertsList((old) => { + let newAlertsList = [ + ...old, + { type: "notice", data: _.cloneDeep(noticeData), id: _.uniqueId() }, + ]; + return newAlertsList; + }); + } + // If there is a success alert open with data, add it to the alertsList + else if (successOpen && successData) { + setSuccessOpen(false); + setAlertsList((old) => { + let newAlertsList = [ + ...old, + { type: "success", data: _.cloneDeep(successData), id: _.uniqueId() }, + ]; + return newAlertsList; + }); + } +}, [_, errorData, errorOpen, noticeData, noticeOpen, setErrorOpen, setNoticeOpen, setSuccessOpen, successData, successOpen]); const removeAlert = (id: string) => { setAlertsList((prevAlertsList) => @@ -82,9 +88,7 @@ export default function App() {
- - {/* Main area */}
{/* Primary column */} diff --git a/langflow/frontend/src/components/ExtraSidebarComponent/index.tsx b/langflow/frontend/src/components/ExtraSidebarComponent/index.tsx index 25d6ab89b..7a112fd29 100644 --- a/langflow/frontend/src/components/ExtraSidebarComponent/index.tsx +++ b/langflow/frontend/src/components/ExtraSidebarComponent/index.tsx @@ -25,12 +25,6 @@ export default function ExtraSidebar() { {extraNavigation.title} -
{extraNavigation.options ? ( diff --git a/langflow/frontend/src/components/HeaderComponent/index.tsx b/langflow/frontend/src/components/HeaderComponent/index.tsx index 4bb25ea4f..40611e9c4 100644 --- a/langflow/frontend/src/components/HeaderComponent/index.tsx +++ b/langflow/frontend/src/components/HeaderComponent/index.tsx @@ -4,7 +4,6 @@ import { MoonIcon, SunIcon, } from '@heroicons/react/24/outline' -import Breadcrumb from '../breadcrumbComponent' import { alertContext } from '../../contexts/alertContext' import { useLayer } from 'react-laag' import AlertDropdown from '../../alerts/alertDropDown' @@ -25,25 +24,8 @@ export default function Header(){ const {dark, setDark} = useContext(darkContext); return (
- {/* Logo area */} -
- - Your Company - -
- {/* Desktop nav area */} -
-
- -
+
diff --git a/langflow/frontend/src/components/SidebarComponent/index.tsx b/langflow/frontend/src/components/SidebarComponent/index.tsx deleted file mode 100644 index 9901614a5..000000000 --- a/langflow/frontend/src/components/SidebarComponent/index.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import SidebarButton from "./sidebarButton"; -import { BsPlusSquare } from "react-icons/bs"; -import { classNames } from "../../utils"; -import { ChevronRightIcon } from "@heroicons/react/24/outline"; -import { useContext } from "react"; -import { sidebarNavigation } from "../../entities/sidebarNav"; -import { locationContext } from "../../contexts/locationContext"; - -export default function Sidebar() { - let { showSideBar, isStackedOpen, setIsStackedOpen } = - useContext(locationContext); - let current = false; - return ( -
-
- -
-
- ); -} diff --git a/langflow/frontend/src/components/SidebarComponent/sidebarButton/index.tsx b/langflow/frontend/src/components/SidebarComponent/sidebarButton/index.tsx deleted file mode 100644 index d98b95f9f..000000000 --- a/langflow/frontend/src/components/SidebarComponent/sidebarButton/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { classNames } from "../../../utils" -import { Link } from "react-router-dom" -import { useContext } from "react" -import { locationContext } from "../../../contexts/locationContext"; -import { sidebarNavigationItemType } from "../../../types/entities"; - -export default function SidebarButton({item}:{item:sidebarNavigationItemType}){ - let {current}= useContext(locationContext); - return ( - <> - - {item.name} -