combine-global-env-docs
This commit is contained in:
parent
dae11df7da
commit
c371cbc22b
3 changed files with 72 additions and 142 deletions
|
|
@ -1,35 +1,42 @@
|
||||||
|
import ThemedImage from "@theme/ThemedImage";
|
||||||
|
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||||
import Admonition from "@theme/Admonition";
|
|
||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
|
import Admonition from "@theme/Admonition";
|
||||||
|
|
||||||
# Global Environment Variables
|
# Global Variables
|
||||||
|
|
||||||
Langflow 1.0 alpha includes the option to add **Global Environment Variables** for your application.
|
Global Variables are a useful feature of Langflow, allowing you to define reusable variables accessed from any Text field in your project.
|
||||||
|
|
||||||
## Add a global variable to a project
|
## TL;DR
|
||||||
|
|
||||||
In this example, you'll add the `openai_api_key` credential as a global environment variable to the **Basic Prompting** starter project.
|
- Global Variables are reusable variables accessible from any Text field in your project.
|
||||||
|
- To create one, click the 🌐 button in a Text field and then **+ Add New Variable**.
|
||||||
|
- Define the **Name**, **Type**, and **Value** of the variable.
|
||||||
|
- Click **Save Variable** to create it.
|
||||||
|
- All Credential Global Variables are encrypted and accessible only by you.
|
||||||
|
- Set _`LANGFLOW_STORE_ENVIRONMENT_VARIABLES`_ to _`true`_ in your `.env` file to add all variables in _`LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`_ to your user's Global Variables.
|
||||||
|
|
||||||
For more information on the starter flow, see [Basic prompting](../starter-projects/basic-prompting.mdx).
|
|
||||||
|
|
||||||
1. From the Langflow dashboard, click **New Project**.
|
## Creating and Adding a Global Variable
|
||||||
2. Select **Basic Prompting**.
|
|
||||||
|
|
||||||
The **Basic Prompting** flow is created.
|
To create and add a global variable, click the 🌐 button in a Text field, and then click **+ Add New Variable**.
|
||||||
|
|
||||||
3. To create an environment variable for the **OpenAI** component:
|
Text fields are where you write text without opening a Text area, and are identified with the 🌐 icon.
|
||||||
1. In the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
|
||||||
2. In the **Variable Name** field, enter `openai_api_key`.
|
For example, to create an environment variable for the **OpenAI** component:
|
||||||
3. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
1. In the **OpenAI API Key** text field, click the 🌐 button, then **Add New Variable**.
|
||||||
4. For the variable **Type**, select **Credential**.
|
2. Enter `openai_api_key` in the **Variable Name** field.
|
||||||
5. In the **Apply to Fields** field, select **OpenAI API Key** to apply this variable to all fields named **OpenAI API Key**.
|
3. Paste your OpenAI API Key (`sk-...`) in the **Value** field.
|
||||||
|
4. Select **Credential** for the **Type**.
|
||||||
|
5. Choose **OpenAI API Key** in the **Apply to Fields** field to apply this variable to all fields named **OpenAI API Key**.
|
||||||
6. Click **Save Variable**.
|
6. Click **Save Variable**.
|
||||||
|
|
||||||
You now have a `openai_api_key` global environment variable for your Langflow project.
|
You now have a `openai_api_key` global environment variable for your Langflow project.
|
||||||
|
Subsequently, clicking the 🌐 button in a Text field will display the new variable in the dropdown.
|
||||||
|
|
||||||
<Admonition type="tip">
|
<Admonition type="tip">
|
||||||
You can also create global variables in **Settings** > **Variables and
|
You can also create global variables in **Settings** > **Variables and Secrets**.
|
||||||
Secrets**.
|
|
||||||
</Admonition>
|
</Admonition>
|
||||||
|
|
||||||
<ZoomableImage
|
<ZoomableImage
|
||||||
|
|
@ -41,10 +48,54 @@ You now have a `openai_api_key` global environment variable for your Langflow pr
|
||||||
style={{ width: "40%", margin: "20px auto" }}
|
style={{ width: "40%", margin: "20px auto" }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
4. To view and manage your project's global environment variables, visit **Settings** > **Variables and Secrets**.
|
To view and manage your project's global environment variables, visit **Settings** > **Variables and Secrets**.
|
||||||
|
|
||||||
For more on variables in HuggingFace Spaces, see [Managing Secrets](https://huggingface.co/docs/hub/spaces-overview#managing-secrets).
|
For more on variables in HuggingFace Spaces, see [Managing Secrets](https://huggingface.co/docs/hub/spaces-overview#managing-secrets).
|
||||||
|
|
||||||
|
{/* All variables are encrypted */}
|
||||||
|
|
||||||
|
<Admonition type="warning">
|
||||||
|
All Credential Global Variables are encrypted and accessible only by you.
|
||||||
|
</Admonition>
|
||||||
|
|
||||||
|
## Configuring Environment Variables in your .env file
|
||||||
|
|
||||||
|
Setting `LANGFLOW_STORE_ENVIRONMENT_VARIABLES` to `true` in your `.env` file (default) adds all variables in `LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT` to your user's Global Variables.
|
||||||
|
|
||||||
|
These variables are accessible like any other Global Variable.
|
||||||
|
|
||||||
|
<Admonition type="tip">
|
||||||
|
To prevent this behavior, set `LANGFLOW_STORE_ENVIRONMENT_VARIABLES` to `false` in your `.env` file.
|
||||||
|
</Admonition>
|
||||||
|
|
||||||
|
You can specify variables to get from the environment by listing them in `LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`.
|
||||||
|
|
||||||
|
Specify variables as a comma-separated list (e.g., _`"VARIABLE1, VARIABLE2"`_) or a JSON-encoded string (e.g., _`'["VARIABLE1", "VARIABLE2"]'`_).
|
||||||
|
|
||||||
|
The default list of variables includes:
|
||||||
|
|
||||||
|
- ANTHROPIC_API_KEY
|
||||||
|
- ASTRA_DB_API_ENDPOINT
|
||||||
|
- ASTRA_DB_APPLICATION_TOKEN
|
||||||
|
- AZURE_OPENAI_API_KEY
|
||||||
|
- AZURE_OPENAI_API_DEPLOYMENT_NAME
|
||||||
|
- AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
|
||||||
|
- AZURE_OPENAI_API_INSTANCE_NAME
|
||||||
|
- AZURE_OPENAI_API_VERSION
|
||||||
|
- COHERE_API_KEY
|
||||||
|
- GOOGLE_API_KEY
|
||||||
|
- GROQ_API_KEY
|
||||||
|
- HUGGINGFACEHUB_API_TOKEN
|
||||||
|
- OPENAI_API_KEY
|
||||||
|
- PINECONE_API_KEY
|
||||||
|
- SEARCHAPI_API_KEY
|
||||||
|
- SERPAPI_API_KEY
|
||||||
|
- UPSTASH_VECTOR_REST_URL
|
||||||
|
- UPSTASH_VECTOR_REST_TOKEN
|
||||||
|
- VECTARA_CUSTOMER_ID
|
||||||
|
- VECTARA_CORPUS_ID
|
||||||
|
- VECTARA_API_KEY
|
||||||
|
|
||||||
## Video
|
## Video
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|
||||||
import Admonition from "@theme/Admonition";
|
|
||||||
|
|
||||||
# Global Variables
|
|
||||||
|
|
||||||
## TLDR;
|
|
||||||
|
|
||||||
- Global Variables are reusable variables that can be accessed from any Text field in your project.
|
|
||||||
- To create a Global Variable, click on the 🌐 button in a Text field and then **+ Add New Variable**.
|
|
||||||
- Define the **Name**, **Type**, and **Value** of the variable.
|
|
||||||
- Click on **Save Variable** to create the variable.
|
|
||||||
- All Credential Global Variables are encrypted and cannot be accessed by anyone but you.
|
|
||||||
- Set _`LANGFLOW_STORE_ENVIRONMENT_VARIABLES`_ to _`true`_ in your `.env` file to add all variables in _`LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`_ to your user's Global Variables.
|
|
||||||
|
|
||||||
Global Variables are a really useful feature of Langflow.
|
|
||||||
They allow you to define reusable variables that can be accessed from any Text field in your project.
|
|
||||||
|
|
||||||
The first thing you need to do is find a **Text field** in a Component, so let's talk about what a Text field is.
|
|
||||||
|
|
||||||
## Text Fields
|
|
||||||
|
|
||||||
Text fields are the fields in a Component where you can write text but that does not allow you to open a Text Area.
|
|
||||||
|
|
||||||
The easiest way to find fields that are Text fields, though, is to look for fields that have a 🌐 button.
|
|
||||||
|
|
||||||
<ZoomableImage
|
|
||||||
alt="Docusaurus themed image"
|
|
||||||
sources={{
|
|
||||||
light: "img/ollama-gv.png",
|
|
||||||
dark: "img/ollama-gv.png",
|
|
||||||
}}
|
|
||||||
style={{ width: "50%" }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Creating a Global Variable
|
|
||||||
|
|
||||||
To create a Global Variable, you need to click on the 🌐 button in a Text field and that will open a dropdown showing your currently available variables and at the end of it **+ Add New Variable**.
|
|
||||||
|
|
||||||
<ZoomableImage
|
|
||||||
alt="Docusaurus themed image"
|
|
||||||
sources={{
|
|
||||||
light: "img/add-new-variable.png",
|
|
||||||
dark: "img/add-new-variable.png",
|
|
||||||
}}
|
|
||||||
style={{ width: "60%" }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
Click on **+ Add New Variable** and a window will open where you can define your new Global Variable.
|
|
||||||
|
|
||||||
In it, you can define the **Name** of the variable, the optional **Type** of the variable, and the **Value** of the variable.
|
|
||||||
|
|
||||||
The **Name** is the name that you will use to refer to the variable in your Text fields.
|
|
||||||
|
|
||||||
The **Type** is optional for now but will be used in the future to allow for more advanced features.
|
|
||||||
|
|
||||||
The **Value** is the value that the variable will have.
|
|
||||||
{/* say that all variables are encrypted */}
|
|
||||||
|
|
||||||
<Admonition type="warning">
|
|
||||||
All Credential Global Variables are encrypted and cannot be accessed by anyone
|
|
||||||
but you.
|
|
||||||
</Admonition>
|
|
||||||
|
|
||||||
<ZoomableImage
|
|
||||||
alt="Docusaurus themed image"
|
|
||||||
sources={{
|
|
||||||
light: "img/create-variable-window.png",
|
|
||||||
dark: "img/create-variable-window.png",
|
|
||||||
}}
|
|
||||||
style={{ width: "60%" }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
After you have defined your variable, click on **Save Variable** and your variable will be created.
|
|
||||||
|
|
||||||
After that, once you click on the 🌐 button in a Text field, you will see your new variable in the dropdown.
|
|
||||||
|
|
||||||
## Environment Variables
|
|
||||||
|
|
||||||
If you set _`LANGFLOW_STORE_ENVIRONMENT_VARIABLES`_ to _`true`_ (which is the default value) in your `.env` file, all variables in _`LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`_ will be added to your user's Global Variables.
|
|
||||||
|
|
||||||
All of these variables can be used in your project as any other Global Variable.
|
|
||||||
|
|
||||||
<Admonition type="tip">
|
|
||||||
You can set _`LANGFLOW_STORE_ENVIRONMENT_VARIABLES`_ to _`false`_ in your
|
|
||||||
`.env` file to prevent this behavior.
|
|
||||||
</Admonition>
|
|
||||||
|
|
||||||
You can also set _`LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`_ to a list of variables that you want to get from the environment.
|
|
||||||
|
|
||||||
The default list at the moment is:
|
|
||||||
|
|
||||||
- ANTHROPIC_API_KEY
|
|
||||||
- ASTRA_DB_API_ENDPOINT
|
|
||||||
- ASTRA_DB_APPLICATION_TOKEN
|
|
||||||
- AZURE_OPENAI_API_KEY
|
|
||||||
- AZURE_OPENAI_API_DEPLOYMENT_NAME
|
|
||||||
- AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
|
|
||||||
- AZURE_OPENAI_API_INSTANCE_NAME
|
|
||||||
- AZURE_OPENAI_API_VERSION
|
|
||||||
- COHERE_API_KEY
|
|
||||||
- GOOGLE_API_KEY
|
|
||||||
- GROQ_API_KEY
|
|
||||||
- HUGGINGFACEHUB_API_TOKEN
|
|
||||||
- OPENAI_API_KEY
|
|
||||||
- PINECONE_API_KEY
|
|
||||||
- SEARCHAPI_API_KEY
|
|
||||||
- SERPAPI_API_KEY
|
|
||||||
- UPSTASH_VECTOR_REST_URL
|
|
||||||
- UPSTASH_VECTOR_REST_TOKEN
|
|
||||||
- VECTARA_CUSTOMER_ID
|
|
||||||
- VECTARA_CORPUS_ID
|
|
||||||
- VECTARA_API_KEY
|
|
||||||
|
|
||||||
<Admonition type="tip">
|
|
||||||
Set _`LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT`_ as a comma-separated list
|
|
||||||
of variables (e.g. _`"VARIABLE1, VARIABLE2"`_) or as a JSON-encoded string
|
|
||||||
(e.g. _`'["VARIABLE1", "VARIABLE2"]'`_).
|
|
||||||
</Admonition>
|
|
||||||
|
|
@ -49,8 +49,8 @@ module.exports = {
|
||||||
label: "Core Components",
|
label: "Core Components",
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
items: [
|
items: [
|
||||||
"components/inputs",
|
"components/inputs-and-outputs",
|
||||||
"components/outputs",
|
"components/text-and-record",
|
||||||
"components/data",
|
"components/data",
|
||||||
"components/models",
|
"components/models",
|
||||||
"components/helpers",
|
"components/helpers",
|
||||||
|
|
@ -91,15 +91,12 @@ module.exports = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "category",
|
type: "category",
|
||||||
label: "Migration Guides",
|
label: "Migration",
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
items: [
|
items: [
|
||||||
"migration/possible-installation-issues",
|
"migration/possible-installation-issues",
|
||||||
"migration/migrating-to-one-point-zero",
|
"migration/migrating-to-one-point-zero",
|
||||||
"migration/inputs-and-outputs",
|
|
||||||
"migration/text-and-record",
|
|
||||||
"migration/compatibility",
|
"migration/compatibility",
|
||||||
"migration/global-variables",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue