diff --git a/docs/docs/administration/global-env.mdx b/docs/docs/administration/global-env.mdx index c23ca8dd1..ae5ff0fb4 100644 --- a/docs/docs/administration/global-env.mdx +++ b/docs/docs/administration/global-env.mdx @@ -1,35 +1,42 @@ +import ThemedImage from "@theme/ThemedImage"; +import useBaseUrl from "@docusaurus/useBaseUrl"; import ZoomableImage from "/src/theme/ZoomableImage.js"; -import Admonition from "@theme/Admonition"; 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**. -2. Select **Basic Prompting**. +## Creating and Adding a Global Variable -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: - 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`. - 3. In the **Value** field, paste your OpenAI API Key (`sk-...`). - 4. For the variable **Type**, select **Credential**. - 5. In the **Apply to Fields** field, select **OpenAI API Key** to apply this variable to all fields named **OpenAI API Key**. +Text fields are where you write text without opening a Text area, and are identified with the 🌐 icon. + +For example, to create an environment variable for the **OpenAI** component: + 1. In the **OpenAI API Key** text field, click the 🌐 button, then **Add New Variable**. + 2. Enter `openai_api_key` in the **Variable Name** field. + 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**. 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. - You can also create global variables in **Settings** > **Variables and - Secrets**. + You can also create global variables in **Settings** > **Variables and Secrets**. -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). +{/* All variables are encrypted */} + + + All Credential Global Variables are encrypted and accessible only by you. + + +## 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. + + + To prevent this behavior, set `LANGFLOW_STORE_ENVIRONMENT_VARIABLES` to `false` in your `.env` file. + + +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
- -## 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**. - - - -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 */} - - - All Credential Global Variables are encrypted and cannot be accessed by anyone - but you. - - - - -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. - - - You can set _`LANGFLOW_STORE_ENVIRONMENT_VARIABLES`_ to _`false`_ in your - `.env` file to prevent this behavior. - - -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 - - - 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"]'`_). - diff --git a/docs/sidebars.js b/docs/sidebars.js index d3f4f2671..b12111797 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -49,8 +49,8 @@ module.exports = { label: "Core Components", collapsed: false, items: [ - "components/inputs", - "components/outputs", + "components/inputs-and-outputs", + "components/text-and-record", "components/data", "components/models", "components/helpers", @@ -91,15 +91,12 @@ module.exports = { }, { type: "category", - label: "Migration Guides", + label: "Migration", collapsed: false, items: [ "migration/possible-installation-issues", "migration/migrating-to-one-point-zero", - "migration/inputs-and-outputs", - "migration/text-and-record", "migration/compatibility", - "migration/global-variables", ], }, {