From a2e5fab6376b0d848dcd4874c9b67b3ca43f76e8 Mon Sep 17 00:00:00 2001 From: Deepankar Mahapatro Date: Wed, 17 May 2023 10:24:19 +0530 Subject: [PATCH] ci: trigger workflow during release --- .github/workflows/release.yml | 4 +-- README.md | 48 ++++++++++++++++++++++++++++++-- poetry.lock | 4 +-- pyproject.toml | 2 +- src/backend/langflow/__main__.py | 7 +++-- 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c39e91c9..cc9e15761 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,7 +51,7 @@ jobs: - name: Trigger build and push on langchain-serve uses: peter-evans/repository-dispatch@v2 with: - token: ${{ secrets.DEEPANKAR_GITHUB_TOKEN }} # TODO: repo authors need to create a PAT and add it to secrets + token: ${{ secrets.SERVE_GITHUB_TOKEN }} repository: jina-ai/langchain-serve event-type: langflow-push - client-payload: '{"push_token": "${{ secrets.LCSERVE_PUSH_TOKEN }}", "branch": "dev"}' # TODO: repo authors need to store `LCSERVE_PUSH_TOKEN` in secrets + client-payload: '{"push_token": "${{ secrets.LCSERVE_PUSH_TOKEN }}", "branch": "dev"}' diff --git a/README.md b/README.md index ecf851422..bd377896c 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,16 @@ Alternatively, click the **"Open in Cloud Shell"** button below to launch Google Langflow integrates with langchain-serve to provide a one-command deployment to Jina AI Cloud. -Start by installing `langchain-serve` with `pip install -U langchain-serve`. Then, run: +Start by installing `langchain-serve` with ```bash -langflow jcloud +pip install -U langchain-serve +``` + +Then, run: + +```bash +langflow --jcloud ``` ```text @@ -95,7 +101,43 @@ langflow jcloud -> Read more about customization, cost, and management of Langflow on Jina AI Cloud in the **[langchain-serve](https://github.com/jina-ai/langchain-serve)** repository. +#### API Usage + +You can use Langflow directly on your browser, or use the API endpoints on Jina AI Cloud to interact with the server. + +
+ Show API usage (with python) + + ```python + import json + import requests + + FLOW_PATH = "Time_traveller.json" + + # HOST = 'http://localhost:7860' + HOST = 'https://langflow-f1ed20e309.wolf.jina.ai' + API_URL = f'{HOST}/predict' + + def predict(message): + with open(FLOW_PATH, "r") as f: + json_data = json.load(f) + payload = {'exported_flow': json_data, 'message': message} + response = requests.post(API_URL, json=payload) + return response.json() + + + predict('Take me 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. ## 🎨 Creating Flows diff --git a/poetry.lock b/poetry.lock index b5469390b..165eba2dd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -5768,9 +5768,9 @@ cffi = {version = ">=1.11", markers = "platform_python_implementation == \"PyPy\ cffi = ["cffi (>=1.11)"] [extras] -production = ["langchain-serve"] +deploy = ["langchain-serve"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "a6fa5f8b36994c9b7dfa3de4979099f2e76cb534697823b49a949c661efa3fba" +content-hash = "bca5ed5cd32c5ad8d80faf99e9d988703202dd52001d2cbadaf61968a7cdebcc" diff --git a/pyproject.toml b/pyproject.toml index 972bcc229..9389b9661 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ types-pillow = "^9.5.0.2" [tool.poetry.extras] -production = ["langchain-serve"] +deploy = ["langchain-serve"] [tool.ruff] line-length = 120 diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index e6ca9b9de..89645aefc 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -33,11 +33,15 @@ def serve( config: str = typer.Option("config.yaml", help="Path to the configuration file."), log_level: str = typer.Option("info", help="Logging level."), log_file: Path = typer.Option("logs/langflow.log", help="Path to the log file."), + jcloud: bool = typer.Option(False, help="Deploy on Jina AI Cloud"), ): """ Run the Langflow server. """ + if jcloud: + return serve_on_jcloud() + configure(log_level=log_level, log_file=log_file) update_settings(config) app = create_app() @@ -69,8 +73,7 @@ def serve( LangflowApplication(app, options).run() -@app.command() -def jcloud(): +def serve_on_jcloud(): """ Deploy Langflow server on Jina AI Cloud """