diff --git a/docs/docs/Agents/agent-tool-calling-agent-component.md b/docs/docs/Agents/agent-tool-calling-agent-component.md index d0c3bdbd9..8e2557e7a 100644 --- a/docs/docs/Agents/agent-tool-calling-agent-component.md +++ b/docs/docs/Agents/agent-tool-calling-agent-component.md @@ -157,11 +157,18 @@ These components support **Tool Mode**: * **Calculator** * **Current date** -If the component you want to use as a tool doesn't have a **Tool Mode** button, add `tool_mode=True` to the component's code under `MessageTextInput`. +If the component you want to use as a tool doesn't have a **Tool Mode** button, add `tool_mode=True` to one of the component's inputs. -For example, in the [components as tools](#components-as-tools) example above, `tool_mode=True,` is added so the custom component can be used as a tool. +Langflow supports **Tool Mode** for the following data types: -**Tool Mode** supports the `MessageTextInput` type. +* `DataInput` +* `DataFrameInput` +* `PromptInput` +* `MessageTextInput` +* `MultilineInput` +* `DropdownInput` + +For example, in the [components as tools](#components-as-tools) example above, `tool_mode=True,` is added to the `MultilineInput` input so the custom component can be used as a tool. ```python inputs = [ diff --git a/docs/docs/Components/_category_.json b/docs/docs/Components/_category_.json deleted file mode 100644 index 62531e49e..000000000 --- a/docs/docs/Components/_category_.json +++ /dev/null @@ -1 +0,0 @@ -{"position":6, "label":"Components"} \ No newline at end of file diff --git a/docs/docs/Components/components-agents.md b/docs/docs/Components/components-agents.md index 53b73768f..e1f782e9c 100644 --- a/docs/docs/Components/components-agents.md +++ b/docs/docs/Components/components-agents.md @@ -6,12 +6,30 @@ slug: /components-agents # Agent components in Langflow -Agent components are used to define the behavior and capabilities of AI agents in your flow. Agents can interact with APIs, databases, and other services and use LLMs as a reasoning engine to decide which course to take in your flow. +Agent components define the behavior and capabilities of AI agents in your flow. + +Agents use LLMs as a reasoning engine to decide which of the connected tool components to use to solve a problem. + +Tools in agentic functions are, essentially, functions that the agent can call to perform tasks or access external resources. +A function is wrapped as a `Tool` object, with a common interface the agent understands. +Agents become aware of tools through tool registration, where the agent is provided a list of available tools, typically at agent initialization. The `Tool` object's description tells the agent what the tool can do. + +The agent then uses a connected LLM to reason through the problem to decide which tool is best for the job. + +## Use an agent in a flow + +The [simple agent starter project](/starter-projects-simple-agent) uses an [agent component](#agent-component-agent-component) connected to URL and Calculator tools to answer a user's questions. The OpenAI LLM acts as a brain for the agent to decide which tool to use. Tools are connected to agent components at the **Tools** port. + +![Simple agent starter flow](/img/starter-flow-simple-agent.png) + +For a multi-agent example, see [Create a problem-solving agent](/agents-tool-calling-agent-component). ## Agent component {#agent-component} This component creates an agent that can use tools to answer questions and perform tasks based on given instructions. +The component includes an LLM model integration, a system message prompt, and a **Tools** port to connect tools to extend its capabilities. + For more information on this component, see the [tool calling agent documentation](/agents-tool-calling-agent-component). ### Inputs diff --git a/docs/docs/Components/components-custom-components.md b/docs/docs/Components/components-custom-components.md index 20a85337f..385abae02 100644 --- a/docs/docs/Components/components-custom-components.md +++ b/docs/docs/Components/components-custom-components.md @@ -1,18 +1,15 @@ --- -title: Custom Components -sidebar_position: 8 +title: Create custom components slug: /components-custom-components --- -# Custom Components - Custom components are created within Langflow and extend the platform's functionality with custom, reusable Python code. Since Langflow operates with Python behind the scenes, you can implement any Python function within a Custom Component. This means you can leverage the power of libraries such as Pandas, Scikit-learn, Numpy, and thousands of other packages to create components that handle data processing in unlimited ways. You can use any type as long as the type is properly annotated in the output methods (e.g., `> list[int]`). Custom Components create reusable and configurable components to enhance the capabilities of Langflow, making it a powerful tool for developing complex processing between user and AI messages. -## How to Create Custom Components +## Create a custom component in Langflow Creating custom components in Langflow involves creating a Python class that defines the component's functionality, inputs, and outputs. The default code provides a working structure for your custom component. diff --git a/docs/docs/Components/components-data.md b/docs/docs/Components/components-data.md index 87ea75ac7..21566653f 100644 --- a/docs/docs/Components/components-data.md +++ b/docs/docs/Components/components-data.md @@ -4,15 +4,32 @@ sidebar_position: 3 slug: /components-data --- +# Data components in Langflow + +Data components load data from a source into your flow. + +They may perform some processing or type checking, like converting raw HTML data into text, or ensuring your loaded file is of an acceptable type. + +## Use a data component in a flow + +The **URL** data component loads content from a list of URLs. + +In the component's **URLs** field, enter a comma-separated list of URLs you want to load. Alternatively, connect a component that outputs the `Message` type, like the **Chat Input** component, to supply your URLs with a component. + +To output a `Data` type, in the **Output Format** dropdown, select **Raw HTML**. +To output a `Message` type, in the **Output Format** dropdown, select **Text**. This option applies postprocessing with the `data_to_text` helper function. + +In this example of a document ingestion pipeline, the URL component outputs raw HTML to a text splitter, which splits the raw content into chunks for a vector database to ingest. + +![URL component in a data ingestion pipeline](/img/url-component.png) + ## API Request This component sends HTTP requests to the specified URLs. Use this component to interact with external APIs or services and retrieve data. Ensure that the URLs are valid and that you configure the method, headers, body, and timeout correctly. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | | ------- | ------------ | -------------------------------------------------------------------------- | @@ -27,7 +44,7 @@ Use this component to interact with external APIs or services and retrieve data. This component recursively loads files from a directory, with options for file types, depth, and concurrency. -### Parameters +### Inputs | Input | Type | Description | | ------------------ | ---------------- | -------------------------------------------------- | @@ -40,6 +57,9 @@ This component recursively loads files from a directory, with options for file t | silent_errors | BoolInput | If true, errors will not raise an exception | | use_multithreading | BoolInput | If true, multithreading will be used | + +### Outputs + | Output | Type | Description | | ------ | ---------- | ----------------------------------- | | data | List[Data] | Loaded file data from the directory | @@ -48,16 +68,14 @@ This component recursively loads files from a directory, with options for file t The FileComponent is a class that loads and parses text files of various supported formats, converting the content into a Data object. It supports multiple file types and provides an option for silent error handling. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | | ------------- | ------------- | -------------------------------------------- | | path | Path | File path to load. | | silent_errors | Silent Errors | If true, errors will not raise an exception. | -#### Outputs +### Outputs | Name | Display Name | Info | | ---- | ------------ | -------------------------------------------- | @@ -67,15 +85,13 @@ The FileComponent is a class that loads and parses text files of various support The URLComponent is a class that fetches content from one or more URLs, processes the content, and returns it as a list of Data objects. It ensures that the provided URLs are valid and uses WebBaseLoader to fetch the content. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | | ---- | ------------ | ---------------------- | | urls | URLs | Enter one or more URLs | -#### Outputs +### Outputs | Name | Display Name | Info | | ---- | ------------ | ------------------------------------------------------------ | @@ -87,7 +103,7 @@ This component loads emails from Gmail using provided credentials and filters. For more on creating a service account JSON, see [Service Account JSON](https://developers.google.com/identity/protocols/oauth2/service-account). -### Parameters +### Inputs | Input | Type | Description | | ----------- | ---------------- | ------------------------------------------------------------------------------------ | @@ -95,6 +111,8 @@ For more on creating a service account JSON, see [Service Account JSON](https:// | label_ids | MessageTextInput | Comma-separated list of label IDs to filter emails | | max_results | MessageTextInput | Maximum number of emails to load | +### Outputs + | Output | Type | Description | | ------ | ---- | ----------------- | | data | Data | Loaded email data | @@ -105,13 +123,15 @@ This component loads documents from Google Drive using provided credentials and For more on creating a service account JSON, see [Service Account JSON](https://developers.google.com/identity/protocols/oauth2/service-account). -### Parameters +### Inputs | Input | Type | Description | | ----------- | ---------------- | ------------------------------------------------------------------------------------ | | json_string | SecretStrInput | JSON string containing OAuth 2.0 access token information for service account access | | document_id | MessageTextInput | Single Google Drive document ID | +### Outputs + | Output | Type | Description | | ------ | ---- | -------------------- | | docs | Data | Loaded document data | @@ -122,7 +142,7 @@ This component searches Google Drive files using provided credentials and query For more on creating a service account JSON, see [Service Account JSON](https://developers.google.com/identity/protocols/oauth2/service-account). -### Parameters +### Inputs | Input | Type | Description | | -------------- | ---------------- | ------------------------------------------------------------------------------------ | @@ -132,6 +152,8 @@ For more on creating a service account JSON, see [Service Account JSON](https:// | search_term | MessageTextInput | The value to search for in the specified query item | | query_string | MessageTextInput | The query string used for searching (can be edited manually) | +### Outputs + | Output | Type | Description | | ---------- | --------- | ----------------------------------------------- | | doc_urls | List[str] | URLs of the found documents | @@ -145,15 +167,13 @@ This component defines a webhook input for the flow. The flow can be triggered b If the input is not valid JSON, the component will wrap it in a "payload" field. The component's status will reflect any errors or the processed data. -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ---- | ------ | ---------------------------------------------- | | data | String | JSON payload for testing the webhook component | -#### Outputs +### Outputs | Name | Type | Description | | ----------- | ---- | ------------------------------------- | diff --git a/docs/docs/Components/components-embedding-models.md b/docs/docs/Components/components-embedding-models.md index b44394ced..556651294 100644 --- a/docs/docs/Components/components-embedding-models.md +++ b/docs/docs/Components/components-embedding-models.md @@ -1,12 +1,22 @@ --- -title: Embedding Models +title: Embeddings sidebar_position: 6 slug: /components-embedding-models --- -# Embedding Models +# Embeddings models in Langflow -Embeddings models are used to convert text into numerical vectors. These vectors can be used for various tasks such as similarity search, clustering, and classification. +Embeddings models convert text into numerical vectors. These embeddings capture semantic meaning of the input text, and allow LLMs to understand context. + +Refer to your specific component's documentation for more information on parameters. + +## Use an embeddings model component in a flow + +In this example of a document ingestion pipeline, the **OpenAI** embeddings model is connected to a vector database. The component converts the text chunks into vectors and stores them in the vector database. The vectorized data can be used to inform AI workloads like chatbots, similarity searches, and agents. + +This embeddings component uses an OpenAI API key for authentication. Refer to your specific embeddings component's documentation for more information on authentication. + +![URL component in a data ingestion pipeline](/img/url-component.png) ## AI/ML diff --git a/docs/docs/Components/components-helpers.md b/docs/docs/Components/components-helpers.md index 77234609a..d2a67fe4e 100644 --- a/docs/docs/Components/components-helpers.md +++ b/docs/docs/Components/components-helpers.md @@ -4,17 +4,66 @@ sidebar_position: 4 slug: /components-helpers --- -# Helpers +# Helper components in Langflow Helper components provide utility functions to help manage data, tasks, and other components in your flow. -## Chat Memory +## Use a helper component in a flow + +Chat memory in Langflow is stored either in local Langflow tables with `LCBufferMemory`, or connected to an external database. + +The **Store Message** helper component stores chat memories as [Data](/guides-data-message) objects, and the **Message History** helper component retrieves chat messages as data objects or strings. + +This example flow stores and retrieves chat history from an [AstraDBChatMemory](/components-memories#astradbchatmemory-component) component with **Store Message** and **Chat Memory** components. + +![Sample Flow storing Chat Memory in AstraDB](/img/astra_db_chat_memory_rounded.png) + +## Create List + +This component dynamically creates a record with a specified number of fields. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| n_fields | Number of Fields | Number of fields to be added to the record. | +| text_key | Text Key | Key used as text. | + +## Current date + +The Current Date component returns the current date and time in a selected timezone. This component provides a flexible way to obtain timezone-specific date and time information within a Langflow pipeline. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +|timezone|Timezone|Select the timezone for the current date and time. + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +|current_date|Current Date|The resulting current date and time in the selected timezone. + +## ID Generator + +This component generates a unique ID. + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +| value | Value | Unique ID generated. | + +## Message history + +:::info +Prior to Langflow 1.1, this component was known as the Chat Memory component. +::: This component retrieves and manages chat messages from Langflow tables or an external memory. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -26,201 +75,13 @@ This component retrieves and manages chat messages from Langflow tables or an ex | order | Order | Order of the messages. | | template | Template | The template to use for formatting the data. It can contain the keys `{text}`, `{sender}` or any other key in the message data. | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| | messages | Messages (Data) | Retrieved messages as Data objects. | | messages_text | Messages (Text) | Retrieved messages formatted as text. | -| lc_memory | Memory | Built LangChain memory object. | - -## Combine Text - -This component concatenates two text sources into a single text chunk using a specified delimiter. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| first_text | First Text | The first text input to concatenate. | -| second_text | Second Text | The second text input to concatenate. | -| delimiter | Delimiter | A string used to separate the two text inputs. Defaults to a space. | - -## Create List - -This component dynamically creates a record with a specified number of fields. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| n_fields | Number of Fields | Number of fields to be added to the record. | -| text_key | Text Key | Key used as text. | - -## Custom Component - -Use this component as a template to create your custom component. - -For more, see [Custom Components](components-custom-components). - -## Filter Data - -This component filters a Data object based on a list of keys. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| data | Data | Data object to filter. | -| filter_criteria | Filter Criteria | List of keys to filter by. | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| filtered_data | Filtered Data | A new Data object containing only the key-value pairs that match the filter criteria. | - -## Hierarchical Task - -This component creates and manages hierarchical tasks for CrewAI agents in a Playground environment. - -For more information, see the [CrewAI documentation](https://docs.crewai.com/how-to/Hierarchical/). - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| task_description | Description | Descriptive text detailing task's purpose and execution. | -| expected_output | Expected Output | Clear definition of expected task outcome. | -| tools | Tools | List of tools/resources limited for task execution. Uses the Agent tools by default. | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| task_output | Task | The built hierarchical task. | - -## ID Generator - -This component generates a unique ID. - -### Parameters - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| value | Value | Unique ID generated. | - -## Parse JSON - -This component converts and extracts JSON fields using JQ queries. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| input_value | Input | Data object to filter. Can be a Message or Data object. | -| query | JQ Query | JQ Query to filter the data. The input is always a JSON list. | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| filtered_data | Filtered Data | Filtered data as a list of Data objects. | - -## Merge Data - -This component combines multiple data sources into a single unified Data object. - -The component iterates through the input list of Data objects, merging them into a single Data object. If the input list is empty, it returns an empty Data object. If there's only one input Data object, it returns that object unchanged. The merging process uses the addition operator to combine Data objects. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| data | Data | A list of Data objects to be merged | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| merged_data | Merged Data | A single Data object containing the combined information from all input Data objects | - - -## Parse Data - -The ParseData component converts Data objects into plain text using a specified template. -This component transforms structured data into human-readable text formats, allowing for customizable output through the use of templates. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| data | Data | The data to convert to text | -| template | Template | The template to use for formatting the data. It can contain the keys `{text}`, `{data}` or any other key in the Data | -| sep | Separator | The separator to use between multiple data items | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| text | Text | The resulting formatted text string as a Message object | - -## Sequential Task - -This component creates and manage sequential tasks for CrewAI agents. It builds a SequentialTask object with the provided description, expected output, and agent, allowing for the specification of tools and asynchronous execution. - -For more information, see the [CrewAI documentation](https://docs.crewai.com/how-to/Sequential/). - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| task_description | Description | Descriptive text detailing task's purpose and execution. | -| expected_output | Expected Output | Clear definition of expected task outcome. | -| tools | Tools | List of tools/resources limited for task execution. Uses the Agent tools by default. | -| agent | Agent | CrewAI Agent that will perform the task. | -| task | Task | CrewAI Task that will perform the task. | -| async_execution | Async Execution | Boolean flag indicating asynchronous task execution. | - -#### Outputs - -| Name | Display Name | Info | -|------|--------------|------| -| task_output | Task | The built sequential task or list of tasks. | - -## Split Text - -This component splits text into chunks of a specified length. - -### Parameters - -#### Inputs - -| Name | Display Name | Info | -|------|--------------|------| -| texts | Texts | Texts to split. | -| separators | Separators | Characters to split on. Defaults to a space. | -| max_chunk_size | Max Chunk Size | The maximum length (in characters) of each chunk. | -| chunk_overlap | Chunk Overlap | The amount of character overlap between chunks. | -| recursive | Recursive | Whether to split recursively. | +| lc_memory | Memory | A constructed Langchain [ConversationBufferMemory](https://api.python.langchain.com/en/latest/memory/langchain.memory.buffer.ConversationBufferMemory.html) object | ## Store Message @@ -228,9 +89,7 @@ This component stores chat messages or text into Langflow tables or an external It provides flexibility in managing message storage and retrieval within a chat system. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -240,8 +99,26 @@ It provides flexibility in managing message storage and retrieval within a chat | sender_name | Sender Name | The name of the sender. Can be AI or User. If empty, the current sender parameter will be used. | | session_id | Session ID | The session ID of the chat. If empty, the current session ID parameter will be used. | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| | stored_messages | Stored Messages | The list of stored messages after the current message has been added. | + +## Structured output + +This component transforms LLM responses into structured data formats. + +### Input + +| Name | Display Name | Info | +|------|--------------|------| +| llm | Language Model | The language model to use to generate the structured output. | +| input_value | Input message | The input message for the language model to process. | +| schema_name | Schema Name | Provide a name for the output data schema. | +| output_schema | Output Schema | Define the structure and data types for the model's output. | +| multiple | Generate Multiple | Set to True if the model should generate a list of outputs instead of a single output. | + +### Output + +| structured_output | Structured Output | The resulting structured output based on the defined schema. | diff --git a/docs/docs/Components/components-io.md b/docs/docs/Components/components-io.md index 2b8f22c8d..1d12b7963 100644 --- a/docs/docs/Components/components-io.md +++ b/docs/docs/Components/components-io.md @@ -1,89 +1,100 @@ --- -title: Inputs & Outputs +title: Inputs and outputs sidebar_position: 1 slug: /components-io --- -# Inputs & Outputs +# Input and output components in Langflow This category of components defines where data enters and exits your flow. They dynamically alter 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 various sources, such as users, databases, or any other source that can be converted to Text or Data. +The difference between Chat Input and Text Input components is the output format, the number of configurable fields, and the way they are displayed in the Playground. ### Chat Input This component collects user input from the chat. -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. +The Chat Input component creates a [Message](/guides-data-message) object that includes the input text, sender information, session ID, file attachments, and styling properties. It can optionally store the message in a chat history and supports customization of the message appearance. -Chat Input components can output Text or Data. When you want to pass the sender name or sender to the next component, use the Data output. To pass only the message, use the Text output. Passing only the message is useful when saving the message to a database or a memory system like Zep. +### Inputs -#### Parameters +| Name | Display Name | Info | Type | +|------|--------------|------|------| +|input_value|Text|Message to be passed as input.|MultilineInput| +|should_store_message|Store Messages|Store the message in the history.|BoolInput| +|sender|Sender Type|Type of sender.|DropdownInput| +|sender_name|Sender Name|Name of the sender.|MessageTextInput| +|session_id|Session ID|The session ID of the chat. If empty, the current session ID parameter will be used.|MessageTextInput| +|files|Files|Files to be sent with the message.|FileInput| +|background_color|Background Color|The background color of the icon.|MessageTextInput| +|chat_icon|Icon|The icon of the message.|MessageTextInput| +|text_color|Text Color|The text color of the name|MessageTextInput| -| Name | Display Name | Info | -|--------------|--------------|---------------------------------------------------------------------| -| Sender Type | Sender Type | Specifies the sender type (User or Machine). Defaults to User | -| Sender Name | Sender Name | Specifies the name of the sender. Defaults to User | -| Message | Message | Specifies the message text. Multiline text input | -| Session ID | Session ID | Specifies the session ID of the chat history | +### Outputs -:::note -If "As Data" is true and the "Message" is a Data, the data will be updated with the Sender, Sender Name, and Session ID. -::: +| Name | Display Name | Info | +|------|--------------|------| +|message|Message|The resulting chat message object with all specified properties.| -### Text Input +## Text Input -This component adds an Input field on the Playground, allowing parameter definition while running and testing your flow. +The Text Input component adds an Input field on the Playground. -The Data Template field specifies how a Data should be converted into Text. This is particularly useful when you want to extract specific information from a Data and pass it as text to the next component in the sequence. +The Text Input component offers one input field for text, while the Chat Input has multiple fields for various chat-related features. -For example, if you have a Data with the following structure: +### Inputs -```json -{ "name": "John Doe", "age": 30, "email": "johndoe@email.com"} -``` +| Name | Display Name | Info | Type | +|------|--------------|------|------| +|input_value|Text|Text to be passed as input.|MultilineInput| -A template with Name: `{name}, Age: {age}` will convert the Data into a text string of `Name: John Doe, Age: 30`. +### Outputs -If you pass more than one Data, the text will be concatenated with a new line separator. +| Name | Display Name | Info | +|------|--------------|------| +|text|Text|The resulting text message.| -#### Parameters -| Name | Display Name | Info | -|---------------|---------------|--------------------------------------------------------------------| -| Value | Value | Specifies the text input value. Defaults to an empty string | -| Data Template | Data Template | Specifies how a Data should be converted into Text | +## Chat Output + +The Chat Output component creates a [Message](/guides-data-message) object that includes the input text, sender information, session ID, and styling properties. It can optionally store the message in a chat history and supports customization of the message appearance, including background color, icon, and text color. + +### Inputs + +| Name | Display Name | Info | Type | +|------|--------------|------|------| +|input_value|Text|Message to be passed as output.|MessageInput| +|should_store_message|Store Messages|Store the message in the history.|BoolInput| +|sender|Sender Type|Type of sender.|DropdownInput| +|sender_name|Sender Name|Name of the sender.|MessageTextInput| +|session_id|Session ID|The session ID of the chat. If empty, the current session ID parameter will be used.|MessageTextInput| +|data_template|Data Template|Template to convert data to text. If left empty, it will be dynamically set to the data's text key.|MessageTextInput| +|background_color|Background Color|The background color of the icon.|MessageTextInput| +|chat_icon|Icon|The icon of the message.|MessageTextInput| +|text_color|Text Color|The text color of the name|MessageTextInput| + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +|message|Message|The resulting chat message object with all specified properties.| + + +## Text Output + +The TextOutputComponent displays text output in the **Playground**. It takes a single input of text and returns a [Message](/guides-data-message) object containing that text. The component is simpler compared to the Chat Output, but focuses solely on displaying text without additional chat-specific features or customizations. + +## Inputs + +| Name | Display Name | Info | Type | +|------|--------------|------|------| +|input_value|Text|Text to be passed as output.|MultilineInput| ## Outputs -Outputs define where data exits your flow. They can send data to the user, the Playground, or define how data will be displayed in the Playground. +| Name | Display Name | Info | +|------|--------------|------| +|text|Text|The resulting text message.| -### Chat Output -This component sends a message to the chat. - -#### Parameters - -| Name | Display Name | Info | -|--------------|--------------|---------------------------------------------------------------------| -| Sender Type | Sender Type | Specifies the sender type (Machine or User). Defaults to Machine | -| Sender Name | Sender Name | Specifies the sender's name. Defaults to AI | -| Session ID | Session ID | Specifies the session ID of the chat history | -| Message | Message | Specifies the text of the message | - -:::note -If "As Data" is true and the "Message" is a Data, the data will be updated with the Sender, Sender Name, and Session ID. -::: - -### Text Output - -This component displays text data to the user without sending it to the chat. Defaults to an empty string. - -#### Parameters - -| Name | Display Name | Info | -|-------|--------------|----------------------------------------------------------| -| Value | Value | Specifies the text data to be displayed | diff --git a/docs/docs/Components/components-loaders.md b/docs/docs/Components/components-loaders.md index 44fad826c..982bdf93e 100644 --- a/docs/docs/Components/components-loaders.md +++ b/docs/docs/Components/components-loaders.md @@ -4,17 +4,26 @@ sidebar_position: 10 slug: /components-loaders --- -# Loaders +# Loader components in Langflow -Loaders are components used to load documents from various sources, such as databases, websites, and local files. They can be used to fetch data from external sources and convert it into a format that can be processed by other components. +:::info +As of Langflow 1.1, loader components are now found in the **Components** menu under **Bundles**. +::: + +Loaders fetch data into Langflow from various sources, such as databases, websites, and local files. + +## Use a loader component in a flow + +This flow creates a question-and-answer chatbot for documents that are loaded into the flow. +The [Unstructured.io](https://unstructured.io/) loader component loads files from your local machine, and then parses them into a list of structured [Data](/guides-data-message) objects. This loaded data informs the **Open AI** component's responses to your questions. + +![Sample Flow retrieving data with unstructured](/img/starter-flow-unstructured-qa.png) ## Confluence The Confluence component integrates with the Confluence wiki collaboration platform to load and process documents. It utilizes the ConfluenceLoader from LangChain to fetch content from a specified Confluence space. -### Parameters - -#### Inputs: +### Inputs: | Name | Display Name | Info | | --- | --- | --- | @@ -26,7 +35,7 @@ The Confluence component integrates with the Confluence wiki collaboration platf | content_format | Content Format | Specify content format (default: STORAGE) | | max_pages | Max Pages | Maximum number of pages to retrieve (default: 1000) | -#### Outputs: +### Outputs: | Name | Display Name | Info | | --- | --- | --- | @@ -36,9 +45,7 @@ The Confluence component integrates with the Confluence wiki collaboration platf The GitLoader component uses the GitLoader from LangChain to fetch and load documents from a specified Git repository. -### Parameters - -#### Inputs: +### Inputs: | Name | Display Name | Info | | --- | --- | --- | @@ -48,7 +55,7 @@ The GitLoader component uses the GitLoader from LangChain to fetch and load docu | file_filter | File Filter | Patterns to filter files (e.g., '.py' to include only .py files, '!.py' to exclude .py files) | | content_filter | Content Filter | A regex pattern to filter files based on their content | -#### Outputs: +### Outputs: | Name | Display Name | Info | | --- | --- | --- | @@ -56,18 +63,19 @@ The GitLoader component uses the GitLoader from LangChain to fetch and load docu ## Unstructured -This component uses the [Unstructured.io](https://unstructured.io/) Serverless API to load and parse files into structured data. +This component uses the [Unstructured.io](https://unstructured.io/) Serverless API to load and parse files into a list of structured [Data](/guides-data-message) objects. -### Parameters - -#### Inputs: +### Inputs: | Name | Display Name | Info | | --- | --- | --- | | file | File | The path to the file to be parsed (supported types are listed [here](https://docs.unstructured.io/api-reference/api-services/overview#supported-file-types)) | | api_key | API Key | Unstructured.io Serverless API Key | +| api_url | Unstructured.io API URL | Optional URL for the Unstructured API | +| chunking_strategy | Chunking Strategy | Strategy for chunking the document (options: "", "basic", "by_title", "by_page", "by_similarity") | +| unstructured_args | Additional Arguments | Optional dictionary of additional arguments for the Unstructured.io API | -#### Outputs: +### Outputs: | Name | Display Name | Info | | --- | --- | --- | diff --git a/docs/docs/Components/components-logic.md b/docs/docs/Components/components-logic.md index 3ab9002ad..6641d1659 100644 --- a/docs/docs/Components/components-logic.md +++ b/docs/docs/Components/components-logic.md @@ -3,6 +3,7 @@ title: Logic sidebar_position: 13 slug: /components-logic --- + # Logic components in Langflow Logic components provide functionalities for routing, conditional processing, and flow management. diff --git a/docs/docs/Components/components-memories.md b/docs/docs/Components/components-memories.md index 5dfd45d0a..6495b7e0f 100644 --- a/docs/docs/Components/components-memories.md +++ b/docs/docs/Components/components-memories.md @@ -1,14 +1,29 @@ -# Memories +--- +title: Memories +slug: /components-memories +--- -Chat memory components store and retrieve chat messages by `session_id`. +# Memory components in Langflow + +Memory components store and retrieve chat messages by `session_id`. + +They are distinct from vector store components, because they are built specifically for storing and retrieving chat messages from external databases. + +Memory components provide access to their respective external databases **as memory**. This allows Large Language Models (LLMs) or [agents](/components-agents) to access external memory for persistence and context retention. + +## Use a memory component in a flow + +This example flow stores and retrieves chat history from an **Astra DB Chat Memory** component with **Store Message** and **Chat Memory** components. + +The **Store Message** helper component stores chat memories as [Data](/guides-data-message) objects, and the **Message History** helper component retrieves chat messages as [Data](/guides-data-message) objects or strings. + +![Sample Flow storing Chat Memory in AstraDB](/img/astra_db_chat_memory_rounded.png) ## AstraDBChatMemory Component -This component creates an `AstraDBChatMessageHistory` instance, which allows for storing and retrieving chat messages using Astra DB, a cloud-native database service. +This component creates an `AstraDBChatMessageHistory` instance, which stores and retrieves chat messages using Astra DB, a cloud-native database service. -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |------------------|---------------|-----------------------------------------------------------------------| @@ -18,7 +33,7 @@ This component creates an `AstraDBChatMessageHistory` instance, which allows for | namespace | String | Optional namespace within Astra DB for the collection. | | session_id | MessageText | Chat session ID. Uses current session ID if not provided. | -#### Outputs +### Outputs | Name | Type | Description | |-----------------|-------------------------|-----------------------------------------------------------| @@ -28,9 +43,7 @@ This component creates an `AstraDBChatMessageHistory` instance, which allows for This component creates a `CassandraChatMessageHistory` instance, enabling storage and retrieval of chat messages using Apache Cassandra or DataStax Astra DB. -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |----------------|---------------|-------------------------------------------------------------------------------| @@ -42,7 +55,7 @@ This component creates a `CassandraChatMessageHistory` instance, enabling storag | session_id | MessageText | Unique identifier for the chat session. Optional. | | cluster_kwargs | Dictionary | Additional keyword arguments for Cassandra cluster configuration. Optional. | -#### Outputs +### Outputs | Name | Type | Description | |-----------------|-------------------------|--------------------------------------------------------------| @@ -52,9 +65,7 @@ This component creates a `CassandraChatMessageHistory` instance, enabling storag This component creates a `ZepChatMessageHistory` instance, enabling storage and retrieval of chat messages using Zep, a memory server for Large Language Models (LLMs). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------|---------------|-----------------------------------------------------------| @@ -63,7 +74,7 @@ This component creates a `ZepChatMessageHistory` instance, enabling storage and | api_base_path | Dropdown | API version to use. Options: "api/v1" or "api/v2". | | session_id | MessageText | Unique identifier for the chat session. Optional. | -#### Outputs +### Outputs | Name | Type | Description | |-----------------|-------------------------|-------------------------------------------------------| diff --git a/docs/docs/Components/components-models.md b/docs/docs/Components/components-models.md index 4ae3997e0..8d9c84350 100644 --- a/docs/docs/Components/components-models.md +++ b/docs/docs/Components/components-models.md @@ -4,9 +4,21 @@ sidebar_position: 5 slug: /components-models --- -# Models +# Model components in Langflow -Model components are used to generate text using language models. These components can be used to generate text for various tasks such as chatbots, content generation, and more. +Model components generate text using large language models. + +Refer to your specific component's documentation for more information on parameters. + +## Use a model component in a flow + +Model components receive inputs and prompts for generating text, and the generated text is sent to an output component. + +The model output can also be sent to the **Language Model** port and on to a **Parse Data** component, where the output can be parsed into structured [Data](/guides-data-message) objects. + +This example has the OpenAI model in a chatbot flow. For more information, see the [Basic prompting flow](/starter-projects-basic-prompting). + +![](/img/starter-flow-basic-prompting.png) ## AI/ML API @@ -14,9 +26,7 @@ This component creates a ChatOpenAI model instance using the AIML API. For more information, see [AIML documentation](https://docs.aimlapi.com/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |--------------|-------------|---------------------------------------------------------------------------------------------| @@ -28,7 +38,7 @@ For more information, see [AIML documentation](https://docs.aimlapi.com/). | temperature | Float | Controls randomness in the output. Default: 0.1. | | seed | Integer | Controls reproducibility of the job. | -#### Outputs +### Outputs | Name | Type | Description | |-------|---------------|------------------------------------------------------------------| @@ -40,9 +50,7 @@ This component generates text using Amazon Bedrock LLMs. For more information, see [Amazon Bedrock documentation](https://docs.aws.amazon.com/bedrock). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |------------------------|--------------|-------------------------------------------------------------------------------------| @@ -54,7 +62,7 @@ For more information, see [Amazon Bedrock documentation](https://docs.aws.amazon | model_kwargs | Dictionary | Additional keyword arguments for the model (advanced). | | endpoint_url | String | Custom endpoint URL for the Bedrock service (advanced). | -#### Outputs +### Outputs | Name | Type | Description | |-------|---------------|-------------------------------------------------------------------| @@ -66,9 +74,7 @@ This component allows the generation of text using Anthropic Chat and Language m For more information, see the [Anthropic documentation](https://docs.anthropic.com/en/docs/welcome). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------------|-------------|----------------------------------------------------------------------------------------| diff --git a/docs/docs/Components/components-overview.md b/docs/docs/Components/components-overview.md index 53e89bdce..0460515e4 100644 --- a/docs/docs/Components/components-overview.md +++ b/docs/docs/Components/components-overview.md @@ -1,59 +1,93 @@ --- -title: How to build flows with components +title: Components overview sidebar_position: 0 slug: /components-overview --- -A component is a single building block within a flow. It consists of inputs, outputs, and parameters that define their functionality. These elements provide a convenient and straightforward way to compose LLM-based applications. Learn more about components and how they work below. +import Icon from "@site/src/components/icon"; +A component is a single building block within a flow with inputs, outputs, functions, and parameters that define its functionality. A single component is like a class within a larger application. -During the flow creation process, you will notice handles (colored circles) attached to one or both sides of a component. These handles use distinct colors to indicate the types of inputs and outputs that can be interconnected. Hover over a handle to see connection details. +To add a component to a flow, drag it from the **Component** menu to the **Workspace**. +Learn more about components and how they work on this page. + +## Component menu + +Each component is unique, but all have a menu bar at the top that looks something like this. + +Open AI component + +Use these controls to do the following: + +- **Code** — Modify the component's Python code and save your changes. +- **Controls** — Adjust all component parameters. +- **Freeze Path** — After a component runs, lock its previous output state to prevent it from re-running. + +Click  **All** to see additional options for a component. + +To view a component’s output and logs, click the **Visibility** icon. + +To run a single component, click ▶️ **Play**. A ✅**Check** indicates that the component ran successfully. + +## Component ports + +Handles () on the side of a component indicate the types of inputs and outputs that can be connected at that port. Hover over a handle to see connection details. Prompt component +### Component port data type colors -On the top right corner of the component, you'll find the a play button to run a component. Once it runs, a status icon appears and you can hover over that to visualize success or error messages. Start interacting with your AI by clicking the **Playground** at the bottom right of the workspace. +The following table lists the handle colors and their corresponding data types: + +| Data Type | Handle Color | Hex Code | +|-----------|--------------|----------| +| BaseLanguageModel | Fuchsia | #c026d3 | +| Data | Red | #dc2626 | +| Document | Lime | #65a30d | +| Embeddings | Emerald | #10b981 | +| LanguageModel | Fuchsia | #c026d3 | +| Message | Indigo | #4f46e5 | +| Prompt | Violet | #7c3aed | +| str | Indigo | #4F46E5 | +| Text | Indigo | #4F46E5 | +| unknown | Gray | #9CA3AF | -## Component menu {#7e3f2f8ff5074b2fb3eee97c9cfaabe7} +## Freeze Path + +After a component runs, **Freeze Path** locks the component's previous output state to prevent it from re-running. + +If you’re expecting consistent output from a component and don’t need to re-run it, click **Freeze Path**. + +Enabling **Freeze Path** freezes all components downstream of the selected component. -Each component is unique, but they all have a menu bar at the top that looks something like this. +## Additional component options +Click  **All** to see additional options for a component. -Prompt component +To modify a component's name or description, double-click in the **Name** or **Description** fields. Component descriptions accept markdown syntax. +### Component shortcuts -It consists of options such as: +The following keyboard shortcuts are available when a component is selected. -- **Code** — Modify the component's Python code and save it. -- **Controls** — Adjust all parameters of a component. -- **Freeze Path** — After a component runs, lock its previous output state to prevent it from re-running. - -Click **All** (the "..." button) to see all options. - - -## Output preview {#ed7b3c34e0774b8a916b0e68821c9a7a} - - -Langflow includes an output visualizer for components that opens a pop-up screen. This allows you to easily inspect and monitor transmissions between components, providing instant feedback on your workflows. - - -## Advanced settings {#b6430d4903df44f0ba4618a558c83d7b} - - -Langflow components can be edited by clicking the **Advanced Settings** button. - - -Hide parameters with the **Show** button to reduce complexity and keep the workspace clean and intuitive for experimentation. - - -You can also double-click a component's name and description to modify those. Component descriptions accept markdown syntax. - - -## Group components {#c3f5ed818e3b40ceb6534dc358e1a5f2} +| Menu Item | Mac Shortcut | Description | +|-----------|----------|-------------| +| Code | ⌘ + C | Opens the code editor for the component. | +| Advanced | ⌘ + A | Opens advanced settings for the component. | +| Save | ⌘ + S | Saves the current state of the component to Saved components in the sidebar. | +| Duplicate | ⌘ + D | Creates a duplicate of the component. | +| Copy | ⌘ + C | Copies the selected component. Paste it in the workspace with ⌘ + V. | +| Docs | ⌘ + D | Opens related documentation. | +| Minimize | ⌘ + Q | Minimizes the current component. | +| Freeze | ⌘ + F | Freezes the current component state. | +| Freeze Path | ⌘ + F | Freezes the current component state and all upstream components. | +| Download | ⌘ + D | Downloads the current component as a JSON file. | +| Delete | ⌘ + ⌫ | Deletes the component. | +## Group components in the workspace Multiple components can be grouped into a single component for reuse. This is useful when combining large flows into single components (like RAG with a vector database, for example) and saving space. @@ -61,11 +95,12 @@ Multiple components can be grouped into a single component for reuse. This is us 2. Select **Group**. 3. The components merge into a single component. 4. Double-click the name and description to change them. -5. Save your grouped component to in the sidebar for later use! +5. Save your grouped component to in the sidebar for later use. -## Component version {#887fd587589448dc8c27336d1c235b9b} +## Component version A component's state is stored in a database, while sidebar components are like starter templates. As soon as you drag a component from the sidebar to the workspace, the two components are no longer in parity. - The component will keep the version number it was initialized to the workspace with. Click the **Update Component** icon (exclamation mark) to bring the component up to the `latest` version. This will change the code of the component in place so you can validate that the component was updated by checking its Python code before and after updating it. + + diff --git a/docs/docs/Components/components-processing.md b/docs/docs/Components/components-processing.md new file mode 100644 index 000000000..efe51b9e8 --- /dev/null +++ b/docs/docs/Components/components-processing.md @@ -0,0 +1,117 @@ +--- +title: Processing +slug: /components-processing +--- + +# Processing components in Langflow + +Processing components process and transform data within a flow. + +## Use a processing component in a flow + +The **Split Text** processing component in this flow splits the incoming [data](/guides-data-message) into chunks to be embedded into the vector store component. + +The component offers control over chunk size, overlap, and separator, which affect context and granularity in vector store retrieval results. + +![](/img/vector-store-document-ingestion.png) + +## Combine Text + +This component concatenates two text sources into a single text chunk using a specified delimiter. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| first_text | First Text | The first text input to concatenate. | +| second_text | Second Text | The second text input to concatenate. | +| delimiter | Delimiter | A string used to separate the two text inputs. Defaults to a space. | + + +## Filter Data + +This component filters a Data object based on a list of keys. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| data | Data | Data object to filter. | +| filter_criteria | Filter Criteria | List of keys to filter by. | + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +| filtered_data | Filtered Data | A new Data object containing only the key-value pairs that match the filter criteria. | + + +## Parse JSON + +This component converts and extracts JSON fields using JQ queries. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| input_value | Input | Data object to filter. Can be a message or data object. | +| query | JQ Query | JQ Query to filter the data. The input is always a JSON list. | + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +| filtered_data | Filtered Data | Filtered data as a list of data objects. | + +## Merge Data component + +This component combines multiple data sources into a single unified Data object. + +The component iterates through the input list of data objects, merging them into a single data object. If the input list is empty, it returns an empty data object. If there's only one input data object, it returns that object unchanged. The merging process uses the addition operator to combine data objects. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| data | Data | A list of data objects to be merged | + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +| merged_data | Merged Data | A single data object containing the combined information from all input data objects | + + +## Parse Data component + +The ParseData component converts data objects into plain text using a specified template. +This component transforms structured data into human-readable text formats, allowing for customizable output through the use of templates. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| data | Data | The data to convert to text. | +| template | Template | The template to use for formatting the data. It can contain the keys `{text}`, `{data}` or any other key in the data. | +| sep | Separator | The separator to use between multiple data items. | + +### Outputs + +| Name | Display Name | Info | +|------|--------------|------| +| text | Text | The resulting formatted text string as a message object. | + + +## Split Text component + +This component splits text into chunks of a specified length. + +### Inputs + +| Name | Display Name | Info | +|------|--------------|------| +| texts | Texts | Texts to split. | +| separators | Separators | Characters to split on. Defaults to a space. | +| max_chunk_size | Max Chunk Size | The maximum length, in characters, of each chunk. | +| chunk_overlap | Chunk Overlap | The amount of character overlap between chunks. | +| recursive | Recursive | Whether to split recursively. | diff --git a/docs/docs/Components/components-prompts.md b/docs/docs/Components/components-prompts.md index 55ff7d747..57ecf2d3e 100644 --- a/docs/docs/Components/components-prompts.md +++ b/docs/docs/Components/components-prompts.md @@ -4,21 +4,42 @@ sidebar_position: 2 slug: /components-prompts --- -# Prompts +# Prompt components in Langflow -A prompt serves as the input to a language model, comprising multiple components that can be parameterized using prompt templates. +A prompt is a structured input to a language model that instructs the model how to handle user inputs and variables. -Prompt templates provide a systematic approach for generating prompts, allowing for reproducible customization through defined input variables. +Prompt components create prompt templates with custom fields and dynamic variables for providing your model structured, repeatable prompts. -### Parameters +Prompts are a combination of natural language and variables created with curly braces. -#### Inputs +## Use a prompt component in a flow + +An example of modifying a prompt can be found in the [Quickstart](/get-started-quickstart#run-the-chatbot-with-retrieved-context), where a basic chatbot flow is extended to include a full vector RAG pipeline. + +![](/img/quickstart-add-document-ingestion.png) + +The default prompt in the **Prompt** component is `Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.` + +This prompt creates a "personality" for your LLM's chat interactions, but it doesn't include variables that you may find useful when templating prompts. + +To modify the prompt template, in the **Prompt** component, click the **Template** field. For example, the `{context}` variable gives the LLM model access to embedded vector data to return better answers. + +```plain +Given the context +{context} +Answer the question +{user_question} +``` + +When variables are added to a prompt template, new fields are automatically created in the component. These fields can be connected to receive text input from other components to automate prompting, or to output instructions to other components. An example of prompts controlling agents behavior is available in the [sequential tasks agent starter flow](/starter-projects-sequential-agent). + +### Inputs | Name | Display Name | Info | |----------|--------------|-------------------------------------------------------------------| | template | Template | Create a prompt template with dynamic variables. | -#### Outputs +### Outputs | Name | Display Name | Info | |--------|----------------|--------------------------------------------------------| @@ -30,16 +51,14 @@ This component fetches prompts from the [Langchain Hub](https://docs.smith.langc When a prompt is loaded, the component generates input fields for custom variables. For example, the default prompt "efriis/my-first-prompt" generates fields for `profession` and `question`. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |--------------------|---------------------------|------------------------------------------| | langchain_api_key | Your LangChain API Key | The LangChain API Key to use. | | langchain_hub_prompt| LangChain Hub Prompt | The LangChain Hub prompt to use. | -#### Outputs +### Outputs | Name | Display Name | Info | |--------|--------------|-------------------------------------------------------------------| diff --git a/docs/docs/Components/components-rag.md b/docs/docs/Components/components-rag.md deleted file mode 100644 index 9af9468fb..000000000 --- a/docs/docs/Components/components-rag.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: RAG -sidebar_position: 9 -slug: /components-rag ---- - -RAG (Retrieval-Augmented Generation) components process a user query by retrieving relevant documents and generating a concise summary that addresses the user's question. - -## Vectara RAG - -This component leverages Vectara's Retrieval Augmented Generation (RAG) capabilities to search and summarize documents based on the provided input. For more information, see the [Vectara documentation](https://docs.vectara.com/docs/). - -### Parameters - -#### Inputs - -| Name | Type | Description | -|-----------------------|--------------|------------------------------------------------------------| -| vectara_customer_id | String | Vectara customer ID | -| vectara_corpus_id | String | Vectara corpus ID | -| vectara_api_key | SecretString | Vectara API key | -| search_query | String | The query to receive an answer on | -| lexical_interpolation | Float | Hybrid search factor (0.005 to 0.1) | -| filter | String | Metadata filters to narrow the search | -| reranker | String | Reranker type (mmr, rerank_multilingual_v1, none) | -| reranker_k | Integer | Number of results to rerank (1 to 100) | -| diversity_bias | Float | Diversity bias for MMR reranker (0 to 1) | -| max_results | Integer | Maximum number of search results to summarize (1 to 100) | -| response_lang | String | Language code for the response (e.g., "eng", "auto") | -| prompt | String | Prompt name for summarization | - -#### Outputs - -| Name | Type | Description | -|--------|---------|-----------------------| -| answer | Message | Generated RAG response| \ No newline at end of file diff --git a/docs/docs/Components/components-tools.md b/docs/docs/Components/components-tools.md index 0a6d95a51..e0527b1c2 100644 --- a/docs/docs/Components/components-tools.md +++ b/docs/docs/Components/components-tools.md @@ -1,6 +1,29 @@ -# Tools +--- +title: Tools +slug: /components-tools +--- -Tool components are used to interact with external services, APIs, and tools. They can be used to search the web, query databases, and perform other tasks. +# Tool components in Langflow + +Tools are typically connected to agent components at the **Tools** port. Agents use LLMs as a reasoning engine to decide which of the connected tool components to use to solve a problem. + +Tools in agentic functions are, essentially, functions that the agent can call to perform tasks or access external resources. +A function is wrapped as a `Tool` object, with a common interface the agent understands. +Agents become aware of tools through tool registration, where the agent is provided a list of available tools, typically at agent initialization. The `Tool` object's description tells the agent what the tool can do. + +The agent then uses a connected LLM to reason through the problem to decide which tool is best for the job. + +## Use a tool in a flow + +Tools are typically connected to agent components at the **Tools** port. + +The [simple agent starter project](/starter-projects-simple-agent) uses URL and Calculator tools connected to an [agent component](#agent-component-agent-component) to answer a user's questions. The OpenAI LLM acts as a brain for the agent to decide which tool to use. + +![Simple agent starter flow](/img/starter-flow-simple-agent.png) + +To make a component into a tool that an agent can use, enable **Tool mode** in the component. Enabling **Tool mode** modifies a component input to accept calls from an agent. +If the component you want to connect to an agent doesn't have a **Tool mode** option, you can modify the component's inputs to become a tool. +For an example, see [Make any component a tool](/agents-tool-calling-agent-component#make-any-component-a-tool). ## Bing Search API diff --git a/docs/docs/Components/components-vector-stores.md b/docs/docs/Components/components-vector-stores.md index da8c181d1..b45689099 100644 --- a/docs/docs/Components/components-vector-stores.md +++ b/docs/docs/Components/components-vector-stores.md @@ -1,11 +1,33 @@ --- -title: Vector Stores -sidebar_position: 7 +title: Vector stores slug: /components-vector-stores --- -# Vector Stores -Vector databases are used to store and search for vectors. They can be used to store embeddings, search for similar vectors, and perform other vector operations. +# Vector store components in Langflow + +Vector databases store vector data, which backs AI workloads like chatbots and Retrieval Augmented Generation. + +Vector database components establish connections to existing vector databases or create in-memory vector stores for storing and retrieving vector data. + +Vector database components are distinct from [memory components](/components-memories), which are built specifically for storing and retrieving chat messages from external databases. + +## Use a vector store component in a flow + +Vector databases can be populated from within Langflow with document ingestion pipelines, like the following + +![](/img/vector-store-document-ingestion.png) + +This example uses the **Astra DB vector store** component. Your vector store component's parameters and authentication may be different, but the document ingestion workflow is the same. A document is loaded from a local machine and chunked. The Astra DB vector store generates embeddings with the connected [model](/components-models) component, and stores them in the connected Astra DB database. + +This vector data can then be retrieved for workloads like Retrieval Augmented Generation. + +![](/img/vector-store-retrieval.png) + +The user's chat input is embedded and compared to the vectors embedded during document ingestion for a similarity search. The results are output from the vector database component as a [Data](/guides-data-message) object, and parsed into text. This text fills the `{context}` variable in the **Prompt** component, which informs the **Open AI model** component's responses. + +Alternatively, connect the vector database component's **Retriever** port to a [retriever tool](components-tools#retriever-tool), and then to an [agent](/components-agents) component. This enables the agent to use your vector database as a tool and make decisions based on the available data. + +![](/img/vector-store-agent-retrieval-tool.png) ## Astra DB Vector Store @@ -13,9 +35,7 @@ This component implements a Vector Store using Astra DB with search capabilities For more information, see the [DataStax documentation](https://docs.datastax.com/en/astra-db-serverless/databases/create-database.html). -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -37,7 +57,7 @@ For more information, see the [DataStax documentation](https://docs.datastax.com | search_score_threshold | Search Score Threshold | Minimum similarity score threshold for search results | | search_filter | Search Metadata Filter | Optional dictionary of filters to apply to the search query | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| @@ -49,9 +69,7 @@ For more information, see the [DataStax documentation](https://docs.datastax.com This component creates a Cassandra Vector Store with search capabilities. For more information, see the [Cassandra documentation](https://cassandra.apache.org/doc/latest/cassandra/vector-search/overview.html). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |------|------|-------------| @@ -74,7 +92,7 @@ For more information, see the [Cassandra documentation](https://cassandra.apache | body_search | String | Document textual search terms | | enable_body_search | Boolean | Flag to enable body search | -#### Outputs +### Outputs | Name | Type | Description | |------|------|-------------| @@ -85,9 +103,7 @@ For more information, see the [Cassandra documentation](https://cassandra.apache This component implements a Cassandra Graph Vector Store with search capabilities. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -107,7 +123,7 @@ This component implements a Cassandra Graph Vector Store with search capabilitie | search_score_threshold | Search Score Threshold | Minimum similarity score threshold for search results (for "Similarity with score threshold" search type) | | search_filter | Search Metadata Filter | Optional dictionary of filters to apply to the search query | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| @@ -119,9 +135,7 @@ This component implements a Cassandra Graph Vector Store with search capabilitie This component creates a Chroma Vector Store with search capabilities. For more information, see the [Chroma documentation](https://docs.trychroma.com/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |------------------------------|---------------|--------------------------------------------------| @@ -140,7 +154,7 @@ For more information, see the [Chroma documentation](https://docs.trychroma.com/ | number_of_results | Integer | Number of results to return from the search. Default: 10. | | limit | Integer | Limit the number of records to compare when Allow Duplicates is False. | -#### Outputs +### Outputs | Name | Type | Description | |----------------|---------------|--------------------------------| @@ -152,9 +166,7 @@ For more information, see the [Chroma documentation](https://docs.trychroma.com/ This component implements a Clickhouse Vector Store with search capabilities. For more information, see the [CLickhouse Documentation](https://clickhouse.com/docs/en/intro). -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -175,7 +187,7 @@ For more information, see the [CLickhouse Documentation](https://clickhouse.com/ | number_of_results | Number of Results | Number of results to return in similarity search (default: 4) | | score_threshold | Score threshold | Threshold for similarity scores | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| @@ -187,9 +199,7 @@ For more information, see the [CLickhouse Documentation](https://clickhouse.com/ This component creates a Couchbase Vector Store with search capabilities. For more information, see the [Couchbase documentation](https://docs.couchbase.com/home/index.html). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |-------------------------|---------------|--------------------------------------------------| @@ -205,7 +215,7 @@ For more information, see the [Couchbase documentation](https://docs.couchbase.c | embedding | Embeddings | The embedding function to use for the vector store. | | number_of_results | Integer | Number of results to return from the search. Default: 4 (advanced). | -#### Outputs +### Outputs | Name | Type | Description | |----------------|------------------------|--------------------------------| @@ -216,9 +226,7 @@ For more information, see the [Couchbase documentation](https://docs.couchbase.c This component creates a FAISS Vector Store with search capabilities. For more information, see the [FAISS documentation](https://faiss.ai/index.html). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------------------|---------------|--------------------------------------------------| @@ -230,7 +238,7 @@ For more information, see the [FAISS documentation](https://faiss.ai/index.html) | embedding | Embeddings | The embedding function to use for the vector store. | | number_of_results | Integer | Number of results to return from the search. Default: 4 (advanced). | -#### Outputs +### Outputs | Name | Type | Description | |----------------|------------------------|--------------------------------| @@ -240,9 +248,7 @@ For more information, see the [FAISS documentation](https://faiss.ai/index.html) This component implements a Vector Store using HCD. -### Parameters - -#### Inputs +### Inputs | Name | Display Name | Info | |------|--------------|------| @@ -270,7 +276,7 @@ This component implements a Vector Store using HCD. | search_score_threshold | Search Score Threshold | Minimum similarity score threshold for search results (default: 0) | | search_filter | Search Metadata Filter | Optional dictionary of filters to apply to the search query | -#### Outputs +### Outputs | Name | Display Name | Info | |------|--------------|------| @@ -282,9 +288,7 @@ This component implements a Vector Store using HCD. This component creates a Milvus Vector Store with search capabilities. For more information, see the [Milvus documentation](https://milvus.io/docs). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |-------------------------|---------------|--------------------------------------------------| @@ -305,7 +309,7 @@ For more information, see the [Milvus documentation](https://milvus.io/docs). | vector_dimensions | Integer | Number of dimensions of the vectors | | pre_delete_collection | Boolean | Whether to delete the collection before creating a new one | -#### Outputs +### Outputs | Name | Type | Description | |----------------|------------------------|--------------------------------| @@ -316,9 +320,7 @@ For more information, see the [Milvus documentation](https://milvus.io/docs). This component creates a MongoDB Atlas Vector Store with search capabilities. For more information, see the [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/tutorials/vector-search-quick-start/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ------------------------ | ------------ | ----------------------------------------- | @@ -331,7 +333,7 @@ For more information, see the [MongoDB Atlas documentation](https://www.mongodb. | embedding | Embeddings | Embedding function to use | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ---------------------- | ----------------------------------------- | @@ -344,9 +346,7 @@ For more information, see the [MongoDB Atlas documentation](https://www.mongodb. This component creates a PGVector Vector Store with search capabilities. For more information, see the [PGVector documentation](https://github.com/pgvector/pgvector). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | --------------- | ------------ | ----------------------------------------- | @@ -357,7 +357,7 @@ For more information, see the [PGVector documentation](https://github.com/pgvect | embedding | Embeddings | Embedding function to use | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ----------- | ----------------------------------------- | @@ -370,9 +370,7 @@ For more information, see the [PGVector documentation](https://github.com/pgvect This component creates a Pinecone Vector Store with search capabilities. For more information, see the [Pinecone documentation](https://docs.pinecone.io/home). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ----------------- | ------------ | ----------------------------------------- | @@ -386,7 +384,7 @@ For more information, see the [Pinecone documentation](https://docs.pinecone.io/ | embedding | Embeddings | Embedding function to use | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ---------- | ----------------------------------------- | @@ -399,9 +397,7 @@ For more information, see the [Pinecone documentation](https://docs.pinecone.io/ This component creates a Qdrant Vector Store with search capabilities. For more information, see the [Qdrant documentation](https://qdrant.tech/documentation/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | -------------------- | ------------ | ----------------------------------------- | @@ -422,7 +418,7 @@ For more information, see the [Qdrant documentation](https://qdrant.tech/documen | embedding | Embeddings | Embedding function to use | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | -------- | ----------------------------------------- | @@ -435,9 +431,7 @@ For more information, see the [Qdrant documentation](https://qdrant.tech/documen This component creates a Redis Vector Store with search capabilities. For more information, see the [Redis documentation](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ----------------- | ------------ | ----------------------------------------- | @@ -450,7 +444,7 @@ For more information, see the [Redis documentation](https://redis.io/docs/latest | number_of_results | Integer | Number of results to return in search | | embedding | Embeddings | Embedding function to use | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | -------- | ----------------------------------------- | @@ -463,9 +457,7 @@ For more information, see the [Redis documentation](https://redis.io/docs/latest This component creates a connection to a Supabase Vector Store with search capabilities. For more information, see the [Supabase documentation](https://supabase.com/docs/guides/ai). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ------------------- | ------------ | ----------------------------------------- | @@ -478,7 +470,7 @@ For more information, see the [Supabase documentation](https://supabase.com/docs | embedding | Embeddings | Embedding function to use | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ------------------ | ----------------------------------------- | @@ -491,9 +483,7 @@ For more information, see the [Supabase documentation](https://supabase.com/docs This component creates an Upstash Vector Store with search capabilities. For more information, see the [Upstash documentation](https://upstash.com/docs/introduction). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | --------------- | ------------ | ----------------------------------------- | @@ -507,7 +497,7 @@ For more information, see the [Upstash documentation](https://upstash.com/docs/i | embedding | Embeddings | Embedding function to use (optional) | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ---------------- | ----------------------------------------- | @@ -520,9 +510,7 @@ For more information, see the [Upstash documentation](https://upstash.com/docs/i This component creates a Vectara Vector Store with search capabilities. For more information, see the [Vectara documentation](https://docs.vectara.com/docs/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | | ---------------- | ------------ | ----------------------------------------- | @@ -534,7 +522,7 @@ For more information, see the [Vectara documentation](https://docs.vectara.com/d | search_query | String | Query for similarity search | | number_of_results | Integer | Number of results to return in search | -#### Outputs +### Outputs | Name | Type | Description | | ------------- | ----------------- | ----------------------------------------- | @@ -546,9 +534,7 @@ For more information, see the [Vectara documentation](https://docs.vectara.com/d This component searches a Vectara Vector Store for documents based on the provided input. For more information, see the [Vectara documentation](https://docs.vectara.com/docs/). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------------|--------------|-------------------------------------------| @@ -559,20 +545,45 @@ For more information, see the [Vectara documentation](https://docs.vectara.com/d | vectara_api_key | SecretString | Vectara API key | | files_url | List[String] | Optional URLs for file initialization | -#### Outputs +### Outputs | Name | Type | Description | |----------------|------------|----------------------------| | search_results | List[Data] | Results of similarity search | +## Vectara RAG + +This component leverages Vectara's Retrieval Augmented Generation (RAG) capabilities to search and summarize documents based on the provided input. For more information, see the [Vectara documentation](https://docs.vectara.com/docs/). + +### Inputs + +| Name | Type | Description | +|-----------------------|--------------|------------------------------------------------------------| +| vectara_customer_id | String | Vectara customer ID | +| vectara_corpus_id | String | Vectara corpus ID | +| vectara_api_key | SecretString | Vectara API key | +| search_query | String | The query to receive an answer on | +| lexical_interpolation | Float | Hybrid search factor (0.005 to 0.1) | +| filter | String | Metadata filters to narrow the search | +| reranker | String | Reranker type (mmr, rerank_multilingual_v1, none) | +| reranker_k | Integer | Number of results to rerank (1 to 100) | +| diversity_bias | Float | Diversity bias for MMR reranker (0 to 1) | +| max_results | Integer | Maximum number of search results to summarize (1 to 100) | +| response_lang | String | Language code for the response (for example, "eng", "auto") | +| prompt | String | Prompt name for summarization | + +### Outputs + +| Name | Type | Description | +|--------|---------|-----------------------| +| answer | Message | Generated RAG response| + ## Weaviate This component facilitates a Weaviate Vector Store setup, optimizing text and document indexing and retrieval. For more information, see the [Weaviate Documentation](https://weaviate.io/developers/weaviate). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------|--------------|-------------------------------------------| @@ -585,7 +596,7 @@ For more information, see the [Weaviate Documentation](https://weaviate.io/devel | embedding | Embeddings | Model used | | attributes | List[String] | Optional additional attributes | -#### Outputs +### Outputs | Name | Type | Description | |--------------|------------------|-------------------------------| @@ -598,9 +609,7 @@ For more information, see the [Weaviate Documentation](https://weaviate.io/devel This component searches a Weaviate Vector Store for documents similar to the input. For more information, see the [Weaviate Documentation](https://weaviate.io/developers/weaviate). -### Parameters - -#### Inputs +### Inputs | Name | Type | Description | |---------------|--------------|-------------------------------------------| @@ -614,7 +623,7 @@ For more information, see the [Weaviate Documentation](https://weaviate.io/devel | embedding | Embeddings | Model used | | attributes | List[String] | Optional additional attributes | -#### Outputs +### Outputs | Name | Type | Description | |----------------|------------|----------------------------| diff --git a/docs/docs/Guides/guides-chat-memory.md b/docs/docs/Guides/guides-chat-memory.md index 03019d890..a62fac9fb 100644 --- a/docs/docs/Guides/guides-chat-memory.md +++ b/docs/docs/Guides/guides-chat-memory.md @@ -12,7 +12,7 @@ Langflow allows every chat message to be stored, and a single flow can have mult In any project, as long as there are [**Chat**](/components-io) being used, memories are always being stored by default. These are messages from a user to the AI or vice-versa. -To see and access this history of messages, Langflow features a component called **Chat Memory**. It retrieves previous messages and outputs them in structured format or parsed. +To see and access this history of messages, Langflow features a component called [Message history](/components-helpers#memory-history). It retrieves previous messages and outputs them in structured format or parsed. To learn the basics about memory in Langflow, check out the [Memory Chatbot](/starter-projects-memory-chatbot) starter example. @@ -55,13 +55,13 @@ You can also display all messages stored across every flow and session by going ## Store chat memory in an external database -Chat memory is retrieved from an external database or vector store using the [**Chat Memory**](/components-helpers#chat-memory) component. +Chat memory is retrieved from an external database or vector store using the [Chat Memory](/components-helpers#chat-memory) component. Chat memory is stored to an external database or vector store using the [Store Message](/components-helpers#store-message) component. -The [**Chat Memories**](/Components/components-memories) components provide access to their respective external databases **as memory**. This allows AIs to access external memory for persistence and context retention. For example, connect the **Chat Memory** component to an **AstraDBChatMemory*** component to store the message history in an external Astra DB database. +The [**Chat Memories**](/components-memories) components provide access to their respective external databases **as memory**. This allows AIs to access external memory for persistence and context retention. For example, connect the **Chat Memory** component to an **AstraDBChatMemory** component to store the message history in an external Astra DB database. -This example stores and retrieves chat history from an [AstraDBChatMemory](/Components/components-memories#astradbchatmemory-component) component with **Store Message** and **Chat Memory** components. +This example stores and retrieves chat history from an [AstraDBChatMemory](/components-memories#astradbchatmemory-component) component with **Store Message** and **Chat Memory** components. ### Prerequisites @@ -76,7 +76,7 @@ This example stores and retrieves chat history from an [AstraDBChatMemory](/Comp This starter project extends the basic prompting flow to include a chat memory component. 2. Add the [Store Message](/components-helpers#store-message) component to the flow. The **Store message** component stores messages in the external database. -3. Add the [AstraDBChatMemory Component](/Components/components-memories#astradbchatmemory-component) to the flow. +3. Add the [AstraDBChatMemory Component](/components-memories#astradbchatmemory-component) to the flow. The **Astra DB Chat Memory** component stores and retrieves messages from **Astra DB**. 4. Configure the **AstraDBChatMemory** component with your AstraDB instance details. 1. In the **Astra DB Application Token** field, add your Astra token. (`AstraCS:...`) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 00dc90662..a20004279 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -127,6 +127,10 @@ const config = { to: "/configuration-global-variables", from: "/settings-global-variables", }, + { + to: "/components-vector-stores", + from: "/components-rag", + }, // add more redirects like this // { // to: '/docs/anotherpage', diff --git a/docs/sidebars.js b/docs/sidebars.js index 4cfa5dba6..7eca0c594 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -33,6 +33,26 @@ module.exports = { "Workspace/workspace-playground", ], }, + { + type: "category", + label: "Components", + items: [ + "Components/components-overview", + "Components/components-agents", + "Components/components-data", + "Components/components-embedding-models", + "Components/components-helpers", + "Components/components-io", + "Components/components-loaders", + "Components/components-logic", + "Components/components-memories", + "Components/components-models", + "Components/components-prompts", + "Components/components-tools", + "Components/components-vector-stores", + "Components/components-custom-components", + ], + }, { type: "category", label: "Agents", @@ -55,27 +75,6 @@ module.exports = { "Configuration/configuration-security-best-practices" ], }, - { - type: "category", - label: "Components", - items: [ - "Components/components-overview", - "Components/components-agents", - "Components/components-custom-components", - "Components/components-data", - "Components/components-embedding-models", - "Components/components-helpers", - "Components/components-io", - "Components/components-loaders", - "Components/components-logic", - "Components/components-memories", - "Components/components-models", - "Components/components-prompts", - "Components/components-rag", - "Components/components-tools", - "Components/components-vector-stores", - ], - }, { type: "category", label: "Guides", diff --git a/docs/static/img/url-component.png b/docs/static/img/url-component.png new file mode 100644 index 000000000..1a26605c5 Binary files /dev/null and b/docs/static/img/url-component.png differ diff --git a/docs/static/img/vector-store-agent-retrieval-tool.png b/docs/static/img/vector-store-agent-retrieval-tool.png new file mode 100644 index 000000000..5a4112018 Binary files /dev/null and b/docs/static/img/vector-store-agent-retrieval-tool.png differ diff --git a/docs/static/img/vector-store-document-ingestion.png b/docs/static/img/vector-store-document-ingestion.png new file mode 100644 index 000000000..886d3927a Binary files /dev/null and b/docs/static/img/vector-store-document-ingestion.png differ diff --git a/docs/static/img/vector-store-retrieval.png b/docs/static/img/vector-store-retrieval.png new file mode 100644 index 000000000..6fa36fcc8 Binary files /dev/null and b/docs/static/img/vector-store-retrieval.png differ