From 868ecd86ab0e588c97512c196881b5ec713d3992 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 31 Jul 2023 17:46:38 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs(README.md):=20remove=20unne?= =?UTF-8?q?cessary=20empty=20line=20=F0=9F=93=9D=20docs(README.md):=20upda?= =?UTF-8?q?te=20Table=20of=20Contents=20formatting=20=F0=9F=93=9D=20docs(R?= =?UTF-8?q?EADME.md):=20update=20Installation=20section=20formatting=20?= =?UTF-8?q?=F0=9F=93=9D=20docs(README.md):=20update=20Command=20Line=20Int?= =?UTF-8?q?erface=20(CLI)=20section=20formatting=20=F0=9F=93=9D=20docs(REA?= =?UTF-8?q?DME.md):=20update=20Deployment=20section=20formatting=20?= =?UTF-8?q?=F0=9F=93=9D=20docs(README.md):=20update=20API=20Usage=20sectio?= =?UTF-8?q?n=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 chore(README.md): remove unnecessary whitespace and fix indentation in code block 📝 docs(README.md): update contributing section and add links to Discord server and contributing guidelines 🐛 fix(__main__.py): change envvar name from LANGFLOW_COMPONENT_PATH to LANGFLOW_COMPONENTS_PATH for consistency and clarity --- README.md | 123 ++++++++++++++++--------------- src/backend/langflow/__main__.py | 2 +- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 4b0494c8c..dc0695a88 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ Github License

-

Discord Server HuggingFace Spaces @@ -22,32 +21,33 @@ -

# Table of Contents + - [⛓️ Langflow](#️-langflow) - [Table of Contents](#table-of-contents) - [📦 Installation](#-installation) - - [Locally](#locally) - - [HuggingFace Spaces](#huggingface-spaces) + - [Locally](#locally) + - [HuggingFace Spaces](#huggingface-spaces) - [🖥️ Command Line Interface (CLI)](#️-command-line-interface-cli) - - [Usage](#usage) - - [Environment Variables](#environment-variables) + - [Usage](#usage) + - [Environment Variables](#environment-variables) - [Deployment](#deployment) - [Deploy Langflow on Google Cloud Platform](#deploy-langflow-on-google-cloud-platform) - [Deploy Langflow on Jina AI Cloud](#deploy-langflow-on-jina-ai-cloud) - - [API Usage](#api-usage) + - [API Usage](#api-usage) - [Deploy on Railway](#deploy-on-railway) - [Deploy on Render](#deploy-on-render) - [🎨 Creating Flows](#-creating-flows) - [👋 Contributing](#-contributing) - [📄 License](#-license) - # 📦 Installation + ### Locally + You can install Langflow from pip: ```shell @@ -59,12 +59,15 @@ Next, run: ```shell python -m langflow ``` + or + ```shell langflow # or langflow --help ``` ### HuggingFace Spaces + You can also check it out on [HuggingFace Spaces](https://huggingface.co/spaces/Logspace/Langflow) and run it in your browser! You can even clone it and have your own copy of Langflow to play with. # 🖥️ Command Line Interface (CLI) @@ -89,7 +92,7 @@ Each option is detailed below: - `--config`: Defines the path to the configuration file. The default is `config.yaml`. - `--env-file`: Specifies the path to the .env file containing environment variables. The default is `.env`. - `--log-level`: Defines the logging level. Can be set using the `LANGFLOW_LOG_LEVEL` environment variable. The default is `critical`. -- `component-path`: Specifies the path to the directory containing custom components. Can be set using the `LANGFLOW_COMPONENT_PATH` environment variable. The default is `langflow/components`. +- `--components-path`: Specifies the path to the directory containing custom components. Can be set using the `LANGFLOW_COMPONENTS_PATH` environment variable. The default is `langflow/components`. - `--log-file`: Specifies the path to the log file. Can be set using the `LANGFLOW_LOG_FILE` environment variable. The default is `logs/langflow.log`. - `--cache`: Selects the type of cache to use. Options are `InMemoryCache` and `SQLiteCache`. Can be set using the `LANGFLOW_LANGCHAIN_CACHE` environment variable. The default is `SQLiteCache`. - `--jcloud/--no-jcloud`: Toggles the option to deploy on Jina AI Cloud. The default is `no-jcloud`. @@ -117,7 +120,6 @@ Alternatively, click the **"Open in Cloud Shell"** button below to launch Google [![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/logspace-ai/langflow&working_dir=scripts&shellonly=true&tutorial=walkthroughtutorial_spot.md) - ## Deploy Langflow on [Jina AI Cloud](https://github.com/jina-ai/langchain-serve) Langflow integrates with langchain-serve to provide a one-command deployment to Jina AI Cloud. @@ -143,33 +145,33 @@ langflow --jcloud
Show complete (example) output - ```text - 🚀 Deploying Langflow server on Jina AI Cloud - ╭───────────────────────── 🎉 Flow is available! ──────────────────────────╮ - │ │ - │ ID langflow-e3dd8820ec │ - │ Gateway (Websocket) wss://langflow-e3dd8820ec.wolf.jina.ai │ - │ Dashboard https://dashboard.wolf.jina.ai/flow/e3dd8820ec │ - │ │ - ╰──────────────────────────────────────────────────────────────────────────╯ - ╭──────────────┬──────────────────────────────────────────────────────────────────────────────╮ - │ App ID │ langflow-e3dd8820ec │ - ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ - │ Phase │ Serving │ - ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ - │ Endpoint │ wss://langflow-e3dd8820ec.wolf.jina.ai │ - ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ - │ App logs │ dashboards.wolf.jina.ai │ - ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ - │ Swagger UI │ https://langflow-e3dd8820ec.wolf.jina.ai/docs │ - ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ - │ OpenAPI JSON │ https://langflow-e3dd8820ec.wolf.jina.ai/openapi.json │ - ╰──────────────┴──────────────────────────────────────────────────────────────────────────────╯ +```text + 🚀 Deploying Langflow server on Jina AI Cloud + ╭───────────────────────── 🎉 Flow is available! ──────────────────────────╮ + │ │ + │ ID langflow-e3dd8820ec │ + │ Gateway (Websocket) wss://langflow-e3dd8820ec.wolf.jina.ai │ + │ Dashboard https://dashboard.wolf.jina.ai/flow/e3dd8820ec │ + │ │ + ╰──────────────────────────────────────────────────────────────────────────╯ + ╭──────────────┬──────────────────────────────────────────────────────────────────────────────╮ + │ App ID │ langflow-e3dd8820ec │ + ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ + │ Phase │ Serving │ + ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ + │ Endpoint │ wss://langflow-e3dd8820ec.wolf.jina.ai │ + ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ + │ App logs │ dashboards.wolf.jina.ai │ + ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ + │ Swagger UI │ https://langflow-e3dd8820ec.wolf.jina.ai/docs │ + ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ + │ OpenAPI JSON │ https://langflow-e3dd8820ec.wolf.jina.ai/openapi.json │ + ╰──────────────┴──────────────────────────────────────────────────────────────────────────────╯ - 🎉 Langflow server successfully deployed on Jina AI Cloud 🎉 - 🔗 Click on the link to open the server (please allow ~1-2 minutes for the server to startup): https://langflow-e3dd8820ec.wolf.jina.ai/ - 📖 Read more about managing the server: https://github.com/jina-ai/langchain-serve - ``` + 🎉 Langflow server successfully deployed on Jina AI Cloud 🎉 + 🔗 Click on the link to open the server (please allow ~1-2 minutes for the server to startup): https://langflow-e3dd8820ec.wolf.jina.ai/ + 📖 Read more about managing the server: https://github.com/jina-ai/langchain-serve +```
@@ -180,7 +182,7 @@ You can use Langflow directly on your browser, or use the API endpoints on Jina
Show API usage (with python) - ```python +```python import requests BASE_API_URL = "https://langflow-e3dd8820ec.wolf.jina.ai/api/v1/predict" @@ -188,47 +190,49 @@ FLOW_ID = "864c4f98-2e59-468b-8e13-79cd8da07468" # You can tweak the flow by adding a tweaks dictionary # e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}} TWEAKS = { - "ChatOpenAI-g4jEr": {}, - "ConversationChain-UidfJ": {} +"ChatOpenAI-g4jEr": {}, +"ConversationChain-UidfJ": {} } def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict: - """ - Run a flow with a given message and optional tweaks. + """ + Run a flow with a given message and optional tweaks. - :param message: The message to send to the flow - :param flow_id: The ID of the flow to run - :param tweaks: Optional tweaks to customize the flow - :return: The JSON response from the flow - """ - api_url = f"{BASE_API_URL}/{flow_id}" + :param message: The message to send to the flow + :param flow_id: The ID of the flow to run + :param tweaks: Optional tweaks to customize the flow + :return: The JSON response from the flow + """ + api_url = f"{BASE_API_URL}/{flow_id}" - payload = {"message": message} + payload = {"message": message} - if tweaks: - payload["tweaks"] = tweaks + if tweaks: + payload["tweaks"] = tweaks - response = requests.post(api_url, json=payload) - return response.json() + response = requests.post(api_url, json=payload) + return response.json() # Setup any tweaks you want to apply to the flow print(run_flow("Your message", flow_id=FLOW_ID, tweaks=TWEAKS)) - ``` +``` - ```json - { - "result": "Great choice! Bangalore in the 1920s was a vibrant city with a rich cultural and political scene. Here are some suggestions for things to see and do:\n\n1. Visit the Bangalore Palace - built in 1887, this stunning palace is a perfect example of Tudor-style architecture. It was home to the Maharaja of Mysore and is now open to the public.\n\n2. Attend a performance at the Ravindra Kalakshetra - this cultural center was built in the 1920s and is still a popular venue for music and dance performances.\n\n3. Explore the neighborhoods of Basavanagudi and Malleswaram - both of these areas have retained much of their old-world charm and are great places to walk around and soak up the atmosphere.\n\n4. Check out the Bangalore Club - founded in 1868, this exclusive social club was a favorite haunt of the British expat community in the 1920s.\n\n5. Attend a meeting of the Indian National Congress - founded in 1885, the INC was a major force in the Indian independence movement and held many meetings and rallies in Bangalore in the 1920s.\n\nHope you enjoy your trip to 1920s Bangalore!" - } - ``` +```json +{ + "result": "Great choice! Bangalore in the 1920s was a vibrant city with a rich cultural and political scene. Here are some suggestions for things to see and do:\n\n1. Visit the Bangalore Palace - built in 1887, this stunning palace is a perfect example of Tudor-style architecture. It was home to the Maharaja of Mysore and is now open to the public.\n\n2. Attend a performance at the Ravindra Kalakshetra - this cultural center was built in the 1920s and is still a popular venue for music and dance performances.\n\n3. Explore the neighborhoods of Basavanagudi and Malleswaram - both of these areas have retained much of their old-world charm and are great places to walk around and soak up the atmosphere.\n\n4. Check out the Bangalore Club - founded in 1868, this exclusive social club was a favorite haunt of the British expat community in the 1920s.\n\n5. Attend a meeting of the Indian National Congress - founded in 1885, the INC was a major force in the Indian independence movement and held many meetings and rallies in Bangalore in the 1920s.\n\nHope you enjoy your trip to 1920s Bangalore!" +} +```
> Read more about resource customization, cost, and management of Langflow apps on Jina AI Cloud in the **[langchain-serve](https://github.com/jina-ai/langchain-serve)** repository. ## Deploy on Railway + [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/Emy2sU?referralCode=MnPSdg) ## Deploy on Render + Deploy to Render @@ -251,12 +255,10 @@ flow = load_flow_from_json("path/to/flow.json") flow("Hey, have you heard of Langflow?") ``` - # 👋 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](./CONTRIBUTING.md) and help make Langflow more accessible. - Join our [Discord](https://discord.com/invite/EqksyE2EX9) server to ask questions, make suggestions and showcase your projects! 🦾

@@ -264,7 +266,6 @@ Join our [Discord](https://discord.com/invite/EqksyE2EX9) server to ask question [![Star History Chart](https://api.star-history.com/svg?repos=logspace-ai/langflow&type=Timeline)](https://star-history.com/#logspace-ai/langflow&Date) - # 📄 License Langflow is released under the MIT License. See the LICENSE file for details. diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index f15587dba..b20a2a902 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -129,7 +129,7 @@ def serve( components_path: Optional[Path] = typer.Option( Path(__file__).parent, help="Path to the directory containing custom components.", - envvar="LANGFLOW_COMPONENT_PATH", + envvar="LANGFLOW_COMPONENTS_PATH", ), config: str = typer.Option("config.yaml", help="Path to the configuration file."), # .env file param