docs: added fetching from notion (#2670)
* Added new Docusaurus instance that fetches automatically from Notion * Add Github workflow to fetch docs from Notion * Added legacy peer deps to solve dependency problems * Fix git ignore and added pages
BIN
docs/docs/Configuration/1009571828.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
docs/docs/Configuration/1125619904.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/docs/Configuration/1289235516.png
Normal file
|
After Width: | Height: | Size: 350 KiB |
BIN
docs/docs/Configuration/1813063533.png
Normal file
|
After Width: | Height: | Size: 341 KiB |
BIN
docs/docs/Configuration/1926471667.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
docs/docs/Configuration/383358552.png
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
docs/docs/Configuration/563306242.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
docs/docs/Configuration/596474918.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
docs/docs/Configuration/711485342.gif
Normal file
|
After Width: | Height: | Size: 833 KiB |
BIN
docs/docs/Configuration/945175915.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
96
docs/docs/Configuration/Folders.md
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
---
|
||||
title: Folders
|
||||
sidebar_position: 3
|
||||
slug: /365085a8-a90a-43f9-a779-f8769ec7eca1
|
||||
---
|
||||
|
||||
|
||||
|
||||
## **Collections and Projects** {#a259c11235144b18b3ae7a8265a2e6f5}
|
||||
|
||||
|
||||
My Collection is a space in Langflow where users can manage, organize, and access their flows and components. Flows and components are displayed as individual cards that provide relevant information.
|
||||
|
||||
|
||||

|
||||
|
||||
- **Folders**: Users can organize their projects into folders. Default folders include "My Projects" and the ability to create new folders. Hover over a folder to access options to download or delete it.
|
||||
- **Search Bar** Enables users to quickly search through their flows and components.
|
||||
- **Select All**: This feature allows users to select all projects displayed on the page for batch actions like moving, deleting, or exporting.
|
||||
|
||||
Click on a flow card to open it in Langflow Workspace or use the **Playground Button** for direct access to execute and interact with the flow’s chatbot interface.
|
||||
|
||||
|
||||
## Folders {#776a3866273f4efbbbb2febdfc1baa12}
|
||||
|
||||
|
||||
Folders can help you keep your projects organized in Langflow. They help you manage and categorize your work efficiently, making it easier to find and access the resources you need.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Multiple projects can be stored in **folders**.
|
||||
|
||||
|
||||
Folders allow you to categorize flows and components into manageable groups. This makes it easier to find and access specific projects quickly.
|
||||
|
||||
|
||||
**My Projects** is a default folder where all new projects and components are initially stored unless specified otherwise. Users can create custom folders to better organize their work according to specific needs.
|
||||
|
||||
|
||||
Hovering over a folder in Langflow provides options to either remove or download the entire folder, allowing you to keep an offline copy or migrate projects between environments
|
||||
|
||||
|
||||
Create new folders with the **New folder** button. One folder can store multiple projects (as the default My Projects folder does).
|
||||
|
||||
|
||||
You can download folders of projects as a single JSON file, and upload files and flows to your folder.
|
||||
|
||||
|
||||
Click the **Trash** icon to delete a folder.
|
||||
|
||||
|
||||
|
||||
### How to Create Folders {#5ba5abe995c843e4a429e41413f9d539}
|
||||
|
||||
1. **Navigate to the Home Screen:**
|
||||
- Go to your Langflow Home Page (outside of projects).
|
||||
2. **Create a New Folder:**
|
||||
- Click on the "New Folder" button
|
||||
|
||||

|
||||
|
||||
- Double-click the new folder created to rename your folder appropriately to reflect its contents.
|
||||
|
||||

|
||||
|
||||
3. **Move Files:**
|
||||
- Drag and drop files into the corresponding folders and subfolders to keep everything organized.
|
||||
|
||||

|
||||
|
||||
|
||||
### Best Practices for Organizing Folders {#66f23f8e129a48598a7bb4565a508360}
|
||||
|
||||
- **Categorize by Project:** Create a main folder for each project, then add projects for different aspects such as research, drafts, and final documents.
|
||||
- **Use Descriptive Names:** Use clear and descriptive names for your folders to easily identify their contents at a glance.
|
||||
|
||||
### Example Structure {#ebe6acad99c24d6f9aaabf18e4a17ff4}
|
||||
|
||||
|
||||
Here's an example of how you might organize folders and subfolders for a Langflow project:
|
||||
|
||||
|
||||
```text
|
||||
Langflow
|
||||
├── Research
|
||||
│ ├── Articles Project
|
||||
│ ├── Data Project
|
||||
│ └── Notes Project
|
||||
└── Documents
|
||||
├── RAG Project
|
||||
└── Advanced RAG Project
|
||||
|
||||
```
|
||||
|
||||
1
docs/docs/Configuration/_category_.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"position":8, "label":"Configuration"}
|
||||
211
docs/docs/Configuration/configuration-api-keys.md
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
---
|
||||
title: API Keys
|
||||
sidebar_position: 1
|
||||
slug: /configuration-api-keys
|
||||
---
|
||||
|
||||
|
||||
|
||||
:::caution
|
||||
|
||||
This page may contain outdated information. It will be updated as soon as possible.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
|
||||
|
||||
Langflow provides an API key functionality that allows users to access their individual components and flows without traditional login authentication. The API key is a user-specific token that can be included in the request header or query parameter to authenticate API calls. This documentation outlines how to generate, use, and manage API keys in Langflow.
|
||||
|
||||
|
||||
:::caution
|
||||
|
||||
The default user and password are set using the LANGFLOW_SUPERUSER and LANGFLOW_SUPERUSER_PASSWORD environment variables. The default values are langflow and langflow, respectively.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
|
||||
|
||||
## Generate an API key {#c29986a69cad4cdbbe7537e383ea7207}
|
||||
|
||||
|
||||
Generate a user-specific token to use with Langflow.
|
||||
|
||||
|
||||
### Generate an API key with the Langflow UI {#3d90098ddd7c44b6836c0273acf57123}
|
||||
|
||||
1. Click on the "API Key" icon.
|
||||
|
||||

|
||||
|
||||
2. Click on "Create new secret key".
|
||||
3. Give it an optional name.
|
||||
4. Click on "Create secret key".
|
||||
5. Copy the API key and store it in a secure location.
|
||||
|
||||
### Generate an API key with the Langflow CLI {#2368f62fc4b8477e8080c9c2d3659d76}
|
||||
|
||||
|
||||
```shell
|
||||
langflow api-key
|
||||
# or
|
||||
python -m langflow api-key
|
||||
╭─────────────────────────────────────────────────────────────────────╮
|
||||
│ API Key Created Successfully: │
|
||||
│ │
|
||||
│ sk-O0elzoWID1izAH8RUKrnnvyyMwIzHi2Wk-uXWoNJ2Ro │
|
||||
│ │
|
||||
│ This is the only time the API key will be displayed. │
|
||||
│ Make sure to store it in a secure location. │
|
||||
│ │
|
||||
│ The API key has been copied to your clipboard. Cmd + V to paste it. │
|
||||
╰──────────────────────────────
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Use the Langflow API key {#ae787e4b0d3846aa9094fac75e0ac04f}
|
||||
|
||||
|
||||
Include your API key in API requests to authenticate requests to Langflow.
|
||||
|
||||
|
||||
### Use the `x-api-key` header {#70965b3ad24d467ca4f90e7c13a1f394}
|
||||
|
||||
|
||||
Include the `x-api-key` in the HTTP header when making API requests:
|
||||
|
||||
|
||||
```shell
|
||||
curl -X POST \\
|
||||
<http://localhost:3000/api/v1/run/><your_flow_id> \\
|
||||
-H 'Content-Type: application/json'\\
|
||||
-H 'x-api-key: <your api key>'\\
|
||||
-d '{"inputs": {"text":""}, "tweaks": {}}'
|
||||
|
||||
```
|
||||
|
||||
|
||||
With Python using `requests`:
|
||||
|
||||
|
||||
```python
|
||||
import requests
|
||||
from typing import Optional
|
||||
|
||||
BASE_API_URL = "<http://localhost:3001/api/v1/process>"
|
||||
FLOW_ID = "4441b773-0724-434e-9cee-19d995d8f2df"
|
||||
# You can tweak the flow by adding a tweaks dictionary
|
||||
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
||||
TWEAKS = {}
|
||||
|
||||
def run_flow(inputs: dict,
|
||||
flow_id: str,
|
||||
tweaks: Optional[dict] = None,
|
||||
apiKey: Optional[str] = None) -> dict:
|
||||
"""
|
||||
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}"
|
||||
|
||||
payload = {"inputs": inputs}
|
||||
headers = {}
|
||||
|
||||
if tweaks:
|
||||
payload["tweaks"] = tweaks
|
||||
if apiKey:
|
||||
headers = {"x-api-key": apiKey}
|
||||
|
||||
response = requests.post(api_url, json=payload, headers=headers)
|
||||
return response.json()
|
||||
|
||||
# Setup any tweaks you want to apply to the flow
|
||||
inputs = {"text":""}
|
||||
api_key = "<your api key>"
|
||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS, apiKey=api_key))
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Use the query parameter {#febb797f3bb5403b9f070afc0fa4f453}
|
||||
|
||||
|
||||
Include the API key as a query parameter in the URL:
|
||||
|
||||
|
||||
```shell
|
||||
curl -X POST \\
|
||||
<http://localhost:3000/api/v1/process/><your_flow_id>?x-api-key=<your_api_key> \\
|
||||
-H 'Content-Type: application/json'\\
|
||||
-d '{"inputs": {"text":""}, "tweaks": {}}'
|
||||
|
||||
```
|
||||
|
||||
|
||||
With Python using `requests`:
|
||||
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
BASE_API_URL = "<http://localhost:3001/api/v1/process>"
|
||||
FLOW_ID = "4441b773-0724-434e-9cee-19d995d8f2df"
|
||||
# You can tweak the flow by adding a tweaks dictionary
|
||||
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
||||
TWEAKS = {}
|
||||
|
||||
def run_flow(inputs: dict,
|
||||
flow_id: str,
|
||||
tweaks: Optional[dict] = None,
|
||||
apiKey: Optional[str] = None) -> dict:
|
||||
"""
|
||||
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}"
|
||||
|
||||
payload = {"inputs": inputs}
|
||||
headers = {}
|
||||
|
||||
if tweaks:
|
||||
payload["tweaks"] = tweaks
|
||||
if apiKey:
|
||||
api_url += f"?x-api-key={apiKey}"
|
||||
|
||||
response = requests.post(api_url, json=payload, headers=headers)
|
||||
return response.json()
|
||||
|
||||
# Setup any tweaks you want to apply to the flow
|
||||
inputs = {"text":""}
|
||||
api_key = "<your api key>"
|
||||
print(run_flow(inputs, flow_id=FLOW_ID, tweaks=TWEAKS, apiKey=api_key))
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Security Considerations {#1273eb69a61344d19827b30dba46dfd5}
|
||||
|
||||
- **Visibility**: For security reasons, the API key cannot be retrieved again through the UI.
|
||||
- **Scope**: The key allows access only to the flows and components of the specific user to whom it was issued.
|
||||
|
||||
## Custom API endpoint {#da933a86690a4fdeac24024472caf8a9}
|
||||
|
||||
|
||||
Under **Project Settings** > **Endpoint Name**, you can pick a custom name for the endpoint used to call your flow from the API.
|
||||
|
||||
|
||||
## Revoke an API Key {#f0ea41ea167845cea91bb5e8f90d9df0}
|
||||
|
||||
|
||||
To revoke an API key, delete it from the UI. This action immediately invalidates the key and prevents it from being used again.
|
||||
|
||||
140
docs/docs/Configuration/configuration-authentication.md
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
title: Authentication
|
||||
sidebar_position: 0
|
||||
slug: /configuration-authentication
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Sign Up and Sign In {#f480dac5d2094d75a433de0b8e195641}
|
||||
|
||||
|
||||
> ⚠️ WARNING
|
||||
> This page may contain outdated information. It will be updated as soon as possible.
|
||||
>
|
||||
|
||||
|
||||
The login functionality in Langflow serves to authenticate users and protect sensitive routes in the application. Starting from version 0.5, Langflow introduces an enhanced login mechanism that is governed by a few environment variables. This allows new secure features.
|
||||
|
||||
|
||||
## Environment variables {#3ed7cae6f5324ba0ac14783cf2a6cc07}
|
||||
|
||||
|
||||
The following environment variables are crucial in configuring the login settings:
|
||||
|
||||
- _`LANGFLOW_AUTO_LOGIN`_: Determines whether Langflow should automatically log users in. Default is `True`.
|
||||
- _`LANGFLOW_SUPERUSER`_: The username of the superuser.
|
||||
- _`LANGFLOW_SUPERUSER_PASSWORD`_: The password for the superuser.
|
||||
- _`LANGFLOW_SECRET_KEY`_: A key used for encrypting the superuser's password.
|
||||
- _`LANGFLOW_NEW_USER_IS_ACTIVE`_: Determines whether new users are automatically activated. Default is `False`.
|
||||
|
||||
All of these variables can be passed to the CLI command _`langflow run`_ through the _`--env-file`_ option. For example:
|
||||
|
||||
|
||||
```shell
|
||||
langflow run --env-file .env
|
||||
|
||||
```
|
||||
|
||||
|
||||
> ℹ︎ INFO
|
||||
> It is critical not to expose these environment variables in your code repository. Always set them securely in your deployment environment, for example, using Docker secrets, Kubernetes ConfigMaps/Secrets, or dedicated secure environment configuration systems like AWS Secrets Manager.
|
||||
>
|
||||
|
||||
|
||||
### _`LANGFLOW_AUTO_LOGIN`_ {#8b10059e0fbc44f3bc8ce63fe7692e7e}
|
||||
|
||||
|
||||
By default, this variable is set to `True`. When enabled (`True`), Langflow operates as it did in versions prior to 0.5—automatic login without requiring explicit user authentication.
|
||||
|
||||
|
||||
To disable automatic login and enforce user authentication:
|
||||
|
||||
|
||||
```shell
|
||||
export LANGFLOW_AUTO_LOGIN=False
|
||||
```
|
||||
|
||||
|
||||
### _`LANGFLOW_SUPERUSER`_ and _`LANGFLOW_SUPERUSER_PASSWORD`_ {#a61a651a0fc7443a82cec93c07a14503}
|
||||
|
||||
|
||||
These environment variables are only relevant when `LANGFLOW_AUTO_LOGIN` is set to `False`. They specify the username and password for the superuser, which is essential for administrative tasks.
|
||||
|
||||
|
||||
To create a superuser manually:
|
||||
|
||||
|
||||
```shell
|
||||
export LANGFLOW_SUPERUSER=admin
|
||||
export LANGFLOW_SUPERUSER_PASSWORD=securepassword
|
||||
```
|
||||
|
||||
|
||||
You can also use the CLI command `langflow superuser` to set up a superuser interactively.
|
||||
|
||||
|
||||
### _`LANGFLOW_SECRET_KEY`_ {#977aea34e6174c58bd76107990d62a1f}
|
||||
|
||||
|
||||
This environment variable holds a secret key used for encrypting the superuser's password. Make sure to set this to a secure, randomly generated string.
|
||||
|
||||
|
||||
```shell
|
||||
export LANGFLOW_SECRET_KEY=randomly_generated_secure_key
|
||||
|
||||
```
|
||||
|
||||
|
||||
### _`LANGFLOW_NEW_USER_IS_ACTIVE`_ {#c8f5df9283be4e20be51e14518f5272e}
|
||||
|
||||
|
||||
By default, this variable is set to `False`. When enabled (`True`), new users are automatically activated and can log in without requiring explicit activation by the superuser.
|
||||
|
||||
|
||||
## Manage superusers with the CLI {#3b0c36a5cc0f4acc95c884d3de858d46}
|
||||
|
||||
|
||||
Langflow provides a command-line utility for managing superusers:
|
||||
|
||||
|
||||
```shell
|
||||
langflow superuser
|
||||
```
|
||||
|
||||
|
||||
This command prompts you to enter the username and password for the superuser, unless they are already set using environment variables.
|
||||
|
||||
|
||||
## Sign in {#736ebb8c854b4c268d5e748c119a08ea}
|
||||
|
||||
|
||||
With _`LANGFLOW_AUTO_LOGIN`_ set to _`False`_, Langflow requires users to sign up before they can log in. The sign-up page is the default landing page when a user visits Langflow for the first time.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
## Profile settings {#dd5926e12471448d99bd6849d2149dc8}
|
||||
|
||||
|
||||
Once signed in, you can change your profile settings by clicking on the profile icon in the top right corner of the Langflow dashboard. This opens a dropdown menu with the following options:
|
||||
|
||||
- **Admin Page**: Opens the admin page, which is only accessible to the superuser.
|
||||
- **Profile Settings**: Opens the profile settings page.
|
||||
- **Sign Out**: Logs the user out.
|
||||
|
||||

|
||||
|
||||
|
||||
Select **Profile Settings** to change your password and your profile picture.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Select **Admin Page** to manage users and groups as the superuser.
|
||||
|
||||
|
||||

|
||||
|
||||
149
docs/docs/Configuration/configuration-backend-only.md
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
---
|
||||
title: Backend-Only
|
||||
sidebar_position: 4
|
||||
slug: /configuration-backend-only
|
||||
---
|
||||
|
||||
|
||||
|
||||
> ⚠️ WARNING
|
||||
> This page may contain outdated information. It will be updated as soon as possible.
|
||||
|
||||
|
||||
You can run Langflow in `--backend-only` mode to expose your Langflow app as an API, without running the frontend UI.
|
||||
|
||||
|
||||
Start langflow in backend-only mode with `python3 -m langflow run --backend-only`.
|
||||
|
||||
|
||||
The terminal prints `Welcome to ⛓ Langflow`, and a blank window opens at `http://127.0.0.1:7864/all`.
|
||||
Langflow will now serve requests to its API without the frontend running.
|
||||
|
||||
|
||||
## Prerequisites {#81dfa9407ed648889081b9d08b0e5cfe}
|
||||
|
||||
- [Langflow installed](/getting-started-installation)
|
||||
- [OpenAI API key](https://platform.openai.com/)
|
||||
- [A Langflow flow created](/starter-projects-basic-prompting)
|
||||
|
||||
## Download your flow's curl call {#d2cf1b694e4741eca07fd9806516007b}
|
||||
|
||||
1. Click API.
|
||||
2. Click **curl** > **Copy code** and save the code to your local machine.
|
||||
It will look something like this:
|
||||
|
||||
```text
|
||||
curl -X POST \\
|
||||
"<http://127.0.0.1:7864/api/v1/run/ef7e0554-69e5-4e3e-ab29-ee83bcd8d9ef?stream=false>" \\
|
||||
-H 'Content-Type: application/json'\\
|
||||
-d '{"input_value": "message",
|
||||
"output_type": "chat",
|
||||
"input_type": "chat",
|
||||
"tweaks": {
|
||||
"Prompt-kvo86": {},
|
||||
"OpenAIModel-MilkD": {},
|
||||
"ChatOutput-ktwdw": {},
|
||||
"ChatInput-xXC4F": {}
|
||||
}}'
|
||||
|
||||
```
|
||||
|
||||
|
||||
Note the flow ID of `ef7e0554-69e5-4e3e-ab29-ee83bcd8d9ef`. You can find this ID in the UI as well to ensure you're querying the right flow.
|
||||
|
||||
|
||||
## Start Langflow in backend-only mode {#f0ba018daf3041c39c0d226dadf78d35}
|
||||
|
||||
1. Stop Langflow with Ctrl+C.
|
||||
2. Start langflow in backend-only mode with `python3 -m langflow run --backend-only`.
|
||||
The terminal prints `Welcome to ⛓ Langflow`, and a blank window opens at `http://127.0.0.1:7864/all`.
|
||||
Langflow will now serve requests to its API.
|
||||
3. Run the curl code you copied from the UI.
|
||||
You should get a result like this:
|
||||
|
||||
```shell
|
||||
{"session_id":"ef7e0554-69e5-4e3e-ab29-ee83bcd8d9ef:bf81d898868ac87e1b4edbd96c131c5dee801ea2971122cc91352d144a45b880","outputs":[{"inputs":{"input_value":"hi, are you there?"},"outputs":[{"results":{"result":"Arrr, ahoy matey! Aye, I be here. What be ye needin', me hearty?"},"artifacts":{"message":"Arrr, ahoy matey! Aye, I be here. What be ye needin', me hearty?","sender":"Machine","sender_name":"AI"},"messages":[{"message":"Arrr, ahoy matey! Aye, I be here. What be ye needin', me hearty?","sender":"Machine","sender_name":"AI","component_id":"ChatOutput-ktwdw"}],"component_display_name":"Chat Output","component_id":"ChatOutput-ktwdw","used_frozen_result":false}]}]}%
|
||||
|
||||
```
|
||||
|
||||
|
||||
Again, note that the flow ID matches.
|
||||
Langflow is receiving your POST request, running the flow, and returning the result, all without running the frontend. Cool!
|
||||
|
||||
|
||||
## Download your flow's Python API call {#5923ff9dc40843c7a22a72fa6c66540c}
|
||||
|
||||
|
||||
Instead of using curl, you can download your flow as a Python API call instead.
|
||||
|
||||
1. Click API.
|
||||
2. Click **Python API** > **Copy code** and save the code to your local machine.
|
||||
The code will look something like this:
|
||||
|
||||
```python
|
||||
import requests
|
||||
from typing import Optional
|
||||
|
||||
BASE_API_URL = "<http://127.0.0.1:7864/api/v1/run>"
|
||||
FLOW_ID = "ef7e0554-69e5-4e3e-ab29-ee83bcd8d9ef"
|
||||
# You can tweak the flow by adding a tweaks dictionary
|
||||
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
||||
|
||||
def run_flow(message: str,
|
||||
flow_id: str,
|
||||
output_type: str = "chat",
|
||||
input_type: str = "chat",
|
||||
tweaks: Optional[dict] = None,
|
||||
api_key: Optional[str] = None) -> dict:
|
||||
"""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}"
|
||||
payload = {
|
||||
"input_value": message,
|
||||
"output_type": output_type,
|
||||
"input_type": input_type,
|
||||
}
|
||||
headers = None
|
||||
if tweaks:
|
||||
payload["tweaks"] = tweaks
|
||||
if api_key:
|
||||
headers = {"x-api-key": api_key}
|
||||
response = requests.post(api_url, json=payload, headers=headers)
|
||||
return response.json()
|
||||
|
||||
# Setup any tweaks you want to apply to the flow
|
||||
|
||||
message = "message"
|
||||
|
||||
print(run_flow(message=message, flow_id=FLOW_ID))
|
||||
|
||||
```
|
||||
|
||||
|
||||
3. Run your Python app:
|
||||
|
||||
|
||||
```shell
|
||||
python3 app.py
|
||||
```
|
||||
|
||||
|
||||
The result is similar to the curl call:
|
||||
|
||||
|
||||
```json
|
||||
{'session_id': 'ef7e0554-69e5-4e3e-ab29-ee83bcd8d9ef:bf81d898868ac87e1b4edbd96c131c5dee801ea2971122cc91352d144a45b880', 'outputs': [{'inputs': {'input_value': 'message'}, 'outputs': [{'results': {'result': "Arrr matey! What be yer message for this ol' pirate? Speak up or walk the plank!"}, 'artifacts': {'message': "Arrr matey! What be yer message for this ol' pirate? Speak up or walk the plank!", 'sender': 'Machine', 'sender_name': 'AI'}, 'messages': [{'message': "Arrr matey! What be yer message for this ol' pirate? Speak up or walk the plank!", 'sender': 'Machine', 'sender_name': 'AI', 'component_id': 'ChatOutput-ktwdw'}], 'component_display_name': 'Chat Output', 'component_id': 'ChatOutput-ktwdw', 'used_frozen_result': False}]}]}
|
||||
|
||||
```
|
||||
|
||||
|
||||
Your Python app POSTs to your Langflow server, and the server runs the flow and returns the result.
|
||||
|
||||
|
||||
See [API](https://www.notion.so/administration/api) for more ways to interact with your headless Langflow server.
|
||||
|
||||
204
docs/docs/Configuration/configuration-cli.md
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
---
|
||||
title: Command Line Interface (CLI)
|
||||
sidebar_position: 2
|
||||
slug: /configuration-cli
|
||||
---
|
||||
|
||||
|
||||
|
||||
> ⚠️ WARNING
|
||||
> This page may contain outdated information. It will be updated as soon as possible.
|
||||
>
|
||||
|
||||
|
||||
Langflow's Command Line Interface (CLI) is a powerful tool that allows you to interact with the Langflow server from the command line. The CLI provides a wide range of commands to help you shape Langflow to your needs.
|
||||
|
||||
|
||||
The available commands are below. Navigate to their individual sections of this page to see the parameters.
|
||||
|
||||
- [langflow](/configuration-cli)
|
||||
- [langflow api-key](/configuration-cli)
|
||||
- [langflow copy-db](/configuration-cli)
|
||||
- [langflow migration](/configuration-cli)
|
||||
- [langflow run](/configuration-cli)
|
||||
- [langflow superuser](/configuration-cli)
|
||||
|
||||
## Overview {#c50e5530289349cf8ed7bee22ba2211a}
|
||||
|
||||
|
||||
Running the CLI without any arguments displays a list of available options and commands.
|
||||
|
||||
|
||||
```shell
|
||||
langflow
|
||||
# or
|
||||
langflow --help
|
||||
# or
|
||||
python -m langflow
|
||||
|
||||
```
|
||||
|
||||
|
||||
| Command | Description |
|
||||
| ----------- | ---------------------------------------------------------------------- |
|
||||
| `api-key` | Creates an API key for the default superuser if AUTO_LOGIN is enabled. |
|
||||
| `copy-db` | Copy the database files to the current directory (`which langflow`). |
|
||||
| `migration` | Run or test migrations. |
|
||||
| `run` | Run the Langflow. |
|
||||
| `superuser` | Create a superuser. |
|
||||
|
||||
|
||||
### Options {#8a3b5b7ed55b4774ad6d533bb337ef47}
|
||||
|
||||
|
||||
| Option | Description |
|
||||
| ---------------------- | -------------------------------------------------------------------------------- |
|
||||
| `--install-completion` | Install completion for the current shell. |
|
||||
| `--show-completion` | Show completion for the current shell, to copy it or customize the installation. |
|
||||
| `--help` | Show this message and exit. |
|
||||
|
||||
|
||||
## langflow api-key {#dbfc8c4c83474b83a38bdc7471bccf41}
|
||||
|
||||
|
||||
Run the `api-key` command to create an API key for the default superuser if `LANGFLOW_AUTO_LOGIN` is set to `True`.
|
||||
|
||||
|
||||
```shell
|
||||
langflow api-key
|
||||
# or
|
||||
python -m langflow api-key
|
||||
╭─────────────────────────────────────────────────────────────────────╮
|
||||
│ API Key Created Successfully: │
|
||||
│ │
|
||||
│ sk-O0elzoWID1izAH8RUKrnnvyyMwIzHi2Wk-uXWoNJ2Ro │
|
||||
│ │
|
||||
│ This is the only time the API key will be displayed. │
|
||||
│ Make sure to store it in a secure location. │
|
||||
│ │
|
||||
│ The API key has been copied to your clipboard. Cmd + V to paste it. │
|
||||
╰──────────────────────────────
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Options {#ec2ef993dc984811b25838c8d8230b31}
|
||||
|
||||
|
||||
| Option | Type | Description |
|
||||
| ----------- | ---- | ------------------------------------------------------------- |
|
||||
| --log-level | TEXT | Logging level. [env var: LANGFLOW_LOG_LEVEL] [default: error] |
|
||||
| --help | | Show this message and exit. |
|
||||
|
||||
|
||||
## langflow copy-db {#729a13f4847545e5973d8f9c20f8833d}
|
||||
|
||||
|
||||
Run the `copy-db` command to copy the cached `langflow.db` and `langflow-pre.db` database files to the current directory.
|
||||
|
||||
|
||||
If the files exist in the cache directory, they will be copied to the same directory as `__main__.py`, which can be found with `which langflow`.
|
||||
|
||||
|
||||
### Options {#7b7e6bd02b3243218e1d666711854673}
|
||||
|
||||
|
||||
None.
|
||||
|
||||
|
||||
## langflow migration {#7027c1925a444119a7a8ea2bff4bd16d}
|
||||
|
||||
|
||||
Run or test migrations with the Alembic database tool.
|
||||
|
||||
|
||||
```shell
|
||||
langflow migration
|
||||
# or
|
||||
python -m langflow migration
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Options {#0b38fbe97bb34edeb7740a7db58433e9}
|
||||
|
||||
|
||||
| Option | Description |
|
||||
| ------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--test, --no-test` | Run migrations in test mode. [default: test] |
|
||||
| `--fix, --no-fix` | Fix migrations. This is a destructive operation, and should only be used if you know what you are doing. [default: no-fix] |
|
||||
| `--help` | Show this message and exit. |
|
||||
|
||||
|
||||
## langflow run {#fe050aa659cb4d33a560b859d54c94ea}
|
||||
|
||||
|
||||
Run Langflow.
|
||||
|
||||
|
||||
```shell
|
||||
langflow run
|
||||
# or
|
||||
python -m langflow run
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Options {#4e811481ec9142f1b60309bb1ce5a2ce}
|
||||
|
||||
|
||||
| Option | Description |
|
||||
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--help` | Displays all available options. |
|
||||
| `--host` | Defines the host to bind the server to. Can be set using the `LANGFLOW_HOST` environment variable. The default is `127.0.0.1`. |
|
||||
| `--workers` | Sets the number of worker processes. Can be set using the `LANGFLOW_WORKERS` environment variable. The default is `1`. |
|
||||
| `--timeout` | Sets the worker timeout in seconds. The default is `60`. |
|
||||
| `--port` | Sets the port to listen on. Can be set using the `LANGFLOW_PORT` environment variable. The default is `7860`. |
|
||||
| `--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`. |
|
||||
| `--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` | Select 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`. |
|
||||
| `--dev`/`--no-dev` | Toggles the development mode. The default is `no-dev`. |
|
||||
| `--path` | Specifies the path to the frontend directory containing build files. This option is for development purposes only. Can be set using the `LANGFLOW_FRONTEND_PATH` environment variable. |
|
||||
| `--open-browser`/`--no-open-browser` | Toggles the option to open the browser after starting the server. Can be set using the `LANGFLOW_OPEN_BROWSER` environment variable. The default is `open-browser`. |
|
||||
| `--remove-api-keys`/`--no-remove-api-keys` | Toggles the option to remove API keys from the projects saved in the database. Can be set using the `LANGFLOW_REMOVE_API_KEYS` environment variable. The default is `no-remove-api-keys`. |
|
||||
| `--install-completion [bash\|zsh\|fish\|powershell\|pwsh]` | Installs completion for the specified shell. |
|
||||
| `--show-completion [bash\|zsh\|fish\|powershell\|pwsh]` | Shows completion for the specified shell, allowing you to copy it or customize the installation. |
|
||||
| `--backend-only` | This parameter, with a default value of `False`, allows running only the backend server without the frontend. It can also be set using the `LANGFLOW_BACKEND_ONLY` environment variable. |
|
||||
| `--store` | This parameter, with a default value of `True`, enables the store features, use `--no-store` to deactivate it. It can be configured using the `LANGFLOW_STORE` environment variable. |
|
||||
|
||||
|
||||
### CLI environment variables {#5868aaccfcc74e26968538ef4d07e756}
|
||||
|
||||
|
||||
You can configure many of the CLI options using environment variables. These can be exported in your operating system or added to a `.env` file and loaded using the `--env-file` option.
|
||||
|
||||
|
||||
A sample `.env` file named `.env.example` is included with the project. Copy this file to a new file named `.env` and replace the example values with your actual settings. If you're setting values in both your OS and the `.env` file, the `.env` settings will take precedence.
|
||||
|
||||
|
||||
## langflow superuser {#5944233ce0c942878e928e1f2945d717}
|
||||
|
||||
|
||||
Create a superuser for Langflow.
|
||||
|
||||
|
||||
```shell
|
||||
langflow superuser
|
||||
# or
|
||||
python -m langflow superuser
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Options {#f333c5635ead4c3d95985467bb08cc8f}
|
||||
|
||||
|
||||
| Option | Type | Description |
|
||||
| ------------- | ---- | ------------------------------------------------------------- |
|
||||
| `--username` | TEXT | Username for the superuser. [default: None] [required] |
|
||||
| `--password` | TEXT | Password for the superuser. [default: None] [required] |
|
||||
| `--log-level` | TEXT | Logging level. [env var: LANGFLOW_LOG_LEVEL] [default: error] |
|
||||
| `--help` | | Show this message and exit. |
|
||||
|
||||