From c371cbc22b444882a8139f33ff7423939048a711 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 15:21:24 -0400
Subject: [PATCH 01/15] combine-global-env-docs
---
docs/docs/administration/global-env.mdx | 87 +++++++++++++----
docs/docs/migration/global-variables.mdx | 118 -----------------------
docs/sidebars.js | 9 +-
3 files changed, 72 insertions(+), 142 deletions(-)
delete mode 100644 docs/docs/migration/global-variables.mdx
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",
],
},
{
From 4841cd9e66748103d8cc8ac960900d6df8e6af49 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 15:21:59 -0400
Subject: [PATCH 02/15] combine-input-and-output-docs
---
docs/docs/components/inputs-and-outputs.mdx | 161 ++++++++++++++++++++
docs/docs/components/inputs.mdx | 99 ------------
docs/docs/components/outputs.mdx | 34 -----
docs/docs/components/prompts.mdx | 25 ---
docs/docs/migration/inputs-and-outputs.mdx | 36 -----
5 files changed, 161 insertions(+), 194 deletions(-)
create mode 100644 docs/docs/components/inputs-and-outputs.mdx
delete mode 100644 docs/docs/components/inputs.mdx
delete mode 100644 docs/docs/components/outputs.mdx
delete mode 100644 docs/docs/components/prompts.mdx
delete mode 100644 docs/docs/migration/inputs-and-outputs.mdx
diff --git a/docs/docs/components/inputs-and-outputs.mdx b/docs/docs/components/inputs-and-outputs.mdx
new file mode 100644
index 000000000..daabc68eb
--- /dev/null
+++ b/docs/docs/components/inputs-and-outputs.mdx
@@ -0,0 +1,161 @@
+import Admonition from '@theme/Admonition';
+import ZoomableImage from "/src/theme/ZoomableImage.js";
+
+# Inputs and Outputs
+
+TL;DR: Inputs and Outputs are a category of components that are used to define where data comes in and out of your flow.
+They also dynamically change the Playground and can be renamed to facilitate building and maintaining your flows.
+
+## Inputs
+
+Inputs are components used to define where data enters your flow. They can receive data from the user, a database, or any other source that can be converted to Text or Record.
+
+The difference between Chat Input and other Input components is the output format, the number of configurable fields, and the way they are displayed in the Playground.
+
+Chat Input components can output `Text` or `Record`. When you want to pass the sender name or sender to the next component, use the `Record` output. To pass only the message, use the `Text` output, useful when saving the message to a database or memory system like Zep.
+
+You can find out more about Chat Input and other Inputs [here](#chat-input).
+
+### Chat Input
+
+This component collects user input from the chat.
+
+**Parameters**
+
+- **Sender Type:** Specifies the sender type. Defaults to `User`. Options are `Machine` and `User`.
+- **Sender Name:** Specifies the name of the sender. Defaults to `User`.
+- **Message:** Specifies the message text. It is a multiline text input.
+- **Session ID:** Specifies the session ID of the chat history. If provided, the message will be saved in the Message History.
+
+
+
+ If `As Record` is `true` and the `Message` is a `Record`, the data
+ of the `Record` will be updated with the `Sender`, `Sender Name`, and
+ `Session ID`.
+
+
+
+
+
+One significant capability of the Chat Input component is its ability to transform the Playground into a chat window. This feature is particularly valuable for scenarios requiring user input to initiate or influence the flow.
+
+
+
+### Text Input
+
+The **Text Input** component adds an **Input** field on the Playground. This enables you to define parameters while running and testing your flow.
+
+**Parameters**
+
+- **Value:** Specifies the text input value. This is where the user inputs text data that will be passed to the next component in the sequence. If no value is provided, it defaults to an empty string.
+- **Record Template:** Specifies how a `Record` should be converted into `Text`.
+
+The **Record Template** field is used to specify how a `Record` should be converted into `Text`. This is particularly useful when you want to extract specific information from a `Record` and pass it as text to the next component in the sequence.
+
+For example, if you have a `Record` with the following structure:
+
+```json
+{
+ "name": "John Doe",
+ "age": 30,
+ "email": "johndoe@email.com"
+}
+```
+
+A template with `Name: {name}, Age: {age}` will convert the `Record` into a text string of `Name: John Doe, Age: 30`.
+
+If you pass more than one `Record`, the text will be concatenated with a new line separator.
+
+
+
+## Outputs
+
+Outputs are components that are used to define where data comes out of your flow. They can be used to send data to the user, to the Playground, or to define how the data will be displayed in the Playground.
+
+The Chat Output works similarly to the Chat Input but does not have a field that allows for written input. It is used as an Output definition and can be used to send data to the user.
+
+You can find out more about it and the other Outputs [here](#chat-output).
+
+### Chat Output
+
+This component sends a message to the chat.
+
+**Parameters**
+
+- **Sender Type:** Specifies the sender type. Default is `"Machine"`. Options are `"Machine"` and `"User"`.
+
+- **Sender Name:** Specifies the sender's name. Default is `"AI"`.
+
+- **Session ID:** Specifies the session ID of the chat history. If provided, messages are saved in the Message History.
+
+- **Message:** Specifies the text of the message.
+
+
+
+ If `As Record` is `true` and the `Message` is a `Record`, the data in the `Record` is updated with the `Sender`, `Sender Name`, and `Session ID`.
+
+
+
+### Text Output
+
+This component displays text data to the user. It is useful when you want to show text without sending it to the chat.
+
+**Parameters**
+
+- **Value:** Specifies the text data to be displayed. Defaults to an empty string.
+
+
+The `TextOutput` component provides a simple way to display text data. It allows textual data to be visible in the chat window during your interaction flow.
+
+## Prompts
+
+A prompt is the input provided to a language model, consisting of multiple components and can be parameterized using prompt templates. A prompt template offers a reproducible method for generating prompts, enabling easy customization through input variables.
+
+### Prompt
+
+This component creates a prompt template with dynamic variables. This is useful for structuring prompts and passing dynamic data to a language model.
+
+**Parameters**
+
+- **Template:** The template for the prompt. This field allows you to create other fields dynamically by using curly brackets `{}`. For example, if you have a template like `Hello {name}, how are you?`, a new field called `name` will be created. Prompt variables can be created with any name inside curly brackets, e.g. `{variable_name}`.
+
+
+
+### PromptTemplate
+
+The `PromptTemplate` component enables users to create prompts and define variables that control how the model is instructed. Users can input a set of variables which the template uses to generate the prompt when a conversation starts.
+
+
+ After defining a variable in the prompt template, it acts as its own component
+ input. See [Prompt Customization](../administration/prompt-customization) for more details.
+
+
+- **template:** The template used to format an individual request.
\ No newline at end of file
diff --git a/docs/docs/components/inputs.mdx b/docs/docs/components/inputs.mdx
deleted file mode 100644
index 854f7fee3..000000000
--- a/docs/docs/components/inputs.mdx
+++ /dev/null
@@ -1,99 +0,0 @@
-import Admonition from '@theme/Admonition';
-import ZoomableImage from "/src/theme/ZoomableImage.js";
-
-# Inputs
-
-## Chat Input
-
-This component obtains user input from the chat.
-
-**Parameters**
-
-- **Sender Type:** Specifies the sender type. Defaults to `User`. Options are `Machine` and `User`.
-- **Sender Name:** Specifies the name of the sender. Defaults to `User`.
-- **Message:** Specifies the message text. It is a multiline text input.
-- **Session ID:** Specifies the session ID of the chat history. If provided, the message will be saved in the Message History.
-
-
-
- If `As Record` is `true` and the `Message` is a `Record`, the data
- of the `Record` will be updated with the `Sender`, `Sender Name`, and
- `Session ID`.
-
-
-
-
-
-One significant capability of the Chat Input component is its ability to transform the Playground into a chat window. This feature is particularly valuable for scenarios requiring user input to initiate or influence the flow.
-
-
-
----
-
-## Prompt
-
-This component creates a prompt template with dynamic variables. This is useful for structuring prompts and passing dynamic data to a language model.
-
-**Parameters**
-
-- **Template:** The template for the prompt. This field allows you to create other fields dynamically by using curly brackets `{}`. For example, if you have a template like `Hello {name}, how are you?`, a new field called `name` will be created. Prompt variables can be created with any name inside curly brackets, e.g. `{variable_name}`.
-
-
-
----
-
-## Text Input
-
-The **Text Input** component adds an **Input** field on the Playground. This enables you to define parameters while running and testing your flow.
-
-**Parameters**
-
-- **Value:** Specifies the text input value. This is where the user inputs text data that will be passed to the next component in the sequence. If no value is provided, it defaults to an empty string.
-- **Record Template:** Specifies how a `Record` should be converted into `Text`.
-
-The **Record Template** field is used to specify how a `Record` should be converted into `Text`. This is particularly useful when you want to extract specific information from a `Record` and pass it as text to the next component in the sequence.
-
-For example, if you have a `Record` with the following structure:
-
-```json
-{
- "name": "John Doe",
- "age": 30,
- "email": "johndoe@email.com"
-}
-```
-
-A template with `Name: {name}, Age: {age}` will convert the `Record` into a text string of `Name: John Doe, Age: 30`.
-
-If you pass more than one `Record`, the text will be concatenated with a new line separator.
-
-
-
diff --git a/docs/docs/components/outputs.mdx b/docs/docs/components/outputs.mdx
deleted file mode 100644
index a8947e60e..000000000
--- a/docs/docs/components/outputs.mdx
+++ /dev/null
@@ -1,34 +0,0 @@
-import Admonition from '@theme/Admonition';
-
-# Outputs
-
-## Chat Output
-
-This component sends a message to the chat.
-
-**Parameters**
-
-- **Sender Type:** Specifies the sender type. Default is `"Machine"`. Options are `"Machine"` and `"User"`.
-
-- **Sender Name:** Specifies the sender's name. Default is `"AI"`.
-
-- **Session ID:** Specifies the session ID of the chat history. If provided, messages are saved in the Message History.
-
-- **Message:** Specifies the text of the message.
-
-
-
- If `As Record` is `true` and the `Message` is a `Record`, the data in the `Record` is updated with the `Sender`, `Sender Name`, and `Session ID`.
-
-
-
-## Text Output
-
-This component displays text data to the user. It is useful when you want to show text without sending it to the chat.
-
-**Parameters**
-
-- **Value:** Specifies the text data to be displayed. Defaults to an empty string.
-
-
-The `TextOutput` component provides a simple way to display text data. It allows textual data to be visible in the chat window during your interaction flow.
diff --git a/docs/docs/components/prompts.mdx b/docs/docs/components/prompts.mdx
deleted file mode 100644
index 19fdedf11..000000000
--- a/docs/docs/components/prompts.mdx
+++ /dev/null
@@ -1,25 +0,0 @@
-import Admonition from "@theme/Admonition";
-
-# Prompts
-
-
-
- Thank you for your patience as we refine our documentation. It may
- still have some areas under development. Please share your feedback or report any issues to help us improve!
-
-
-
-A prompt is the input provided to a language model, consisting of multiple components and can be parameterized using prompt templates. A prompt template offers a reproducible method for generating prompts, enabling easy customization through input variables.
-
----
-
-### PromptTemplate
-
-The `PromptTemplate` component enables users to create prompts and define variables that control how the model is instructed. Users can input a set of variables which the template uses to generate the prompt when a conversation starts.
-
-
- After defining a variable in the prompt template, it acts as its own component
- input. See [Prompt Customization](../administration/prompt-customization) for more details.
-
-
-- **template:** The template used to format an individual request.
diff --git a/docs/docs/migration/inputs-and-outputs.mdx b/docs/docs/migration/inputs-and-outputs.mdx
deleted file mode 100644
index 1e1745347..000000000
--- a/docs/docs/migration/inputs-and-outputs.mdx
+++ /dev/null
@@ -1,36 +0,0 @@
-# Inputs and Outputs
-
-TL;DR: Inputs and Outputs are a category of components that are used to define where data comes in and out of your flow. They also
-dynamically change the Playground and can be renamed to make it easier to build and maintain your flows.
-
-## Introduction
-
-Langflow 1.0 introduces new categories of components called Inputs and Outputs. They are used to make it easier to understand and interact with your flows.
-
-Let's start with what they have in common:
-
-- Components in these categories connect to components that have Text or Record inputs or outputs. Some can connect to both but you have to pick what type of data you want to output or input.
-- They can be renamed to help you identify them more easily in the Playground and while using the API.
-- They dynamically change the Playground to make it easier to understand and interact with your flows.
-
-Native Langflow Components were created to be powerful tools that work around Langflow's features. They are designed to be easy to use and understand, and to help you build your flows faster.
-
-Let's dive into Inputs and Outputs.
-
-## Inputs
-
-Inputs are components that are used to define where data comes into your flow. They can be used to receive data from the user, from a database, or from any other source that can be converted to Text or Record.
-
-The difference between Chat Input and other Input components is the format of the output, the number of configurable fields, and the way they are displayed in the Playground.
-
-Chat Input components can output Text or Record. When you want to pass the sender name, or sender to the next component, you can use the Record output, and when you want to pass the message only you can use the Text output. This is useful when saving the message to a database or a memory system like Zep.
-
-You can find out more about it and the other Inputs [here](../components/inputs).
-
-## Outputs
-
-Outputs are components that are used to define where data comes out of your flow. They can be used to send data to the user, to the Playground, or to define how the data will be displayed in the Playground.
-
-The Chat Output works similarly to the Chat Input but does not have a field that allows for written input. It is used as an Output definition and can be used to send data to the user.
-
-You can find out more about it and the other Outputs [here](../components/outputs).
From 8ab21e8ced6fffd86451f5e8cc4bbded5b24d488 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:21:07 -0400
Subject: [PATCH 03/15] text-and-record
---
docs/docs/components/text-and-record.mdx | 44 ++++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 docs/docs/components/text-and-record.mdx
diff --git a/docs/docs/components/text-and-record.mdx b/docs/docs/components/text-and-record.mdx
new file mode 100644
index 000000000..a83a9df04
--- /dev/null
+++ b/docs/docs/components/text-and-record.mdx
@@ -0,0 +1,44 @@
+# Text and Record
+
+In Langflow 1.0, we added two main input and output types: Text and Record. Text is a simple string input and output type, while Record is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
+
+We've created a few components to help you work with these types. Let's see how a few of them work.
+
+### Records To Text
+
+This is a component that takes in Records and outputs a Text. It does this using a template string and concatenating the values of the Record, one per line.
+
+If we have the following Records:
+
+```json
+{
+ "sender_name": "Alice",
+ "message": "Hello!"
+}
+{
+ "sender_name": "John",
+ "message": "Hi!"
+}
+
+And the template string is: _`{sender_name}: {message}`_
+
+```
+Alice: Hello!
+John: Hi!
+```
+
+### Create Record
+
+This component allows you to create a Record from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15). Once you've picked that number you'll need to write the name of the Key and can pass Text values from other components to it.
+
+### Documents To Records
+
+This component takes in a LangChain Document and outputs a Record. It does this by extracting the page_content and the metadata from the Document and adding them to the Record as text and data respectively.
+
+## Why is this useful?
+
+The idea was to create a unified way to work with complex data in Langflow and to make it easier to work with data that is not just a simple string. This way you can create more complex workflows and use the data in more ways.
+
+## What's next?
+
+We are planning to integrate an array of modalities to Langflow, such as images, audio, and video. This will allow you to create even more complex workflows and use cases. Stay tuned for more updates! 🚀
From 689de35d14161bf93af0790f145a7e107a588c2e Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:21:27 -0400
Subject: [PATCH 04/15] fix-link
---
docs/docs/migration/migrating-to-one-point-zero.mdx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/docs/migration/migrating-to-one-point-zero.mdx b/docs/docs/migration/migrating-to-one-point-zero.mdx
index 827f0e118..5df2c5b3d 100644
--- a/docs/docs/migration/migrating-to-one-point-zero.mdx
+++ b/docs/docs/migration/migrating-to-one-point-zero.mdx
@@ -119,7 +119,7 @@ Things got a whole lot easier. You can now pass tweaks and inputs in the API by
Global Variables can be used in any Text Field across your projects. Learn how to define and utilize Global Variables to streamline your workflow.
-[Learn more about Global Variables](../migration/global-variables)
+[Learn more about Global Variables](../administration/global-env.mdx)
## Experimental Components
From 9a515e7f8e8fba3bdada972b9ff6171f29ce1958 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:21:40 -0400
Subject: [PATCH 05/15] move-doc
---
docs/docs/migration/text-and-record.mdx | 45 -------------------------
1 file changed, 45 deletions(-)
delete mode 100644 docs/docs/migration/text-and-record.mdx
diff --git a/docs/docs/migration/text-and-record.mdx b/docs/docs/migration/text-and-record.mdx
deleted file mode 100644
index cdfb26b6c..000000000
--- a/docs/docs/migration/text-and-record.mdx
+++ /dev/null
@@ -1,45 +0,0 @@
-# Text and Record
-
-In Langflow 1.0 we added two main input and output types: Text and Record. Text is a simple string input and output type, while Record is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
-
-We've created a few components to help you work with these types. Let's see how a few of them work.
-
-### Records To Text
-
-This is a Component that takes in Records and outputs a Text. It does this using a template string and concatenating the values of the Record, one per line.
-
-If we have the following Records:
-
-```json
-{
- "sender_name": "Alice",
- "message": "Hello!"
-}
-{
- "sender_name": "John",
- "message": "Hi!"
-}
-```
-
-And the template string is: _`{sender_name}: {message}`_
-
-```
-Alice: Hello!
-John: Hi!
-```
-
-### Create Record
-
-This Component allows you to create a Record from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15 😅). Once you've picked that number you'll need to write the name of the Key and can pass Text values from other components to it.
-
-### Documents To Records
-
-This Component takes in a [LangChain](https://langchain.com) Document and outputs a Record. It does this by extracting the _`page_content`_ and the _`metadata`_ from the Document and adding them to the Record as _`text`_ and _`data`_ respectively.
-
-## Why is this useful?
-
-The idea was to create a unified way to work with complex data in Langflow, and to make it easier to work with data that is not just a simple string. This way you can create more complex workflows and use the data in more ways.
-
-## What's next?
-
-We are planning to integrate an array of modalities to Langflow, such as images, audio, and video. This will allow you to create even more complex workflows and use cases. Stay tuned for more updates! 🚀
From f74e0f0b8013f53d073af8f71838213eae104d91 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:21:44 -0400
Subject: [PATCH 06/15] fix-links
---
docs/docs/components/vector-stores.mdx | 2 +-
docs/docs/whats-new/a-new-chapter-langflow.mdx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/docs/components/vector-stores.mdx b/docs/docs/components/vector-stores.mdx
index 7e21f1021..6072abe29 100644
--- a/docs/docs/components/vector-stores.mdx
+++ b/docs/docs/components/vector-stores.mdx
@@ -1,6 +1,6 @@
import Admonition from "@theme/Admonition";
-# Vector Stores Documentation
+# Vector Stores
### Astra DB
diff --git a/docs/docs/whats-new/a-new-chapter-langflow.mdx b/docs/docs/whats-new/a-new-chapter-langflow.mdx
index 3ff74ffb2..bdc0f178b 100644
--- a/docs/docs/whats-new/a-new-chapter-langflow.mdx
+++ b/docs/docs/whats-new/a-new-chapter-langflow.mdx
@@ -41,7 +41,7 @@ By having a clear definition of Inputs and Outputs, we could build the experienc
When building a project testing and debugging is crucial. The Playground is a tool that changes dynamically based on the Inputs and Outputs you defined in your project.
For example, let's say you are building a simple RAG application. Generally, you have an Input, some references that come from a Vector Store Search, a Prompt and the answer.
-Now, you could plug the output of your Prompt into a [Text Output](../components/outputs#Text-Output), rename that to "Prompt Result" and see the output of your Prompt in the Playground.
+Now, you could plug the output of your Prompt into a [Text Output](../components/inputs-and-outputs), rename that to "Prompt Result" and see the output of your Prompt in the Playground.
{/* Add image here of the described above */}
From 0b1a4b42327980f01f7135ab8b3a49972a6ad148 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:28:44 -0400
Subject: [PATCH 07/15] cleanup
---
docs/docs/components/text-and-record.mdx | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/docs/docs/components/text-and-record.mdx b/docs/docs/components/text-and-record.mdx
index a83a9df04..c9fa06de3 100644
--- a/docs/docs/components/text-and-record.mdx
+++ b/docs/docs/components/text-and-record.mdx
@@ -1,12 +1,14 @@
# Text and Record
-In Langflow 1.0, we added two main input and output types: Text and Record. Text is a simple string input and output type, while Record is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
+In Langflow 1.0, we added two main input and output types: `Text` and `Record`.
+
+`Text` is a simple string input and output type, while ``Record`` is a structure very similar to a dictionary in Python. It is a key-value pair data structure.
We've created a few components to help you work with these types. Let's see how a few of them work.
-### Records To Text
+## Records To Text
-This is a component that takes in Records and outputs a Text. It does this using a template string and concatenating the values of the Record, one per line.
+This is a component that takes in Records and outputs a `Text`. It does this using a template string and concatenating the values of the `Record`, one per line.
If we have the following Records:
@@ -19,21 +21,24 @@ If we have the following Records:
"sender_name": "John",
"message": "Hi!"
}
+```
And the template string is: _`{sender_name}: {message}`_
+The output is:
+
```
Alice: Hello!
John: Hi!
```
-### Create Record
+## Create Record
-This component allows you to create a Record from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15). Once you've picked that number you'll need to write the name of the Key and can pass Text values from other components to it.
+This component allows you to create a `Record` from a number of inputs. You can add as many key-value pairs as you want (as long as it is less than 15). Once you've picked that number you'll need to write the name of the Key and can pass `Text` values from other components to it.
-### Documents To Records
+## Documents To Records
-This component takes in a LangChain Document and outputs a Record. It does this by extracting the page_content and the metadata from the Document and adding them to the Record as text and data respectively.
+This component takes in a LangChain `Document` and outputs a `Record`. It does this by extracting the `page_content` and the `metadata` from the `Document` and adding them to the `Record` as text and data respectively.
## Why is this useful?
From 9fc769172382a4f4b792bfa0322f4d47dcc75685 Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:28:50 -0400
Subject: [PATCH 08/15] remove-empty-files
---
docs/docs/migration/api.mdx | 0
docs/docs/migration/component-status-and-data-passing.mdx | 0
docs/docs/migration/connecting-output-components.mdx | 0
docs/docs/migration/custom-component.mdx | 0
docs/docs/migration/experimental-components.mdx | 0
docs/docs/migration/flow-of-data.mdx | 0
docs/docs/migration/multiple-flows.mdx | 0
docs/docs/migration/new-categories-and-components.mdx | 0
docs/docs/migration/passing-tweaks-and-inputs.mdx | 0
docs/docs/migration/renaming-and-editing-components.mdx | 0
docs/docs/migration/sidebar-and-interaction-panel.mdx | 0
docs/docs/migration/state-management.mdx | 0
docs/docs/migration/supported-frameworks.mdx | 0
13 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 docs/docs/migration/api.mdx
delete mode 100644 docs/docs/migration/component-status-and-data-passing.mdx
delete mode 100644 docs/docs/migration/connecting-output-components.mdx
delete mode 100644 docs/docs/migration/custom-component.mdx
delete mode 100644 docs/docs/migration/experimental-components.mdx
delete mode 100644 docs/docs/migration/flow-of-data.mdx
delete mode 100644 docs/docs/migration/multiple-flows.mdx
delete mode 100644 docs/docs/migration/new-categories-and-components.mdx
delete mode 100644 docs/docs/migration/passing-tweaks-and-inputs.mdx
delete mode 100644 docs/docs/migration/renaming-and-editing-components.mdx
delete mode 100644 docs/docs/migration/sidebar-and-interaction-panel.mdx
delete mode 100644 docs/docs/migration/state-management.mdx
delete mode 100644 docs/docs/migration/supported-frameworks.mdx
diff --git a/docs/docs/migration/api.mdx b/docs/docs/migration/api.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/component-status-and-data-passing.mdx b/docs/docs/migration/component-status-and-data-passing.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/connecting-output-components.mdx b/docs/docs/migration/connecting-output-components.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/custom-component.mdx b/docs/docs/migration/custom-component.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/experimental-components.mdx b/docs/docs/migration/experimental-components.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/flow-of-data.mdx b/docs/docs/migration/flow-of-data.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/multiple-flows.mdx b/docs/docs/migration/multiple-flows.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/new-categories-and-components.mdx b/docs/docs/migration/new-categories-and-components.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/passing-tweaks-and-inputs.mdx b/docs/docs/migration/passing-tweaks-and-inputs.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/renaming-and-editing-components.mdx b/docs/docs/migration/renaming-and-editing-components.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/sidebar-and-interaction-panel.mdx b/docs/docs/migration/sidebar-and-interaction-panel.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/state-management.mdx b/docs/docs/migration/state-management.mdx
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/migration/supported-frameworks.mdx b/docs/docs/migration/supported-frameworks.mdx
deleted file mode 100644
index e69de29bb..000000000
From f1ef45e41471a42b3d479a91feb6bf72692135be Mon Sep 17 00:00:00 2001
From: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
Date: Tue, 4 Jun 2024 16:37:02 -0400
Subject: [PATCH 09/15] fix-links
---
docs/docs/migration/migrating-to-one-point-zero.mdx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/docs/migration/migrating-to-one-point-zero.mdx b/docs/docs/migration/migrating-to-one-point-zero.mdx
index 5df2c5b3d..973393606 100644
--- a/docs/docs/migration/migrating-to-one-point-zero.mdx
+++ b/docs/docs/migration/migrating-to-one-point-zero.mdx
@@ -41,7 +41,7 @@ We have a special channel in our Discord server dedicated to Langflow 1.0 migrat
Langflow 1.0 introduces adds the concept of Inputs and Outputs to flows, allowing a clear definition of the data flow between components. Discover how to use Inputs and Outputs to pass data between components and create more dynamic flows.
-[Learn more about Inputs and Outputs of Components](../migration/inputs-and-outputs)
+[Learn more about Inputs and Outputs of Components](../components/inputs-and-outputs)
## To Compose or Not to Compose: the choice is yours
@@ -71,7 +71,7 @@ Langflow 1.0 introduces many new native categories, including Inputs, Outputs, H
With the introduction of Text and Record types connections between Components are more intuitive and easier to understand. This is the first step in a series of improvements to the way you interact with Langflow. Learn how to use Text, and Record and how they help you build better flows.
-[Learn more about Text and Record](../migration/text-and-record)
+[Learn more about Text and Record](../components/text-and-record)
## CustomComponent for All Components
From 6addb9636c98f116b50f13e6472a73aace5b606e Mon Sep 17 00:00:00 2001
From: mojunneng <307112505@qq.com>
Date: Wed, 5 Jun 2024 11:50:57 +0800
Subject: [PATCH 10/15] Update README and add Chinese README.
---
README.md | 5 ++
README.zh_CN.md | 171 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 176 insertions(+)
create mode 100644 README.zh_CN.md
diff --git a/README.md b/README.md
index 3c29e83e2..649186a00 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,11 @@
+
+

+

+
+
diff --git a/README.zh_CN.md b/README.zh_CN.md
new file mode 100644
index 000000000..d2c28d713
--- /dev/null
+++ b/README.zh_CN.md
@@ -0,0 +1,171 @@
+
+
+# [](https://www.langflow.org)
+
+
+ 一种用于构建多智能体和RAG应用的可视化框架
+
+
+ 开源、Python驱动、完全可定制、大模型且不依赖于特定的向量存储
+
+
+
+ 文档 -
+ 加入我们的Discord社区 -
+ 在X上关注我们 -
+ 在线体验
+
+
+
+
+
+
+
+
+
+
+
+
+

+

+
+
+
+
+
+
+# 📝 目录
+
+- [📝 目录](#-目录)
+- [📦 开始](#-开始)
+- [🎨 创建工作流](#-创建工作流)
+- [部署](#部署)
+ - [在Google Cloud Platform上部署Langflow](#在google-cloud-platform上部署langflow)
+ - [在Railway上部署](#在railway上部署)
+ - [在Render上部署](#在render上部署)
+- [🖥️ 命令行界面 (CLI)](#️-命令行界面-cli)
+ - [用法](#用法)
+ - [环境变量](#环境变量)
+- [👋 贡献](#-贡献)
+- [🌟 贡献者](#-贡献者)
+- [📄 许可证](#-许可证)
+
+# 📦 开始
+
+使用 pip 安装 Langflow:
+
+```shell
+# 确保您的系统已经安装上>=Python 3.10
+# 安装Langflow预发布版本
+python -m pip install langflow --pre --force-reinstall
+
+# 安装Langflow稳定版本
+python -m pip install langflow -U
+```
+
+然后运行Langflow:
+
+```shell
+python -m langflow run
+```
+
+您可以在[HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview)中在线体验 Langflow,也可以使用该链接[克隆空间](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true),在几分钟内创建您自己的 Langflow 运行工作空间。
+
+# 🎨 创建工作流
+
+使用 Langflow 来创建工作流非常简单。只需从侧边栏拖动组件到画布上,然后连接组件即可开始构建应用程序。
+
+您可以通过编辑提示参数、将组件分组到单个高级组件中以及构建您自己的自定义组件来展开探索。
+
+完成后,可以将工作流导出为 JSON 文件。
+
+然后使用以下脚本加载工作流:
+
+```python
+from langflow.load import run_flow_from_json
+
+results = run_flow_from_json("path/to/flow.json", input_value="Hello, World!")
+```
+# 部署
+
+## 在Google Cloud Platform上部署Langflow
+
+请按照我们的分步指南使用 Google Cloud Shell 在 Google Cloud Platform (GCP) 上部署 Langflow。该指南在 [**Langflow in Google Cloud Platform**](GCP_DEPLOYMENT.md) 文档中提供。
+
+或者,点击下面的 "Open in Cloud Shell" 按钮,启动 Google Cloud Shell,克隆 Langflow 仓库,并开始一个互动教程,该教程将指导您设置必要的资源并在 GCP 项目中部署 Langflow。
+
+[](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/langflow-ai/langflow&working_dir=scripts/gcp&shellonly=true&tutorial=walkthroughtutorial_spot.md)
+
+## 在Railway上部署
+
+使用此模板在 Railway 上部署 Langflow 1.0 预览版:
+
+[](https://railway.app/template/UsJ1uB?referralCode=MnPSdg)
+
+或者使用此模板部署 Langflow 0.6.x:
+
+[](https://railway.app/template/JMXEWp?referralCode=MnPSdg)
+
+## 在Render上部署
+
+
+
+
+
+# 🖥️ 命令行界面 (CLI)
+
+Langflow提供了一个命令行界面以便于平台的管理和配置。
+
+## 用法
+
+您可以使用以下命令运行Langflow:
+
+```shell
+langflow run [OPTIONS]
+```
+
+命令行参数的详细说明:
+
+- `--help`: 显示所有可用参数。
+- `--host`: 定义绑定服务器的主机host参数,可以使用 LANGFLOW_HOST 环境变量设置,默认值为 127.0.0.1。
+- `--workers`: 设置工作进程的数量,可以使用 LANGFLOW_WORKERS 环境变量设置,默认值为 1。
+- `--timeout`: 设置工作进程的超时时间(秒),默认值为 60。
+- `--port`: 设置服务监听的端口,可以使用 LANGFLOW_PORT 环境变量设置,默认值为 7860。
+- `--config`: 定义配置文件的路径,默认值为 config.yaml。
+- `--env-file`: 指定包含环境变量的 .env 文件路径,默认值为 .env。
+- `--log-level`: 定义日志记录级别,可以使用 LANGFLOW_LOG_LEVEL 环境变量设置,默认值为 critical。
+- `--components-path`: 指定包含自定义组件的目录路径,可以使用 LANGFLOW_COMPONENTS_PATH 环境变量设置,默认值为 langflow/components。
+- `--log-file`: 指定日志文件的路径,可以使用 LANGFLOW_LOG_FILE 环境变量设置,默认值为 logs/langflow.log。
+- `--cache`: 选择要使用的缓存类型,可选项为 InMemoryCache 和 SQLiteCache,可以使用 LANGFLOW_LANGCHAIN_CACHE 环境变量设置,默认值为 SQLiteCache。
+- `--dev/--no-dev`: 切换开发/非开发模式,默认值为 no-dev即非开发模式。
+- `--path`: 指定包含前端构建文件的目录路径,此参数仅用于开发目的,可以使用 LANGFLOW_FRONTEND_PATH 环境变量设置。
+- `--open-browser/--no-open-browser`: 切换启动服务器后是否打开浏览器,可以使用 LANGFLOW_OPEN_BROWSER 环境变量设置,默认值为 open-browser即启动后打开浏览器。
+- `--remove-api-keys/--no-remove-api-keys`: 切换是否从数据库中保存的项目中移除 API 密钥,可以使用 LANGFLOW_REMOVE_API_KEYS 环境变量设置,默认值为 no-remove-api-keys。
+- `--install-completion [bash|zsh|fish|powershell|pwsh]`: 为指定的 shell 安装自动补全。
+- `--show-completion [bash|zsh|fish|powershell|pwsh]`: 显示指定 shell 的自动补全,使您可以复制或自定义安装。
+- `--backend-only`: 此参数默认为 False,允许仅运行后端服务器而不运行前端,也可以使用 LANGFLOW_BACKEND_ONLY 环境变量设置。
+- `--store`: 此参数默认为 True,启用存储功能,使用 --no-store 可禁用它,可以使用 LANGFLOW_STORE 环境变量配置。
+
+这些参数对于需要定制 Langflow 行为的用户尤其重要,特别是在开发或者特殊部署场景中。
+
+### 环境变量
+
+您可以使用环境变量配置许多 CLI 参数选项。这些变量可以在操作系统中导出,或添加到 .env 文件中,并使用 --env-file 参数加载。
+
+项目中包含一个名为 .env.example 的示例 .env 文件。将此文件复制为新文件 .env,并用实际设置值替换示例值。如果同时在操作系统和 .env 文件中设置值,则 .env 设置优先。
+
+# 👋 贡献
+
+我们欢迎各级开发者为我们的 GitHub 开源项目做出贡献,并帮助 Langflow 更加易用,如果您想参与贡献,请查看我们的贡献指南 [contributing guidelines](./CONTRIBUTING.md) 。
+
+---
+
+[](https://star-history.com/#langflow-ai/langflow&Date)
+
+# 🌟 贡献者
+
+[](https://github.com/langflow-ai/langflow/graphs/contributors)
+
+# 📄 许可证
+
+Langflow 以 MIT 许可证发布。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。
From 4365cf31e2426be542fc3b1c3b361a3e9a1f671a Mon Sep 17 00:00:00 2001
From: mojunneng <307112505@qq.com>
Date: Wed, 5 Jun 2024 15:00:18 +0800
Subject: [PATCH 11/15] Update Chinese README.
---
README.zh_CN.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.zh_CN.md b/README.zh_CN.md
index d2c28d713..4259286c8 100644
--- a/README.zh_CN.md
+++ b/README.zh_CN.md
@@ -37,7 +37,7 @@
# 📝 目录
- [📝 目录](#-目录)
-- [📦 开始](#-开始)
+- [📦 快速开始](#-快速开始)
- [🎨 创建工作流](#-创建工作流)
- [部署](#部署)
- [在Google Cloud Platform上部署Langflow](#在google-cloud-platform上部署langflow)
@@ -50,7 +50,7 @@
- [🌟 贡献者](#-贡献者)
- [📄 许可证](#-许可证)
-# 📦 开始
+# 📦 快速开始
使用 pip 安装 Langflow:
From 6096c8b73f26ebc054b791004463c13b70707516 Mon Sep 17 00:00:00 2001
From: cristhianzl
Date: Wed, 5 Jun 2024 10:56:47 -0300
Subject: [PATCH 12/15] =?UTF-8?q?=F0=9F=94=A7=20(playwright.config.ts):=20?=
=?UTF-8?q?reduce=20workers=20to=201=20for=20CI=20to=20avoid=20resource=20?=
=?UTF-8?q?contention?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/frontend/playwright.config.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/frontend/playwright.config.ts b/src/frontend/playwright.config.ts
index cf7d59472..eeb9497ae 100644
--- a/src/frontend/playwright.config.ts
+++ b/src/frontend/playwright.config.ts
@@ -21,7 +21,7 @@ export default defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
- workers: 5,
+ workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
timeout: 120 * 1000,
// reporter: [
From 80f6249a5029dcbf083826733362a36352d74d92 Mon Sep 17 00:00:00 2001
From: Gabriel Luiz Freitas Almeida
Date: Wed, 5 Jun 2024 10:30:54 -0700
Subject: [PATCH 13/15] =?UTF-8?q?=F0=9F=93=9D=20(utils.py):=20Add=20get=5F?=
=?UTF-8?q?flow=20function=20and=20update=20Python=20API=20code=20(#2075)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: Add upload_file function for file uploading
This commit adds a new function called `upload_file` to the `load/utils.py` module. This function allows users to upload a file to the storage service and returns the file path. It takes in parameters such as `file_path`, `host`, `port`, `flow_id`, `components`, and `tweaks`. The function makes use of the `upload` function to send a POST request to the storage service API and handle the response.
The `upload_file` function is useful for scenarios where users need to upload files to the flow and associate them with specific components. It provides flexibility by allowing users to specify the components that require the file and any tweaks that should be applied to the file.
This feature enhances the functionality of the codebase and improves the overall user experience when working with file uploads in the application.
* 📝 (utils.py): Add get_flow function to retrieve flow details from Langflow
📝 (utils.py): Remove unused 'port' parameter from upload functions
📝 (utils.py): Update upload function to use Langflow host URL and remove port parameter
📝 (utils.py): Update upload_file function to use Langflow host URL and port number
📝 (utils.py): Update function descriptions and variable names for clarity and consistency
📝 (model.py): Remove 'folder_id' field from FlowBase model in langflow services database
* 📝 (load/__init__.py): add get_flow function to __all__ list to expose it to other modules
📝 (utils.py): fix docstring formatting issue in get_flow function
* make getPythonApiCode receive endpointname
---
src/backend/base/langflow/load/__init__.py | 5 +-
src/backend/base/langflow/load/utils.py | 89 +++++++++++++++++++
.../services/database/models/flow/model.py | 1 -
.../apiModal/utils/get-python-api-code.tsx | 69 +++++++++++---
.../src/modals/apiModal/views/index.tsx | 23 +++--
5 files changed, 165 insertions(+), 22 deletions(-)
create mode 100644 src/backend/base/langflow/load/utils.py
diff --git a/src/backend/base/langflow/load/__init__.py b/src/backend/base/langflow/load/__init__.py
index 2002e8bb1..59dbdf6e0 100644
--- a/src/backend/base/langflow/load/__init__.py
+++ b/src/backend/base/langflow/load/__init__.py
@@ -1,3 +1,4 @@
-from .load import load_flow_from_json, run_flow_from_json # noqa: F401
+from .load import load_flow_from_json, run_flow_from_json
+from .utils import upload_file, get_flow
-__all__ = ["load_flow_from_json", "run_flow_from_json"]
+__all__ = ["load_flow_from_json", "run_flow_from_json", "upload_file", "get_flow"]
diff --git a/src/backend/base/langflow/load/utils.py b/src/backend/base/langflow/load/utils.py
new file mode 100644
index 000000000..9c2918e91
--- /dev/null
+++ b/src/backend/base/langflow/load/utils.py
@@ -0,0 +1,89 @@
+import httpx
+
+from langflow.services.database.models.flow.model import FlowBase
+
+
+def upload(file_path, host, flow_id):
+ """
+ Upload a file to Langflow and return the file path.
+
+ Args:
+ file_path (str): The path to the file to be uploaded.
+ host (str): The host URL of Langflow.
+ flow_id (UUID): The ID of the flow to which the file belongs.
+
+ Returns:
+ dict: A dictionary containing the file path.
+
+ Raises:
+ Exception: If an error occurs during the upload process.
+ """
+ try:
+ url = f"{host}/api/v1/upload/{flow_id}"
+ response = httpx.post(url, files={"file": open(file_path, "rb")})
+ if response.status_code == 200:
+ return response.json()
+ else:
+ raise Exception(f"Error uploading file: {response.status_code}")
+ except Exception as e:
+ raise Exception(f"Error uploading file: {e}")
+
+
+def upload_file(file_path, host, flow_id, components, tweaks={}):
+ """
+ Upload a file to Langflow and return the file path.
+
+ Args:
+ file_path (str): The path to the file to be uploaded.
+ host (str): The host URL of Langflow.
+ port (int): The port number of Langflow.
+ flow_id (UUID): The ID of the flow to which the file belongs.
+ components (str): List of component IDs or names that need the file.
+ tweaks (dict): A dictionary of tweaks to be applied to the file.
+
+ Returns:
+ dict: A dictionary containing the file path and any tweaks that were applied.
+
+ Raises:
+ Exception: If an error occurs during the upload process.
+ """
+ try:
+ response = upload(file_path, host, flow_id)
+ if response["file_path"]:
+ for component in components:
+ if isinstance(component, str):
+ tweaks[component] = {"file_path": response["file_path"]}
+ else:
+ raise ValueError(f"Component ID or name must be a string. Got {type(component)}")
+ return tweaks
+ else:
+ raise ValueError("Error uploading file")
+ except Exception as e:
+ raise ValueError(f"Error uploading file: {e}")
+
+
+def get_flow(url: str, flow_id: str):
+ """Get the details of a flow from Langflow.
+
+ Args:
+ url (str): The host URL of Langflow.
+ port (int): The port number of Langflow.
+ flow_id (UUID): The ID of the flow to retrieve.
+
+ Returns:
+ dict: A dictionary containing the details of the flow.
+
+ Raises:
+ Exception: If an error occurs during the retrieval process.
+ """
+ try:
+ flow_url = f"{url}/api/v1/flows/{flow_id}"
+ response = httpx.get(flow_url)
+ if response.status_code == 200:
+ json_response = response.json()
+ flow = FlowBase(**json_response).model_dump()
+ return flow
+ else:
+ raise Exception(f"Error retrieving flow: {response.status_code}")
+ except Exception as e:
+ raise Exception(f"Error retrieving flow: {e}")
diff --git a/src/backend/base/langflow/services/database/models/flow/model.py b/src/backend/base/langflow/services/database/models/flow/model.py
index 4de1e0bc8..7727c7b86 100644
--- a/src/backend/base/langflow/services/database/models/flow/model.py
+++ b/src/backend/base/langflow/services/database/models/flow/model.py
@@ -29,7 +29,6 @@ class FlowBase(SQLModel):
is_component: Optional[bool] = Field(default=False, nullable=True)
updated_at: Optional[datetime] = Field(default_factory=lambda: datetime.now(timezone.utc), nullable=True)
webhook: Optional[bool] = Field(default=False, nullable=True, description="Can be used on the webhook endpoint")
- folder_id: Optional[UUID] = Field(default=None, nullable=True)
endpoint_name: Optional[str] = Field(default=None, nullable=True, index=True)
@field_validator("endpoint_name")
diff --git a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx
index a25e993fc..e51403acb 100644
--- a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx
+++ b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx
@@ -9,19 +9,35 @@ export default function getPythonApiCode(
flowId: string,
isAuth: boolean,
tweaksBuildedObject,
+ endpointName?: string
): string {
const tweaksObject = tweaksBuildedObject[0];
- return `import requests
+ return `import argparse
+import json
+from argparse import RawTextHelpFormatter
+import requests
from typing import Optional
+import warnings
+try:
+ from langflow.load import upload_file
+except ImportError:
+ warnings.warn("Langflow provides a function to help you upload files to the flow. Please install langflow to use it.")
+ upload_file = None
BASE_API_URL = "${window.location.protocol}//${window.location.host}/api/v1/run"
FLOW_ID = "${flowId}"
+ENDPOINT = "${endpointName || ""}" ${
+ endpointName
+ ? `# The endpoint name of the flow`
+ : `# You can set a specific endpoint name in the flow settings`
+ }
+
# You can tweak the flow by adding a tweaks dictionary
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
TWEAKS = ${JSON.stringify(tweaksObject, null, 2)}
def run_flow(message: str,
- flow_id: str,
+ endpoint: str,
output_type: str = "chat",
input_type: str = "chat",
tweaks: Optional[dict] = None,
@@ -30,11 +46,11 @@ def run_flow(message: str,
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 endpoint: The ID or the endpoint name of the flow
:param tweaks: Optional tweaks to customize the flow
:return: The JSON response from the flow
"""
- api_url = f"{BASE_API_URL}/{flow_id}"
+ api_url = f"{BASE_API_URL}/{endpoint}"
payload = {
"input_value": message,
@@ -49,10 +65,43 @@ def run_flow(message: str,
response = requests.post(api_url, json=payload, headers=headers)
return response.json()
-# Setup any tweaks you want to apply to the flow
-message = "message"
-${!isAuth ? `api_key = ""` : ""}
-print(run_flow(message=message, flow_id=FLOW_ID, tweaks=TWEAKS${
- !isAuth ? `, api_key=api_key` : ""
- }))`;
+def main():
+ parser = argparse.ArgumentParser(description="""Run a flow with a given message and optional tweaks.\nRun it like: python .py "your message here" --endpoint "your_endpoint" --tweaks '{"key": "value"}'""",
+ formatter_class=RawTextHelpFormatter)
+ parser.add_argument("message", type=str, help="The message to send to the flow")
+ parser.add_argument("--endpoint", type=str, default=ENDPOINT or FLOW_ID, help="The ID or the endpoint name of the flow")
+ parser.add_argument("--tweaks", type=str, help="JSON string representing the tweaks to customize the flow", default=json.dumps(TWEAKS))
+ parser.add_argument("--api_key", type=str, help="API key for authentication", default=None)
+ parser.add_argument("--output_type", type=str, default="chat", help="The output type")
+ parser.add_argument("--input_type", type=str, default="chat", help="The input type")
+ parser.add_argument("--upload_file", type=str, help="Path to the file to upload", default=None)
+ parser.add_argument("--components", type=str, help="Components to upload the file to", default=None)
+
+ args = parser.parse_args()
+ try:
+ tweaks = json.loads(args.tweaks)
+ except json.JSONDecodeError:
+ raise ValueError("Invalid tweaks JSON string")
+
+ if args.upload_file:
+ if not upload_file:
+ raise ImportError("Langflow is not installed. Please install it to use the upload_file function.")
+ elif not args.components:
+ raise ValueError("You need to provide the components to upload the file to.")
+ tweaks = upload_file(file_path=args.upload_file, host=BASE_API_URL, flow_id=ENDPOINT, components=args.components, tweaks=tweaks)
+
+ response = run_flow(
+ message=args.message,
+ endpoint=args.endpoint,
+ output_type=args.output_type,
+ input_type=args.input_type,
+ tweaks=tweaks,
+ api_key=args.api_key
+ )
+
+ print(json.dumps(response, indent=2))
+
+if __name__ == "__main__":
+ main()
+`;
}
diff --git a/src/frontend/src/modals/apiModal/views/index.tsx b/src/frontend/src/modals/apiModal/views/index.tsx
index 62ee7a4e5..f7a72082c 100644
--- a/src/frontend/src/modals/apiModal/views/index.tsx
+++ b/src/frontend/src/modals/apiModal/views/index.tsx
@@ -35,7 +35,7 @@ const ApiModal = forwardRef(
flow: FlowType;
children: ReactNode;
},
- ref,
+ ref
) => {
const tweak = useTweaksStore((state) => state.tweak);
const addTweaks = useTweaksStore((state) => state.setTweak);
@@ -46,17 +46,22 @@ const ApiModal = forwardRef(
const { autoLogin } = useContext(AuthContext);
const [open, setOpen] = useState(false);
const [activeTab, setActiveTab] = useState("0");
- const pythonApiCode = getPythonApiCode(flow?.id, autoLogin, tweak);
+ const pythonApiCode = getPythonApiCode(
+ flow?.id,
+ autoLogin,
+ tweak,
+ flow?.endpoint_name
+ );
const curl_run_code = getCurlRunCode(
flow?.id,
autoLogin,
tweak,
- flow?.endpoint_name,
+ flow?.endpoint_name
);
const curl_webhook_code = getCurlWebhookCode(
flow?.id,
autoLogin,
- flow?.endpoint_name,
+ flow?.endpoint_name
);
const pythonCode = getPythonCode(flow?.name, tweak);
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
@@ -72,7 +77,7 @@ const ApiModal = forwardRef(
pythonCode,
];
const [tabs, setTabs] = useState(
- createTabsArray(codesArray, includeWebhook),
+ createTabsArray(codesArray, includeWebhook)
);
const canShowTweaks =
@@ -121,7 +126,7 @@ const ApiModal = forwardRef(
buildTweakObject(
nodeId,
element.data.node.template[templateField].value,
- element.data.node.template[templateField],
+ element.data.node.template[templateField]
);
}
});
@@ -138,7 +143,7 @@ const ApiModal = forwardRef(
async function buildTweakObject(
tw: string,
changes: string | string[] | boolean | number | Object[] | Object,
- template: TemplateVariableType,
+ template: TemplateVariableType
) {
changes = getChangesType(changes, template);
@@ -180,7 +185,7 @@ const ApiModal = forwardRef(
flow?.id,
autoLogin,
cloneTweak,
- flow?.endpoint_name,
+ flow?.endpoint_name
);
const pythonCode = getPythonCode(flow?.name, cloneTweak);
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
@@ -224,7 +229,7 @@ const ApiModal = forwardRef(
);
- },
+ }
);
export default ApiModal;
From 98d9553b92c513ff0b537ec2b371f1b0489511de Mon Sep 17 00:00:00 2001
From: Bee <166352117+bee-ch@users.noreply.github.com>
Date: Thu, 6 Jun 2024 03:38:57 +1000
Subject: [PATCH 14/15] Remove commented out code (#2047)
---
.../FlowPage/components/nodeToolbarComponent/index.tsx | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx
index 045697e3a..bbd5573cb 100644
--- a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx
+++ b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx
@@ -498,16 +498,6 @@ export default function NodeToolbarComponent({
/>
)}
- {/*
-
- */}
Date: Wed, 5 Jun 2024 10:40:58 -0700
Subject: [PATCH 15/15] chore: Update poetry installation to use environment
variable for version (#2074)
---
.github/actions/poetry_caching/action.yml | 2 +-
.github/workflows/create-release.yml | 2 +-
.github/workflows/pre-release-base.yml | 2 +-
.github/workflows/pre-release-langflow.yml | 2 +-
.github/workflows/pre-release.yml | 2 +-
.github/workflows/release.yml | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/actions/poetry_caching/action.yml b/.github/actions/poetry_caching/action.yml
index e185e7094..4bb6415ac 100644
--- a/.github/actions/poetry_caching/action.yml
+++ b/.github/actions/poetry_caching/action.yml
@@ -74,7 +74,7 @@ runs:
if: steps.cache-bin-poetry.outputs.cache-hit != 'true'
shell: bash
env:
- POETRY_VERSION: ${{ inputs.poetry-version }}
+ POETRY_VERSION: ${{ inputs.poetry-version || env.POETRY_VERSION }}
PYTHON_VERSION: ${{ inputs.python-version }}
# Install poetry using the python version installed by setup-python step.
run: |
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index ef3c8f698..e1b806ccf 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
- run: pipx install poetry==$POETRY_VERSION
+ run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
diff --git a/.github/workflows/pre-release-base.yml b/.github/workflows/pre-release-base.yml
index d087fc183..6045038be 100644
--- a/.github/workflows/pre-release-base.yml
+++ b/.github/workflows/pre-release-base.yml
@@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
- run: pipx install poetry==$POETRY_VERSION
+ run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
diff --git a/.github/workflows/pre-release-langflow.yml b/.github/workflows/pre-release-langflow.yml
index 15726385e..f3909f7b1 100644
--- a/.github/workflows/pre-release-langflow.yml
+++ b/.github/workflows/pre-release-langflow.yml
@@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
- run: pipx install poetry==$POETRY_VERSION
+ run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml
index b72def8b3..8cb0bc90e 100644
--- a/.github/workflows/pre-release.yml
+++ b/.github/workflows/pre-release.yml
@@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
- run: pipx install poetry==$POETRY_VERSION
+ run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3cd8fc2f0..851f06424 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install poetry
- run: pipx install poetry==$POETRY_VERSION
+ run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with: