diff --git a/docs/docs/components/chains.mdx b/docs/docs/components/chains.mdx
index 52de6c481..96dcac2d0 100644
--- a/docs/docs/components/chains.mdx
+++ b/docs/docs/components/chains.mdx
@@ -1,6 +1,7 @@
import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
+import Admonition from "@theme/Admonition";
# Chains
@@ -12,22 +13,23 @@ Chains, in the context of language models, refer to a series of calls made to a
The `CombineDocsChain` incorporates methods to combine or aggregate loaded documents for question-answering functionality.
-:::info
+
Works as a proxy of LangChain’s [documents](https://python.langchain.com/docs/modules/chains/document/) chains generated by the `load_qa_chain` function.
-:::
+
**Params**
- **LLM:** Language Model to use in the chain.
- **chain_type:** The chain type to be used. Each one of them applies a different “combination strategy”.
- - **stuff**: The stuff [documents](https://python.langchain.com/docs/modules/chains/document/stuff) chain (“stuff" as in "to stuff" or "to fill") is the most straightforward of *the* document chains. It takes a list of documents, inserts them all into a prompt, and passes that prompt to an LLM. This chain is well-suited for applications where documents are small and only a few are passed in for most calls.
- - **map_reduce**: The map-reduce [documents](https://python.langchain.com/docs/modules/chains/document/map_reduce) chain first applies an LLM chain to each document individually (the Map step), treating the chain output as a new document. It then passes all the new documents to a separate combined documents chain to get a single output (the Reduce step). It can optionally first compress or collapse the mapped documents to make sure that they fit in the combined documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.
- - **map_rerank**: The map re-rank [documents](https://python.langchain.com/docs/modules/chains/document/map_rerank) chain runs an initial prompt on each document that not only tries to complete a task but also gives a score for how certain it is in its answer. The highest-scoring response is returned.
- - **refine**: The refine [documents](https://python.langchain.com/docs/modules/chains/document/refine) chain constructs a response by looping over the input documents and iteratively updating its answer. For each document, it passes all non-document inputs, the current document, and the latest intermediate answer to an LLM chain to get a new answer.
- Since the Refine chain only passes a single document to the LLM at a time, it is well-suited for tasks that require analyzing more documents than can fit in the model's context. The obvious tradeoff is that this chain will make far more LLM calls than, for example, the Stuff documents chain. There are also certain tasks that are difficult to accomplish iteratively. For example, the Refine chain can perform poorly when documents frequently cross-reference one another or when a task requires detailed information from many documents.
+ - **stuff**: The stuff [documents](https://python.langchain.com/docs/modules/chains/document/stuff) chain (“stuff" as in "to stuff" or "to fill") is the most straightforward of _the_ document chains. It takes a list of documents, inserts them all into a prompt, and passes that prompt to an LLM. This chain is well-suited for applications where documents are small and only a few are passed in for most calls.
+ - **map_reduce**: The map-reduce [documents](https://python.langchain.com/docs/modules/chains/document/map_reduce) chain first applies an LLM chain to each document individually (the Map step), treating the chain output as a new document. It then passes all the new documents to a separate combined documents chain to get a single output (the Reduce step). It can optionally first compress or collapse the mapped documents to make sure that they fit in the combined documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.
+ - **map_rerank**: The map re-rank [documents](https://python.langchain.com/docs/modules/chains/document/map_rerank) chain runs an initial prompt on each document that not only tries to complete a task but also gives a score for how certain it is in its answer. The highest-scoring response is returned.
+ - **refine**: The refine [documents](https://python.langchain.com/docs/modules/chains/document/refine) chain constructs a response by looping over the input documents and iteratively updating its answer. For each document, it passes all non-document inputs, the current document, and the latest intermediate answer to an LLM chain to get a new answer.
+
+ Since the Refine chain only passes a single document to the LLM at a time, it is well-suited for tasks that require analyzing more documents than can fit in the model's context. The obvious tradeoff is that this chain will make far more LLM calls than, for example, the Stuff documents chain. There are also certain tasks that are difficult to accomplish iteratively. For example, the Refine chain can perform poorly when documents frequently cross-reference one another or when a task requires detailed information from many documents.
---
@@ -41,7 +43,7 @@ The `ConversationChain` is a straightforward chain for interactive conversations
- **Memory:** Default memory store.
- **input_key:** Used to specify the key under which the user input will be stored in the conversation memory. It allows you to provide the user's input to the chain for processing and generating a response.
- **output_key:** Used to specify the key under which the generated response will be stored in the conversation memory. It allows you to retrieve the response using the specified key.
-- **verbose:** This parameter is used to control the level of detail in the output of the chain. When set to True, it will print out some internal states of the chain while it is being run, which can be helpful for debugging and understanding the chain's behavior. If set to False, it will suppress the verbose output — defaults to `False`.
+- **verbose:** This parameter is used to control the level of detail in the output of the chain. When set to True, it will print out some internal states of the chain while it is being run, which can be helpful for debugging and understanding the chain's behavior. If set to False, it will suppress the verbose output — defaults to `False`.
---
@@ -49,11 +51,11 @@ The `ConversationChain` is a straightforward chain for interactive conversations
The `ConversationalRetrievalChain` extracts information and provides answers by combining document search and question-answering abilities.
-:::info
+
A retriever is a component that finds documents based on a query. It doesn't store the documents themselves, but it returns the ones that match the query.
-:::
+
**Params**
@@ -61,12 +63,13 @@ A retriever is a component that finds documents based on a query. It doesn't sto
- **Memory:** Default memory store.
- **Retriever:** The retriever used to fetch relevant documents.
- **chain_type:** The chain type to be used. Each one of them applies a different “combination strategy”.
- - **stuff**: The stuff [documents](https://python.langchain.com/docs/modules/chains/document/stuff) chain (“stuff" as in "to stuff" or "to fill") is the most straightforward of *the* document chains. It takes a list of documents, inserts them all into a prompt, and passes that prompt to an LLM. This chain is well-suited for applications where documents are small and only a few are passed in for most calls.
- - **map_reduce**: The map-reduce [documents](https://python.langchain.com/docs/modules/chains/document/map_reduce) chain first applies an LLM chain to each document individually (the Map step), treating the chain output as a new document. It then passes all the new documents to a separate combined documents chain to get a single output (the Reduce step). It can optionally first compress or collapse the mapped documents to make sure that they fit in the combined documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.
- - **map_rerank**: The map re-rank [documents](https://python.langchain.com/docs/modules/chains/document/map_rerank) chain runs an initial prompt on each document that not only tries to complete a task but also gives a score for how certain it is in its answer. The highest-scoring response is returned.
- - **refine**: The refine [documents](https://python.langchain.com/docs/modules/chains/document/refine) chain constructs a response by looping over the input documents and iteratively updating its answer. For each document, it passes all non-document inputs, the current document, and the latest intermediate answer to an LLM chain to get a new answer.
- Since the Refine chain only passes a single document to the LLM at a time, it is well-suited for tasks that require analyzing more documents than can fit in the model's context. The obvious tradeoff is that this chain will make far more LLM calls than, for example, the Stuff documents chain. There are also certain tasks that are difficult to accomplish iteratively. For example, the Refine chain can perform poorly when documents frequently cross-reference one another or when a task requires detailed information from many documents.
+ - **stuff**: The stuff [documents](https://python.langchain.com/docs/modules/chains/document/stuff) chain (“stuff" as in "to stuff" or "to fill") is the most straightforward of _the_ document chains. It takes a list of documents, inserts them all into a prompt, and passes that prompt to an LLM. This chain is well-suited for applications where documents are small and only a few are passed in for most calls.
+ - **map_reduce**: The map-reduce [documents](https://python.langchain.com/docs/modules/chains/document/map_reduce) chain first applies an LLM chain to each document individually (the Map step), treating the chain output as a new document. It then passes all the new documents to a separate combined documents chain to get a single output (the Reduce step). It can optionally first compress or collapse the mapped documents to make sure that they fit in the combined documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.
+ - **map_rerank**: The map re-rank [documents](https://python.langchain.com/docs/modules/chains/document/map_rerank) chain runs an initial prompt on each document that not only tries to complete a task but also gives a score for how certain it is in its answer. The highest-scoring response is returned.
+ - **refine**: The refine [documents](https://python.langchain.com/docs/modules/chains/document/refine) chain constructs a response by looping over the input documents and iteratively updating its answer. For each document, it passes all non-document inputs, the current document, and the latest intermediate answer to an LLM chain to get a new answer.
+
+ Since the Refine chain only passes a single document to the LLM at a time, it is well-suited for tasks that require analyzing more documents than can fit in the model's context. The obvious tradeoff is that this chain will make far more LLM calls than, for example, the Stuff documents chain. There are also certain tasks that are difficult to accomplish iteratively. For example, the Refine chain can perform poorly when documents frequently cross-reference one another or when a task requires detailed information from many documents.
- **return_source_documents:** Used to specify whether or not to include the source documents that were used to answer the question in the output. When set to `True`, source documents will be included in the output along with the generated answer. This can be useful for providing additional context or references to the user — defaults to `True`.
- **verbose:** Whether or not to run in verbose mode. In verbose mode, intermediate logs will be printed to the console — defaults to `False`.
@@ -108,17 +111,17 @@ The `LLMMathChain` works by using the language model with an `LLMChain` to under
`RetrievalQA` is a chain used to find relevant documents or information to answer a given query. The retriever is responsible for returning the relevant documents based on the query, and the QA component then extracts the answer from those documents. The retrieval QA system combines the capabilities of both the retriever and the QA component to provide accurate and relevant answers to user queries.
-:::info
+
A retriever is a component that finds documents based on a query. It doesn't store the documents themselves, but it returns the ones that match the query.
-:::
+
**Params**
- **Combine Documents Chain:** Chain to use to combine the documents.
- **Memory:** Default memory store.
-- **Retriever:** The retriever used to fetch relevant documents.
+- **Retriever:** The retriever used to fetch relevant documents.
- **input_key:** This parameter is used to specify the key in the input data that contains the question. It is used to retrieve the question from the input data and pass it to the question-answering model for generating the answer — defaults to `query`.
- **output_key:** This parameter is used to specify the key in the output data where the generated answer will be stored. It is used to retrieve the answer from the output data after the question-answering model has generated it — defaults to `result`.
- **return_source_documents:** Used to specify whether or not to include the source documents that were used to answer the question in the output. When set to `True`, source documents will be included in the output along with the generated answer. This can be useful for providing additional context or references to the user — defaults to `True`.
@@ -134,4 +137,4 @@ The `SQLDatabaseChain` finds answers to questions using a SQL database. It works
- **Db:** SQL Database to connect to.
- **LLM:** Language Model to use in the chain.
-- **Prompt:** Prompt template to translate natural language to SQL.
\ No newline at end of file
+- **Prompt:** Prompt template to translate natural language to SQL.
diff --git a/docs/docs/components/custom.mdx b/docs/docs/components/custom.mdx
new file mode 100644
index 000000000..9f7fa65ca
--- /dev/null
+++ b/docs/docs/components/custom.mdx
@@ -0,0 +1,79 @@
+import Admonition from "@theme/Admonition";
+
+# Custom Component
+
+Used to create a custom component. The code is the class that will be converted to a Custom Component with the fields and formatting you define.
+
+**Params**
+
+- **Code:** The Python code to define the component.
+
+The code must be a class that inherits from the _`langflow.CustomComponent`_ class.
+
+The type annotations of the _`build`_ instance method will be used to create the fields of the component.
+
+| Supported types |
+| --------------------------------------------------------- |
+| _`str`_, _`int`_, _`float`_, _`bool`_, _`list`_, _`dict`_ |
+| _`langchain.chains.base.Chain`_ |
+| _`langchain.PromptTemplate`_ |
+| _`langchain.llms.base.BaseLLM`_ |
+| _`langchain.Tool`_ |
+| _`langchain.document_loaders.base.BaseLoader`_ |
+| _`langchain.schema.Document`_ |
+| _`langchain.text_splitters.TextSplitter`_ |
+| _`langchain.vectorstores.base.VectorStore`_ |
+| _`langchain.embeddings.base.Embeddings`_ |
+| _`langchain.schema.BaseRetriever`_ |
+
+The class can have a [_`build_config`_](focus://8) instance method, which is used to define configuration fields for the component.
+The [_`build_config`_](focus://8) method should always return a dictionary with specific keys representing the field names and their corresponding configurations.
+It must follow the format described below:
+
+The top-level keys are the field names.
+
+Their values are of type _`dict`_ with any of the following keys (all of them are **optional**):
+
+| Key | Description |
+| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| _`field_type: str`_ | The type of the field (can be any of the types supported by the _`build`_ method, passed as a string). |
+| _`is_list: bool`_ | If the field is a list. |
+| _`options: List[str]`_ | This defines the options to be displayed. The _`field_type`_ should invariably be _`str`_. If you set the _`value`_ attribute to one of the options, it will be selected by default. Having _`options`_ will display a dropdown menu. |
+| _`multiline: bool`_ | When the field is a string, this would allow the user to open a text editor. |
+| _`input_types: List[str]`_ | To be used when you want a _`str`_ field to have connectable handles. |
+| _`display_name: str`_ | To define the name of the field. |
+| _`advanced: bool`_ | To hide the field in default view. This is useful when a field is for advanced users or you simply want to remove it from view. |
+| _`password: bool`_ | To mask the input text. This is used to allow the user to hide the values of the text (e.g. API keys). |
+| _`required: bool`_ | To make the field required. |
+| _`info: str`_ | To add a tooltip to the field. |
+| _`file_types: List[str]`_ | This is a requirement if the _`field_type`_ is file. Defines which file types will be accepted. For example, json, yaml or yml. |
+
+The CustomComponent class provides the following methods:
+
+| Method name | Description |
+| -------------- | ------------------------------------------------------------- |
+| _`list_flows`_ | Returns a list of Flow objects with an _`id`_ and a _`name`_. |
+| _`load_flow`_ | Loads a flow from the given _`id`_. |
+
+### Usage
+
+```python
+# In the CustomComponent class
+def build(self, flow_name: str)
+ # This is a list of Flow objects with an id and a name
+ flows = self.list_flows()
+ found_flow = next((f for f in flows if f.name == flow_name), None)
+ if not found_flow:
+ raise ValueError(f"Flow {flow_name} not found")
+
+ flow = self.load_flow(found_flow.id)
+ result = flow() # Run the flow
+ return result
+
+```
+
+
+
+[Learn more about Custom Components](../guidelines/custom-component)
+
+
diff --git a/docs/docs/components/prompts.mdx b/docs/docs/components/prompts.mdx
index f4f2c4cae..0c7257272 100644
--- a/docs/docs/components/prompts.mdx
+++ b/docs/docs/components/prompts.mdx
@@ -1,3 +1,5 @@
+import Admonition from "@theme/Admonition";
+
# Prompts
A prompt refers to the input given to a language model. It is constructed from multiple components and can be parametrized using prompt templates. A prompt template is a reproducible way to generate prompts and allow for easy customization through input variables.
@@ -8,8 +10,10 @@ A prompt refers to the input given to a language model. It is constructed from m
The `PromptTemplate` component allows users to create prompts and define variables that provide control over instructing the model. The template can take in a set of variables from the end user and generates the prompt once the conversation is initiated.
-:::info
-Once a variable is defined in the prompt template, it becomes a component input of its own. Check out [Prompt Customization](../guidelines/prompt-customization.mdx) to learn more.
-:::
+
+ Once a variable is defined in the prompt template, it becomes a component
+ input of its own. Check out [Prompt
+ Customization](../guidelines/prompt-customization.mdx) to learn more.
+
-- **template:** Template used to format an individual request.
\ No newline at end of file
+- **template:** Template used to format an individual request.
diff --git a/docs/docs/examples/buffer-memory.mdx b/docs/docs/examples/buffer-memory.mdx
index c3e886cf9..d34649991 100644
--- a/docs/docs/examples/buffer-memory.mdx
+++ b/docs/docs/examples/buffer-memory.mdx
@@ -1,3 +1,5 @@
+import Admonition from "@theme/Admonition";
+
# Buffer Memory
For certain applications, retaining past interactions is crucial. For that, chains and agents may accept a memory component as one of their input parameters. The `ConversationBufferMemory` component is one of them. It stores messages and extracts them into variables.
@@ -17,9 +19,10 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`ConversationBufferMemory`](https://python.langchain.com/docs/modules/memory/how_to/buffer)
- [`ConversationChain`](https://python.langchain.com/docs/modules/chains/)
- [`ChatOpenAI`](https://python.langchain.com/docs/modules/model_io/models/chat/integrations/openai)
- :::
+
+
diff --git a/docs/docs/examples/conversation-chain.mdx b/docs/docs/examples/conversation-chain.mdx
index b8cbb11bb..db3181881 100644
--- a/docs/docs/examples/conversation-chain.mdx
+++ b/docs/docs/examples/conversation-chain.mdx
@@ -1,10 +1,14 @@
+import Admonition from "@theme/Admonition";
+
# Conversation Chain
This example shows how to instantiate a simple `ConversationChain` component using a Language Model (LLM). Once the Node Status turns green 🟢, the chat will be ready to take in user messages. Here, we used `ChatOpenAI` to act as the required LLM input, but you can use any LLM for this purpose.
-:::info
+
+
Make sure to always get the API key from the provider.
-:::
+
+
## ⛓️ Langflow Example
@@ -21,8 +25,9 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`ConversationChain`](https://python.langchain.com/docs/modules/chains/)
- [`ChatOpenAI`](https://python.langchain.com/docs/modules/model_io/models/chat/integrations/openai)
- :::
+
+
diff --git a/docs/docs/examples/csv-loader.mdx b/docs/docs/examples/csv-loader.mdx
index de808ec3d..c59dfc1e7 100644
--- a/docs/docs/examples/csv-loader.mdx
+++ b/docs/docs/examples/csv-loader.mdx
@@ -1,3 +1,5 @@
+import Admonition from "@theme/Admonition";
+
# CSV Loader
The `VectoStoreAgent` component retrieves information from one or more vector stores. This example shows a `VectoStoreAgent` connected to a CSV file through the `Chroma` vector store. Process description:
@@ -7,13 +9,18 @@ The `VectoStoreAgent` component retrieves information from one or more vector st
- These chunks feed the `Chroma` vector store, which converts them into vectors and stores them for fast indexing.
- Finally, the agent accesses the information of the vector store through the `VectorStoreInfo` tool.
-:::info
-The vector store is used for efficient semantic search, while `VectorStoreInfo` carries information about it, such as its name and description. Embeddings are a way to represent words, phrases, or any entities in a vector space. Learn more about them [here](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings).
-:::
+
+ The vector store is used for efficient semantic search, while
+ `VectorStoreInfo` carries information about it, such as its name and
+ description. Embeddings are a way to represent words, phrases, or any entities
+ in a vector space. Learn more about them
+ [here](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings).
+
-:::tip
-Once you build this flow, ask questions about the data in the chat interface (e.g., number of rows or columns).
-:::
+
+ Once you build this flow, ask questions about the data in the chat interface
+ (e.g., number of rows or columns).
+
## ⛓️ Langflow Example
@@ -30,7 +37,7 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`CSVLoader`](https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/csv)
- [`CharacterTextSplitter`](https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/character_text_splitter)
@@ -39,4 +46,5 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
- [`VectorStoreInfo`](https://python.langchain.com/docs/modules/data_connection/vectorstores/)
- [`OpenAI`](https://python.langchain.com/docs/modules/model_io/models/llms/integrations/openai)
- [`VectorStoreAgent`](https://python.langchain.com/docs/modules/agents/toolkits/vectorstore)
- :::
+
+
diff --git a/docs/docs/examples/flow-runner.mdx b/docs/docs/examples/flow-runner.mdx
new file mode 100644
index 000000000..606e1ad15
--- /dev/null
+++ b/docs/docs/examples/flow-runner.mdx
@@ -0,0 +1,354 @@
+---
+description: Custom Components
+hide_table_of_contents: true
+---
+
+import ZoomableImage from "/src/theme/ZoomableImage.js";
+import Admonition from "@theme/Admonition";
+
+# FlowRunner Component
+
+The CustomComponent allows us to create new components that can interact with Langflow itself.
+
+In this example, we are going to create a component that allows us to run other flows.
+
+What we will see:
+
+- How to list the flows in the collection using the _`list_flows`_ method.
+- How to load a flow using the _`load_flow`_ method.
+- Configure a field to be a dropdown menu using the _`options`_ parameter.
+
+
+
+```python
+from langflow import CustomComponent
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self):
+ ...
+
+ def build(self):
+ ...
+
+```
+
+This is the basic structure of a custom component.
+
+---
+
+```python
+from langflow import CustomComponent
+
+# focus
+class FlowRunner(CustomComponent):
+ # focus
+ display_name = "Flow Runner"
+ # focus
+ description = "Run other flows"
+
+ def build_config(self):
+ ...
+
+ def build(self):
+ ...
+
+```
+
+So, let's start by adding the _`display_name`_ and a _`description`_.
+
+---
+
+```python
+from langflow import CustomComponent
+# focus
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self):
+ ...
+
+```
+
+Now let's import _`Document`_ from the _`langchain.schema`_ module, which will be our return type for the _`build`_ method.
+
+---
+
+```python
+from langflow import CustomComponent
+# focus
+from langchain.schema import Document
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ # focus
+ def build(self, flow_name: str, document: Document) -> Document:
+ ...
+
+```
+
+Let's add the [parameters](focus://11[20:55]) and the [return type](focus://11[60:69]) to the _`build`_ method.
+
+The parameters we added are:
+
+- _`flow_name`_ is the name of the flow to be run.
+- _`document`_ is what is going to be passed to the flow.
+ - We are using the _`Document`_ type, which will add a [handle](../guidelines/components) to the component.
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self, flow_name: str, document: Document) -> Document:
+ # focus
+ # List the flows
+ # focus
+ flows = self.list_flows()
+
+```
+
+Now we can start writing the code for the _`build`_ method.
+
+We will start by listing the flows in the collection using the _`list_flows`_ method.
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self, flow_name: str, document: Document) -> Document:
+ # List the flows
+ flows = self.list_flows()
+ # focus
+ # Get the flow that matches the selected name
+ # focus
+ flow = next(filter(lambda f: f.name == flow_name, flows))
+
+```
+
+We can then get the flow that matches the selected name.
+
+
+ From version 0.4.0 names are unique, but in previous versions, they were not.
+ This might lead to unexpected results if you have flows with the same name.
+
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self, flow_name: str, document: Document) -> Document:
+ # List the flows
+ flows = self.list_flows()
+ # Get the flow that matches the selected name
+ flow = next(filter(lambda f: f.name == flow_name, flows))
+ # focus
+ # Load the flow
+ # focus
+ tweaks = {}
+ # focus
+ flow = self.load_flow(flow.id, tweaks)
+
+```
+
+Now we can load the flow using the _`load_flow`_ method.
+
+The _`tweaks`_ parameter is a dictionary that allows you to customize the flow.
+You can find more information about it in the [features guidelines](../guidelines/features#code).
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self, flow_name: str, document: Document) -> Document:
+ # List the flows
+ flows = self.list_flows()
+ # Get the flow that matches the selected name
+ flow = next(filter(lambda f: f.name == flow_name, flows))
+ # Load the flow
+ tweaks = {}
+ flow = self.load_flow(flow.id, tweaks)
+ # focus
+ # Get the page_content from the document
+ # focus
+ page_content = document.page_content
+```
+
+Now we can get the _`page_content`_ from the document.
+
+This is the content that will be passed to the flow and it depends on many factors.
+
+In this example, we are using a Document because we can use a [Loader](../components/loaders) to load a Document but
+then we'll have to process the page_content depending on what is the input of the flow we are running.
+
+
+ One other approach would be to create another CustomComponent that builds a
+ dictionary and then we use that as the input for the FlowRunner.
+
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ ...
+
+ def build(self, flow_name: str, document: Document) -> Document:
+ # List the flows
+ flows = self.list_flows()
+ # Get the flow that matches the selected name
+ flow = next(filter(lambda f: f.name == flow_name, flows))
+ # Load the flow
+ tweaks = {}
+ flow = self.load_flow(flow.id, tweaks)
+ # Get the page_content from the document
+ page_content = document.page_content
+ # Use it in the flow
+ result = flow(page_content)
+ return Document(page_content=str(result))
+```
+
+Finally, we can use the _`page_content`_ in the flow and return the result.
+
+---
+
+```python focus=9:16
+from langflow import CustomComponent
+from langchain.schema import Document
+
+
+class FlowRunner(CustomComponent):
+ display_name = "Flow Runner"
+ description = "Run other flows using a document as input."
+
+ def build_config(self):
+ flows = self.list_flows()
+ flow_names = [f.name for f in flows]
+ return {"flow_name": {"options": flow_names,
+ "display_name": "Flow Name",
+ },
+ "document": {"display_name": "Document"}
+ }
+
+
+ def build(self, flow_name: str, document: Optional[Document] = None) -> Document:
+ # List the flows
+ flows = self.list_flows()
+ # Get the flow that matches the selected name
+ flow = next(filter(lambda f: f.name == flow_name, flows))
+ # Load the flow
+ tweaks = {}
+ flow = self.load_flow(flow.id, tweaks)
+ # Get the page_content from the document
+ page_content = document.page_content
+ # Use it in the flow
+ result = flow(page_content)
+ return Document(page_content=str(result))
+```
+
+Now we can add the field customization to the _`build_config`_ method.
+
+We are using the _`options`_ parameter to make the _`flow_name`_ field a dropdown menu.
+
+
+ Make sure the type of the field is _`str`_ and the values of the _`options`_
+ are strings.
+
+
+---
+
+
+
+In Langflow, this is how our script looks like:
+
+{" "}
+
+
+
+And here is our brand new custom component:
+
+{" "}
+
+
diff --git a/docs/docs/examples/how-upload-examples.mdx b/docs/docs/examples/how-upload-examples.mdx
index 8a4306212..2b1a2b06c 100644
--- a/docs/docs/examples/how-upload-examples.mdx
+++ b/docs/docs/examples/how-upload-examples.mdx
@@ -7,16 +7,14 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
We welcome all examples that can help our community learn and explore Langflow's capabilities.
Langflow Examples is a repository on [GitHub](https://github.com/logspace-ai/langflow_examples) that contains examples of flows that people can use for inspiration and learning.
-
-
-
+{" "}
+
To upload examples, please follow these steps:
diff --git a/docs/docs/examples/midjourney-prompt-chain.mdx b/docs/docs/examples/midjourney-prompt-chain.mdx
index d3ca57c91..c79bb0b27 100644
--- a/docs/docs/examples/midjourney-prompt-chain.mdx
+++ b/docs/docs/examples/midjourney-prompt-chain.mdx
@@ -1,3 +1,5 @@
+import Admonition from "@theme/Admonition";
+
# MidJourney Prompt Chain
The `MidJourneyPromptChain` can be used to generate imaginative and detailed MidJourney prompts.
@@ -14,9 +16,11 @@ And get a response such as:
Imagine a mysterious forest, the trees are tall and ancient, their branches reaching up to the sky. Through the darkness, a dragon emerges from the shadows, its scales shimmering in the moonlight. Its wingspan is immense, and its eyes glow with a fierce intensity. It is a majestic and powerful creature, one that commands both respect and fear.
```
-:::tip
-Notice that the `ConversationSummaryMemory` stores a summary of the conversation over time. Try using it to create better prompts as the conversation goes on.
-:::
+
+ Notice that the `ConversationSummaryMemory` stores a summary of the
+ conversation over time. Try using it to create better prompts as the
+ conversation goes on.
+
## ⛓️ Langflow Example
@@ -33,8 +37,9 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`OpenAI`](https://python.langchain.com/docs/modules/model_io/models/llms/integrations/openai)
- [`ConversationSummaryMemory`](https://python.langchain.com/docs/modules/memory/how_to/summary)
- :::
+
+
diff --git a/docs/docs/examples/multiple-vectorstores.mdx b/docs/docs/examples/multiple-vectorstores.mdx
index 36890c866..0bb6b9ade 100644
--- a/docs/docs/examples/multiple-vectorstores.mdx
+++ b/docs/docs/examples/multiple-vectorstores.mdx
@@ -1,12 +1,15 @@
+import Admonition from "@theme/Admonition";
+
# Multiple Vector Stores
The example below shows an agent operating with two vector stores built upon different data sources.
The `TextLoader` loads a TXT file, while the `WebBaseLoader` pulls text from webpages into a document format to accessed downstream. The `Chroma` vector stores are created analogous to what we have demonstrated in our [CSV Loader](/examples/csv-loader.mdx) example. Finally, the `VectorStoreRouterAgent` constructs an agent that routes between the vector stores.
-:::info
-Get the TXT file used [here](https://github.com/hwchase17/chat-your-data/blob/master/state_of_the_union.txt).
-:::
+
+ Get the TXT file used
+ [here](https://github.com/hwchase17/chat-your-data/blob/master/state_of_the_union.txt).
+
URL used by the `WebBaseLoader`:
@@ -14,13 +17,15 @@ URL used by the `WebBaseLoader`:
https://pt.wikipedia.org/wiki/Harry_Potter
```
-:::tip
-When you build the flow, request information about one of the sources. The agent should be able to use the correct source to generate a response.
-:::
+
+ When you build the flow, request information about one of the sources. The
+ agent should be able to use the correct source to generate a response.
+
-:::info
-Learn more about Multiple Vector Stores [here](https://python.langchain.com/docs/modules/agents/toolkits/vectorstore?highlight=Multiple%20Vector%20Stores#multiple-vectorstores).
-:::
+
+ Learn more about Multiple Vector Stores
+ [here](https://python.langchain.com/docs/modules/agents/toolkits/vectorstore?highlight=Multiple%20Vector%20Stores#multiple-vectorstores).
+
## ⛓️ Langflow Example
@@ -37,7 +42,7 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`WebBaseLoader`](https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/web_base)
- [`TextLoader`](https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/unstructured_file)
@@ -49,4 +54,4 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
- [`VectorStoreRouterToolkit`](https://python.langchain.com/docs/modules/agents/toolkits/vectorstore)
- [`VectorStoreRouterAgent`](https://python.langchain.com/docs/modules/agents/toolkits/vectorstore)
-:::
+
diff --git a/docs/docs/examples/python-function.mdx b/docs/docs/examples/python-function.mdx
index 12a262a3f..f537075c6 100644
--- a/docs/docs/examples/python-function.mdx
+++ b/docs/docs/examples/python-function.mdx
@@ -1,3 +1,5 @@
+import Admonition from "@theme/Admonition";
+
# Python Function
Langflow allows you to create a customized tool using the `PythonFunction` connected to a `Tool` component. In this example, Regex is used in Python to validate a pattern.
@@ -15,15 +17,19 @@ def is_brazilian_zipcode(zipcode: str) -> bool:
return False
```
-:::tip
-When a tool is called, it is often desirable to have its output returned directly to the user. You can do this by setting the **return_direct** flag for a tool to be True.
-:::
+
+ When a tool is called, it is often desirable to have its output returned
+ directly to the user. You can do this by setting the **return_direct** flag
+ for a tool to be True.
+
The `AgentInitializer` component is a quick way to construct an agent from the model and tools.
-:::info
-The `PythonFunction` is a custom component that uses the LangChain 🦜🔗 tool decorator. Learn more about it [here](https://python.langchain.com/docs/modules/agents/tools/how_to/custom_tools).
-:::
+
+ The `PythonFunction` is a custom component that uses the LangChain 🦜🔗 tool
+ decorator. Learn more about it
+ [here](https://python.langchain.com/docs/modules/agents/tools/how_to/custom_tools).
+
## ⛓️ Langflow Example
@@ -40,9 +46,10 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`PythonFunctionTool`](https://python.langchain.com/docs/modules/agents/tools/how_to/custom_tools)
- [`ChatOpenAI`](https://python.langchain.com/docs/modules/model_io/models/chat/integrations/openai)
- [`AgentInitializer`](https://python.langchain.com/docs/modules/agents/)
- :::
+
+
diff --git a/docs/docs/examples/serp-api-tool.mdx b/docs/docs/examples/serp-api-tool.mdx
index a7e1d3d8e..60e55791a 100644
--- a/docs/docs/examples/serp-api-tool.mdx
+++ b/docs/docs/examples/serp-api-tool.mdx
@@ -1,24 +1,29 @@
+import Admonition from "@theme/Admonition";
+
# Serp API Tool
The [Serp API](https://serpapi.com/) (Search Engine Results Page) allows developers to scrape results from search engines such as Google, Bing and Yahoo, and can be used as in Langflow through the `Search` component.
-:::info
-To use the Serp API, you first need to sign up [Serp API](https://serpapi.com/) for an API key on the provider's website.
-:::
+
+ To use the Serp API, you first need to sign up [Serp
+ API](https://serpapi.com/) for an API key on the provider's website.
+
Here, the `ZeroShotPrompt` component specifies a prompt template for the `ZeroShotAgent`. Set a _Prefix_ and _Suffix_ with rules for the agent to obey. In the example, we used default templates.
The `LLMChain` is a simple chain that takes in a prompt template, formats it with the user input, and returns the response from an LLM.
-:::tip
-In this example, we used [`ChatOpenAI`](https://platform.openai.com/) as the LLM, but feel free to experiment with other Language Models!
-:::
+
+ In this example, we used [`ChatOpenAI`](https://platform.openai.com/) as the
+ LLM, but feel free to experiment with other Language Models!
+
The `ZeroShotAgent` takes the `LLMChain` and the `Search` tool as inputs, using the tool to find information when necessary.
-:::info
-Learn more about the Serp API [here](https://python.langchain.com/docs/modules/agents/tools/integrations/serpapi).
-:::
+
+ Learn more about the Serp API
+ [here](https://python.langchain.com/docs/modules/agents/tools/integrations/serpapi).
+
## ⛓️ Langflow Example
@@ -35,11 +40,12 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
#### Download Flow
-:::note LangChain Components 🦜🔗
+
- [`ZeroShotPrompt`](https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/)
- [`OpenAI`](https://python.langchain.com/docs/modules/model_io/models/llms/integrations/openai)
- [`LLMChain`](https://python.langchain.com/docs/modules/chains/foundational/llm_chain)
- [`Search`](https://python.langchain.com/docs/modules/agents/tools/integrations/serpapi)
- [`ZeroShotAgent`](https://python.langchain.com/docs/modules/agents/how_to/custom_mrkl_agent)
- :::
+
+
diff --git a/docs/docs/getting-started/hugging-face-spaces.mdx b/docs/docs/getting-started/hugging-face-spaces.mdx
index e8b3852a9..acc4bb8d5 100644
--- a/docs/docs/getting-started/hugging-face-spaces.mdx
+++ b/docs/docs/getting-started/hugging-face-spaces.mdx
@@ -6,15 +6,14 @@ import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
-
-
-
+{" "}
+
+
Check out Langflow on [HuggingFace Spaces](https://huggingface.co/spaces/Logspace/Langflow).
diff --git a/docs/docs/guidelines/chat-interface.mdx b/docs/docs/guidelines/chat-interface.mdx
index c09f00076..0ac23dc8a 100644
--- a/docs/docs/guidelines/chat-interface.mdx
+++ b/docs/docs/guidelines/chat-interface.mdx
@@ -7,58 +7,46 @@ import ReactPlayer from "react-player";
Langflow’s chat interface provides a user-friendly experience and functionality to interact with the model and customize the prompt. The sidebar brings options that allow users to view and edit pre-defined prompt variables. This feature facilitates quick experimentation by enabling the modification of variable values right in the chat.
-
-
-
+{" "}
+
Notice that editing variables in the chat interface take place temporarily and won’t change their original value in the components once the chat is closed.
-
-
-
+{" "}
+
+
To view the complete prompt in its original, structured format, click the "Display Prompt" option. This feature lets you see the prompt exactly as it entered the model.
-
-
-
-
+{" "}
+
In the chat interface, you can redefine which variable should be interpreted as the chat input. This gives you control over these inputs and allows dynamic and creative interactions.
-
-
-
+{" "}
+
diff --git a/docs/docs/guidelines/chat-widget.mdx b/docs/docs/guidelines/chat-widget.mdx
new file mode 100644
index 000000000..7f6737fea
--- /dev/null
+++ b/docs/docs/guidelines/chat-widget.mdx
@@ -0,0 +1,209 @@
+import ThemedImage from "@theme/ThemedImage";
+import useBaseUrl from "@docusaurus/useBaseUrl";
+import ZoomableImage from "/src/theme/ZoomableImage.js";
+import ReactPlayer from "react-player";
+import Admonition from "@theme/Admonition";
+
+# Chat Widget
+
+
+ The Langflow Chat Widget is a powerful web component that enables
+ communication with a Langflow project. This widget allows for a chat interface
+ embedding, allowing the integration of Langflow into web applications
+ effortlessly.
+
+
+## Features
+
+🌟 **Seamless Integration:** Easily integrate the Langflow Chat Widget into your website or web application with just a few lines of JavaScript.
+
+🚀 **Interactive Chat Interface:** Engage your users with a user-friendly conversation, powered by Langflow's advanced language understanding capabilities.
+
+🎛️ **Customizable Styling:** Customize the appearance of the chat widget to match your application's design and branding.
+
+🌐 **Multilingual Support:** Communicate with users in multiple languages, opening up your application to a global audience.
+
+---
+
+## Usage
+
+
+ You can get the HTML code embedded with the chat by clicking the Code button
+ at the Sidebar after building a flow.
+
+
+{" "}
+
+
+
+
+ Clicking the Chat Widget HTML tab, you'll get the code to be inserted. Read
+ below to learn how to use it with HTML, React and Angular.
+
+
+{" "}
+
+
+
+---
+
+### HTML
+
+The Chat Widget can be embedded into any HTML page, inside a _``_ tag, as demonstrated in the video below.
+
+
+
+
+
+---
+
+### React
+
+To embed the Chat Widget using React, you'll need to insert this _`
+```
+
+Then, declare your Web Component and encapsulate it in a React component.
+
+```jsx
+declare global {
+ namespace JSX {
+ interface IntrinsicElements {
+ "langflow-chat": any;
+ }
+ }
+}
+
+export default function ChatWidget({ className }) {
+ return (
+
+
+
+ );
+}
+```
+
+Finally, you can place the component anywhere in your code to display the Chat Widget.
+
+---
+
+### Angular
+
+To use it in Angular, first add this _`
+```
+
+When you use a custom web component in an Angular template, the Angular compiler might show a warning when it doesn't recognize the custom elements by default. To suppress this warning, add _`CUSTOM_ELEMENTS_SCHEMA`_ to the module's _`@NgModule.schemas`_.
+
+- Open the module file (it typically ends with _.module.ts_) where you'd add the _`langflow-chat`_ web component.
+- Import _`CUSTOM_ELEMENTS_SCHEMA`_ at the top of the file:
+
+```ts
+import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
+```
+
+- Add _`CUSTOM_ELEMENTS_SCHEMA`_ to the 'schemas' array inside the '@NgModule' decorator:
+
+```ts
+@NgModule({
+ declarations: [
+ // ... Other components and directives ...
+ ],
+ imports: [
+ // ... Other imported modules ...
+ ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA], // Add the CUSTOM_ELEMENTS_SCHEMA here
+})
+export class YourModule {}
+```
+
+In your Angular project, find the component belonging to the module where _`CUSTOM_ELEMENTS_SCHEMA`_ was added.
+
+- Inside the template, add the _`langflow-chat`_ tag to include the Chat Widget in your component's view:
+
+```jsx
+
+```
+
+
+
+
+ _`CUSTOM_ELEMENTS_SCHEMA`_ is a built-in schema that allows Angular to
+ recognize custom elements.
+
+
+ Adding _`CUSTOM_ELEMENTS_SCHEMA`_ tells Angular to allow custom elements
+ in your templates, and it will suppress the warning related to unknown
+ elements like _`langflow-chat`_.
+
+
+ Notice that you can only use the Chat Widget in components that are part
+ of the module where you added _`CUSTOM_ELEMENTS_SCHEMA`_.
+
+
+
+
+---
+
+## Configuration
+
+Use the widget API to customize your Chat Widget:
+
+
+ Props with the type JSON need to be passed as Stringified JSONs, with the
+ format {"key":"value"}.
+
+
+| Prop | Type | Required | Description |
+| --------------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| bot_message_style | JSON | No | Applies custom formatting to bot messages. |
+| chat_input_field | String | Yes | Defines the type of the input field for chat messages. |
+| chat_inputs | JSON | Yes | Determines the chat input elements and their respective values. |
+| chat_output_key | String | No | Specifies which output to display if multiple outputs are available. |
+| chat_position | String | No | Positions the chat window on the screen (options include: top-left, top-center, top-right, center-left, center-right, bottom-right, bottom-center, bottom-left). |
+| chat_trigger_style | JSON | No | Styles the chat trigger button. |
+| chat_window_style | JSON | No | Customizes the overall appearance of the chat window. |
+| error_message_style | JSON | No | Sets the format for error messages within the chat window. |
+| flow_id | String | Yes | Identifies the flow that the component is associated with. |
+| height | Number | No | Sets the height of the chat window in pixels. |
+| host_url | String | Yes | Specifies the URL of the host for chat component communication. |
+| input_container_style | JSON | No | Applies styling to the container where chat messages are entered. |
+| input_style | JSON | No | Sets the style for the chat input field. |
+| online | Boolean | No | Toggles the online status of the chat component. |
+| online_message | String | No | Sets a custom message to display when the chat component is online. |
+| placeholder | String | No | Sets the placeholder text for the chat input field. |
+| placeholder_sending | String | No | Sets the placeholder text to display while a message is being sent. |
+| send_button_style | JSON | No | Sets the style for the send button in the chat window. |
+| send_icon_style | JSON | No | Sets the style for the send icon in the chat window. |
+| tweaks | JSON | No | Applies additional custom adjustments for the associated flow. |
+| user_message_style | JSON | No | Determines the formatting for user messages in the chat window. |
+| width | Number | No | Sets the width of the chat window in pixels. |
+| window_title | String | No | Sets the title displayed in the chat window's header or title bar. |
diff --git a/docs/docs/guidelines/components.mdx b/docs/docs/guidelines/components.mdx
index ba2f5ff33..b7dadcfce 100644
--- a/docs/docs/guidelines/components.mdx
+++ b/docs/docs/guidelines/components.mdx
@@ -25,17 +25,14 @@ Components are the building blocks of the flows. They are made of inputs, output
of that type is required.
-
-
-
+{" "}
+
On the top right corner, you will find the component status icon 🔴. Make the
diff --git a/docs/docs/guidelines/custom-component.mdx b/docs/docs/guidelines/custom-component.mdx
new file mode 100644
index 000000000..07619f224
--- /dev/null
+++ b/docs/docs/guidelines/custom-component.mdx
@@ -0,0 +1,344 @@
+---
+description: Custom Components
+hide_table_of_contents: true
+---
+
+import ZoomableImage from "/src/theme/ZoomableImage.js";
+import Admonition from "@theme/Admonition";
+
+# Custom Components
+
+In Langflow, a Custom Component is a special component type that allows users to extend the functionality of the platform by creating their own reusable and configurable components.
+
+A Custom Component is created from a user-defined Python script that uses the _`CustomComponent`_ class provided by the Langflow library. These components can be as simple as a basic function that takes and returns a string or as complex as a combination of multiple sub-components and API calls.
+
+Let's take a look at the basic rules and features, then we'll go over an example.
+
+## TL;DR
+
+- Create a class that inherits from _`CustomComponent`_ and contains a _`build`_ method.
+- Use arguments with [Type Annotations (or Type Hints)](https://docs.python.org/3/library/typing.html) of the _`build`_ method to create component fields.
+- Use the _`build_config`_ method to customize these fields look and behave.
+
+Here is an example:
+
+
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class DocumentProcessor(CustomComponent):
+ display_name = "Document Processor"
+ description = "This component processes a document"
+
+ def build_config(self) -> dict:
+ options = ["Uppercase", "Lowercase", "Titlecase"]
+ return {
+ "function": {"options": options,
+ "value": options[0]}}
+
+ def build(self, document: Document, function: str) -> Document:
+ page_content = document.page_content
+ if function == "Uppercase":
+ page_content = page_content.upper()
+ elif function == "Lowercase":
+ page_content = page_content.lower()
+ elif function == "Titlecase":
+ page_content = page_content.title()
+ return Document(page_content=page_content)
+```
+
+
+
+
+ Check out [FlowRunner Component](../examples/flow-runner) for a more powerful
+ example.
+
+
+---
+
+## Rules
+
+The Python script for every Custom Component should follow a set of rules. Let's go over them, one by one:
+
+
+
+### Rule 1
+
+The script must contain a **single class** that inherits from _`CustomComponent`_.
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self, document: Document, function: str) -> Document:
+ ...
+```
+
+---
+
+### Rule 2
+
+This class requires a _`build`_ method, which is used to run the component and defines its fields.
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ # focus
+ # mark
+ def build(self) -> Document:
+ ...
+```
+
+---
+
+The [Return Type Annotation](https://docs.python.org/3/library/typing.html) of the _`build`_ method defines the component type (e.g., Chain, BaseLLM or basic Python types). Check out all supported types in the [component reference](../components/custom).
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ # focus[20:31]
+ # mark
+ def build(self) -> Document:
+ ...
+```
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self) -> Document:
+ ...
+```
+
+### Rule 3
+
+The class can have a [_`build_config`_](focus://8) method, which is used to define configuration fields for the component. The [_`build_config`_](focus://8) method should always return a dictionary with specific keys representing the field names and their corresponding configurations. It must follow the format described below:
+
+- Top-level keys are field names.
+- Their values are also of type _`dict`_. They specify the behavior of the generated fields.
+
+Check out the [component reference](../components/custom) for more details on the available field configurations.
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class MyComponent(CustomComponent):
+ display_name = "Custom Component"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self) -> Document:
+ ...
+```
+
+## Example
+
+Let's create a simple component that takes a document and a function name as input and returns a document with the page content processed by the selected function.
+
+
+
+If you were to do this using Langflow's native components, you would create a Tool and ask the agent to use it.
+
+
+
+---
+
+### Pick a display name
+
+First, let's choose a name for our component by adding a _`display_name`_ attribute. This is the component name to be displayed in the canvas.
+The name of the class is not important, but let's call it _`DocumentProcessor`_.
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+# focus
+class DocumentProcessor(CustomComponent):
+ # focus
+ display_name = "Document Processor"
+ description = "This is a custom component"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self) -> Document:
+ ...
+```
+
+---
+
+### Write a description
+
+We can also write a description for it using the _`description`_ attribute.
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class DocumentProcessor(CustomComponent):
+ display_name = "Document Processor"
+ description = "This component processes a document"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self) -> Document:
+ ...
+```
+
+---
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class DocumentProcessor(CustomComponent):
+ display_name = "Document Processor"
+ description = "This component processes a document"
+
+ def build_config(self) -> dict:
+ ...
+
+ def build(self, document: Document, function: str) -> Document:
+ page_content = document.page_content
+ if function == "Uppercase":
+ page_content = page_content.upper()
+ elif function == "Lowercase":
+ page_content = page_content.lower()
+ elif function == "Titlecase":
+ page_content = page_content.title()
+ return Document(page_content=page_content)
+```
+
+### Add the build method
+
+The parameters used are:
+
+- _`document`_ is the document to be processed.
+- _`function`_ is the name of the function to be applied to the document.
+
+The return type is _`Document`_.
+
+This method is called when the component is built (i.e. when you click the _Build_ button in the canvas).
+
+
+ One important aspect of the Type Hints is that generally base Python types add
+ different kinds of fields while other types such as Document add a
+ [handle](../guidelines/components) to the component.
+
+
+---
+
+### Customize the fields
+
+The _`build_config`_ method will be used to configure the fields of the component.
+
+- _`options`_ defines that the field will be a dropdown menu. The values must be _`str`_ and the type of the field should also be _`str`_.
+- _`value`_ is the default value of the field.
+- _`display_name`_ is the name of the field to be displayed in the canvas.
+
+This method is called when the code is processed (i.e. when you click _Check and Save_ in the code editor).
+
+```python
+from langflow import CustomComponent
+from langchain.schema import Document
+
+class DocumentProcessor(CustomComponent):
+ display_name = "Document Processor"
+ description = "This component processes a document"
+
+ def build_config(self) -> dict:
+ options = ["Uppercase", "Lowercase", "Titlecase"]
+ return {
+ "function": {"options": options,
+ "value": options[0],
+ "display_name": "Function"
+ },
+ "document": {"display_name": "Document"}
+ }
+
+ def build(self, document: Document, function: str) -> Document:
+ page_content = document.page_content
+ if function == "Uppercase":
+ page_content = page_content.upper()
+ elif function == "Lowercase":
+ page_content = page_content.lower()
+ elif function == "Titlecase":
+ page_content = page_content.title()
+ return Document(page_content=page_content)
+```
+
+
+
+In Langflow, this is how our script looks like:
+
+{" "}
+
+
+
+And here is our brand new custom component:
+
+{" "}
+
+
diff --git a/docs/docs/guidelines/features.mdx b/docs/docs/guidelines/features.mdx
index cf8b09c6e..6235b68db 100644
--- a/docs/docs/guidelines/features.mdx
+++ b/docs/docs/guidelines/features.mdx
@@ -2,6 +2,7 @@ import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
import ReactPlayer from "react-player";
+import Admonition from "@theme/Admonition";
# Features
@@ -12,17 +13,14 @@ import ReactPlayer from "react-player";
below:
-
-
-
+{" "}
+
Further down, we will explain each of these options.
@@ -34,9 +32,10 @@ import ReactPlayer from "react-player";
Flows can be exported and imported as JSON files.
-:::caution
+
Watch out for API keys being stored in local files.
-:::
+
+
---
diff --git a/docs/docs/guidelines/prompt-customization.mdx b/docs/docs/guidelines/prompt-customization.mdx
index 8e2f409f9..efb5b3928 100644
--- a/docs/docs/guidelines/prompt-customization.mdx
+++ b/docs/docs/guidelines/prompt-customization.mdx
@@ -7,80 +7,62 @@ import ReactPlayer from "react-player";
The prompt template allows users to create prompts and define variables that provide control over instructing the model.
-
-
-
+{" "}
+
Variables can be used to define instructions, questions, context, inputs, or examples for the model and can be created with any chosen name in curly brackets, e.g., `{variable_name}`. They act as placeholders for parts of the text that can be easily modified.
-
-
-
+{" "}
+
Once inserted, these variables are immediately recognized as new fields in the prompt component. Here, you can define their values within the component itself or leave a field empty to be adjusted over the chat interface.
-
-
-
+{" "}
+
+
You can also use documents or output parsers as prompt variables. By plugging them into prompt handles, they’ll disable and feed that input field.
-
-
-
-
+{" "}
+
With this, users can interact with documents, webpages, or any other type of content directly from the prompt, which allows for seamless integration of external resources with the language model.
-
-
If working with an interactive (chat-like) flow, remember to keep one of the input variables empty to behave as the chat input.
-
-
-
-
+{" "}
+
diff --git a/docs/docs/index.mdx b/docs/docs/index.mdx
index 4ec4a300d..7be04549c 100644
--- a/docs/docs/index.mdx
+++ b/docs/docs/index.mdx
@@ -6,13 +6,11 @@ import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
-