⛓️ Langflow

⛓️ Langflow

⛓️ Langflow

⛓️ Langflow

Retrieval Augmented Generation (RAG) using Langflow

Retrieval Augmented Generation (RAG) using Langflow

Retrieval Augmented Generation (RAG) using Langflow

Retrieval Augmented Generation (RAG) using Langflow

Alexandre

Oct 31, 2023

Introduction

Retrieval Augmented Generation (RAG) was introduced to address problems where an LLM needs access to external knowledge sources in order to complete a task.

RAG takes the user query and finds relevant information included in a source, such as a database or PDF files. The retrieved information is combined with the original query and passed to the LLM as context in a prompt to generate a final answer.

LLMs’ parametric knowledge is static, and retrieval-based generation solves this problem by allowing a model to retrieve information that changes over time, avoiding retraining, and creating reliable outputs.

In this tutorial, we will cover how to use Langflow to build a system to retrieve information from a CSV file and generate an answer using RAG.

Langflow components using RAG are available to download at the end of this article.

Using RAG with Langflow

Let's start with the flow from the Community Examples under the name CSV Loader. The image below shows its components.

The process of Retrieval Augmented Generation consists of the explained steps below:


  • Loader: First we need to load information from a source in order to extract knowledge and generate an accurate answer. Langflow contains different types of loaders to start from, such as the WebBaseLoader, TextLoader, PyPDFLoader, etc. Here, we'll extract information from a CSV file using the CSVLoader component.


  • Text Splitter: After loading the information within a document, we need to break it down into chunks of a specific size to feed the vector store. Here, we use Langchain's Recursive Character Text Splitter.


  • Vector Store: The Vector Store is responsible for storing and embedding each chunk separately to allow for similarity searches. Langflow has a range of Vector Store integrations to choose from, such as Chroma, Pinecone, Vectara, and Weaviate.


  • Retrieval: A basic retrieval system will apply a similarity search using the user’s query and concatenate the retrieved chunks to feed an LLM prompt.


  • Generation: The LLM outputs the answer using a prompt that includes both the query and the retrieved knowledge from the document as a context.


The image below displays a table containing each topic of the Langflow documentation.

To check if the LLM is giving the correct answer, let’s ask the question “What is Langflow?”.

We can confirm that the agent retrieved the information from the csv file and output a correct answer. Indeed, this information can be found in Langflow’s documentation.


Now, let’s ask another question to test it again.

Once again, the knowledge was correctly retrieved from the document and the answer is correct.


Finally, we input a final question asking “What are agents in langflow?”.

We can note in the agent’s thoughts (white square content) that the agent didn’t know the answer in the first iteration, and then it called the Vector Store component named CSV to retrieve the knowledge needed to answer this question.


Thus, RAG is a powerful tool to combine with LLMs in order or retrieve information and knowledge about a specific topic.

Download Links (Gists):

{"name":"csv loader","description":"Load a CSV file and start asking questions about it.","data":{"nodes":[{"width":384,"height":290,"id":"VectorStoreAgent-y0gVB","type":"genericNode","position":{"x":1759.0521504033006,"y":-1084.8109307754983},"data":{"type":"VectorStoreAgent","node":{"template":{"llm":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"llm","display_name":"LLM","advanced":false,"dynamic":false,"info":"","type":"BaseLanguageModel","list":false},"vectorstoreinfo":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"vectorstoreinfo","display_name":"Vector Store Info","advanced":false,"dynamic":false,"info":"","type":"VectorStoreInfo","list":false},"_type":"vectorstore_agent"},"description":"Construct an agent from a Vector Store.","base_classes":["AgentExecutor"],"display_name":"VectorStoreAgent","documentation":""},"id":"VectorStoreAgent-y0gVB","value":null},"selected":false,"positionAbsolute":{"x":1759.0521504033006,"y":-1084.8109307754983}},{"width":384,"height":414,"id":"VectorStoreInfo-Sxevb","type":"genericNode","position":{"x":1196.8213224104938,"y":-1126.393770900602},"data":{"type":"VectorStoreInfo","node":{"template":{"vectorstore":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"vectorstore","advanced":false,"dynamic":false,"info":"","type":"VectorStore","list":false},"description":{"required":true,"placeholder":"","show":true,"multiline":true,"password":false,"name":"description","advanced":false,"dynamic":false,"info":"","type":"str","list":false,"value":"Information about a CSV File"},"name":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"name","advanced":false,"dynamic":false,"info":"","type":"str","list":false,"value":"CSV"},"_type":"VectorStoreInfo"},"description":"Information about a VectorStore.","base_classes":["VectorStoreInfo"],"display_name":"VectorStoreInfo","documentation":""},"id":"VectorStoreInfo-Sxevb","value":null},"selected":false,"positionAbsolute":{"x":1196.8213224104938,"y":-1126.393770900602},"dragging":false},{"width":384,"height":366,"id":"OpenAIEmbeddings-NaFe9","type":"genericNode","position":{"x":320.8037105955719,"y":-541.6464393473227},"data":{"type":"OpenAIEmbeddings","node":{"template":{"allowed_special":{"required":false,"placeholder":"","show":true,"multiline":false,"value":[],"password":false,"name":"allowed_special","advanced":true,"dynamic":false,"info":"","type":"Literal'all'","list":true},"disallowed_special":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"all","password":false,"name":"disallowed_special","advanced":true,"dynamic":false,"info":"","type":"Literal'all'","list":true},"chunk_size":{"required":false,"placeholder":"","show":true,"multiline":false,"value":1000,"password":false,"name":"chunk_size","advanced":true,"dynamic":false,"info":"","type":"int","list":false},"client":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"client","advanced":true,"dynamic":false,"info":"","type":"Any","list":false},"deployment":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"text-embedding-ada-002","password":false,"name":"deployment","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"embedding_ctx_length":{"required":false,"placeholder":"","show":true,"multiline":false,"value":8191,"password":false,"name":"embedding_ctx_length","advanced":true,"dynamic":false,"info":"","type":"int","list":false},"headers":{"required":false,"placeholder":"","show":false,"multiline":true,"value":"{'Authorization':\n            'Bearer <token>'}","password":false,"name":"headers","advanced":true,"dynamic":false,"info":"","type":"Any","list":false},"max_retries":{"required":false,"placeholder":"","show":true,"multiline":false,"value":6,"password":false,"name":"max_retries","advanced":true,"dynamic":false,"info":"","type":"int","list":false},"model":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"text-embedding-ada-002","password":false,"name":"model","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"model_kwargs":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"model_kwargs","advanced":true,"dynamic":false,"info":"","type":"dict","list":false},"openai_api_base":{"required":false,"placeholder":"","show":true,"multiline":false,"password":true,"name":"openai_api_base","display_name":"OpenAI API Base","advanced":true,"dynamic":false,"info":"","type":"str","list":false,"value":""},"openai_api_key":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"","password":true,"name":"openai_api_key","display_name":"OpenAI API Key","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"openai_api_type":{"required":false,"placeholder":"","show":true,"multiline":false,"password":true,"name":"openai_api_type","display_name":"OpenAI API Type","advanced":true,"dynamic":false,"info":"","type":"str","list":false,"value":""},"openai_api_version":{"required":false,"placeholder":"","show":true,"multiline":false,"password":true,"name":"openai_api_version","display_name":"OpenAI API Version","advanced":true,"dynamic":false,"info":"","type":"str","list":false,"value":""},"openai_organization":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"openai_organization","display_name":"OpenAI Organization","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"openai_proxy":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"openai_proxy","display_name":"OpenAI Proxy","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"request_timeout":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"request_timeout","advanced":true,"dynamic":false,"info":"","type":"float","list":false},"show_progress_bar":{"required":false,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"show_progress_bar","advanced":true,"dynamic":false,"info":"","type":"bool","list":false},"skip_empty":{"required":false,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"skip_empty","advanced":true,"dynamic":false,"info":"","type":"bool","list":false},"tiktoken_model_name":{"required":false,"placeholder":"","show":true,"multiline":false,"password":true,"name":"tiktoken_model_name","advanced":false,"dynamic":false,"info":"","type":"str","list":false,"value":""},"_type":"OpenAIEmbeddings"},"description":"OpenAI embedding models.","base_classes":["OpenAIEmbeddings","Embeddings"],"display_name":"OpenAIEmbeddings","documentation":"https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/openai"},"id":"OpenAIEmbeddings-NaFe9","value":null},"selected":false,"positionAbsolute":{"x":320.8037105955719,"y":-541.6464393473227}},{"width":384,"height":537,"id":"Chroma-KTk0H","type":"genericNode","position":{"x":781.6596570821403,"y":-1096.3341720971546},"data":{"type":"Chroma","node":{"template":{"client":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"client","advanced":false,"dynamic":false,"info":"","type":"chromadb.Client","list":false},"client_settings":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"client_settings","advanced":false,"dynamic":false,"info":"","type":"chromadb.config.Setting","list":true},"documents":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"documents","display_name":"Documents","advanced":false,"dynamic":false,"info":"","type":"Document","list":true},"embedding":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"embedding","display_name":"Embedding","advanced":false,"dynamic":false,"info":"","type":"Embeddings","list":false},"chroma_server_cors_allow_origins":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"chroma_server_cors_allow_origins","display_name":"Chroma Server CORS Allow Origins","advanced":true,"dynamic":false,"info":"","type":"str","list":true},"chroma_server_grpc_port":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"chroma_server_grpc_port","display_name":"Chroma Server GRPC Port","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"chroma_server_host":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"chroma_server_host","display_name":"Chroma Server Host","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"chroma_server_http_port":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"chroma_server_http_port","display_name":"Chroma Server HTTP Port","advanced":true,"dynamic":false,"info":"","type":"str","list":false},"chroma_server_ssl_enabled":{"required":false,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"chroma_server_ssl_enabled","display_name":"Chroma Server SSL Enabled","advanced":true,"dynamic":false,"info":"","type":"bool","list":false},"collection_metadata":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"collection_metadata","advanced":false,"dynamic":false,"info":"","type":"dict","list":false},"collection_name":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"langflow","password":false,"name":"collection_name","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"ids":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"ids","advanced":false,"dynamic":false,"info":"","type":"str","list":true},"metadatas":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"metadatas","advanced":false,"dynamic":false,"info":"","type":"dict","list":true},"persist":{"required":false,"placeholder":"","show":true,"multiline":false,"value":false,"password":false,"name":"persist","display_name":"Persist","advanced":false,"dynamic":false,"info":"","type":"bool","list":false},"persist_directory":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"persist_directory","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"search_kwargs":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"{}","password":false,"name":"search_kwargs","advanced":true,"dynamic":false,"info":"","type":"NestedDict","list":false},"_type":"Chroma"},"description":"Create a Chroma vectorstore from a raw documents.","base_classes":["Chroma","VectorStore","BaseRetriever","VectorStoreRetriever"],"display_name":"Chroma","custom_fields":{},"output_types":[],"documentation":"https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/chroma"},"id":"Chroma-KTk0H","value":null},"selected":false,"positionAbsolute":{"x":781.6596570821403,"y":-1096.3341720971546}},{"width":384,"height":499,"id":"RecursiveCharacterTextSplitter-R5R9R","type":"genericNode","position":{"x":250.91992861065756,"y":-1150.9950743649817},"data":{"type":"RecursiveCharacterTextSplitter","node":{"template":{"code":{"dynamic":true,"required":true,"placeholder":"","show":false,"multiline":true,"value":"from typing import Optional\nfrom langflow import CustomComponent\nfrom langchain.schema import Document\nfrom langflow.utils.util import build_loader_repr_from_documents\n\n\nclass RecursiveCharacterTextSplitterComponent(CustomComponent):\n    display_name: str = \"Recursive Character Text Splitter\"\n    description: str = \"Split text into chunks of a specified length.\"\n    documentation: str = \"https://docs.langflow.org/components/text-splitters#recursivecharactertextsplitter\"\n\n    def build_config(self):\n        return {\n            \"documents\": {\n                \"display_name\": \"Documents\",\n                \"info\": \"The documents to split.\",\n            },\n            \"separators\": {\n                \"display_name\": \"Separators\",\n                \"info\": 'The characters to split on.\\nIf left empty defaults to [\"\\\\n\\\\n\", \"\\\\n\", \" \", \"\"].',\n                \"is_list\": True,\n            },\n            \"chunk_size\": {\n                \"display_name\": \"Chunk Size\",\n                \"info\": \"The maximum length of each chunk.\",\n                \"field_type\": \"int\",\n                \"value\": 1000,\n            },\n            \"chunk_overlap\": {\n                \"display_name\": \"Chunk Overlap\",\n                \"info\": \"The amount of overlap between chunks.\",\n                \"field_type\": \"int\",\n                \"value\": 200,\n            },\n            \"code\": {\"show\": False},\n        }\n\n    def build(\n        self,\n        documents: list[Document],\n        separators: Optional[list[str]] = None,\n        chunk_size: Optional[int] = 1000,\n        chunk_overlap: Optional[int] = 200,\n    ) -> list[Document]:\n        \"\"\"\n        Split text into chunks of a specified length.\n\n        Args:\n            separators (list[str]): The characters to split on.\n            chunk_size (int): The maximum length of each chunk.\n            chunk_overlap (int): The amount of overlap between chunks.\n            length_function (function): The function to use to calculate the length of the text.\n\n        Returns:\n            list[str]: The chunks of text.\n        \"\"\"\n        from langchain.text_splitter import RecursiveCharacterTextSplitter\n\n        if separators == \"\":\n            separators = None\n        elif separators:\n            # check if the separators list has escaped characters\n            # if there are escaped characters, unescape them\n            separators = [x.encode().decode(\"unicode-escape\") for x in separators]\n\n        # Make sure chunk_size and chunk_overlap are ints\n        if isinstance(chunk_size, str):\n            chunk_size = int(chunk_size)\n        if isinstance(chunk_overlap, str):\n            chunk_overlap = int(chunk_overlap)\n        splitter = RecursiveCharacterTextSplitter(\n            separators=separators,\n            chunk_size=chunk_size,\n            chunk_overlap=chunk_overlap,\n        )\n\n        docs = splitter.split_documents(documents)\n        self.repr_value = build_loader_repr_from_documents(docs)\n        return docs\n","password":false,"name":"code","advanced":false,"type":"code","list":false},"_type":"CustomComponent","chunk_overlap":{"required":false,"placeholder":"","show":true,"multiline":false,"value":200,"password":false,"name":"chunk_overlap","display_name":"Chunk Overlap","advanced":false,"dynamic":false,"info":"The amount of overlap between chunks.","type":"int","list":false},"chunk_size":{"required":false,"placeholder":"","show":true,"multiline":false,"value":1000,"password":false,"name":"chunk_size","display_name":"Chunk Size","advanced":false,"dynamic":false,"info":"The maximum length of each chunk.","type":"int","list":false},"documents":{"required":true,"placeholder":"","show":true,"multiline":false,"password":false,"name":"documents","display_name":"Documents","advanced":false,"dynamic":false,"info":"The documents to split.","type":"Document","list":true},"separators":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"separators","display_name":"Separators","advanced":false,"dynamic":false,"info":"The characters to split on.\nIf left empty defaults to [\"\\n\\n\", \"\\n\", \" \", \"\"].","type":"str","list":true,"value":"."}},"description":"Split text into chunks of a specified length.","base_classes":["Document"],"display_name":"Recursive Character Text Splitter","custom_fields":{},"output_types":["Document"],"documentation":"https://docs.langflow.org/components/text-splitters#recursivecharactertextsplitter"},"id":"RecursiveCharacterTextSplitter-R5R9R","value":null},"selected":false,"positionAbsolute":{"x":250.91992861065756,"y":-1150.9950743649817}},{"width":384,"height":627,"id":"ChatOpenAI-37IXU","type":"genericNode","position":{"x":1198.6499340125472,"y":-704.8915816630376},"data":{"type":"ChatOpenAI","node":{"template":{"callbacks":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"callbacks","advanced":false,"dynamic":false,"info":"","type":"langchain.callbacks.base.BaseCallbackHandler","list":true},"cache":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"cache","advanced":false,"dynamic":false,"info":"","type":"bool","list":false},"client":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"client","advanced":false,"dynamic":false,"info":"","type":"Any","list":false},"max_retries":{"required":false,"placeholder":"","show":false,"multiline":false,"value":6,"password":false,"name":"max_retries","advanced":false,"dynamic":false,"info":"","type":"int","list":false},"max_tokens":{"required":false,"placeholder":"","show":true,"multiline":false,"password":true,"name":"max_tokens","advanced":false,"dynamic":false,"info":"","type":"int","list":false,"value":""},"metadata":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"metadata","advanced":false,"dynamic":false,"info":"","type":"dict","list":false},"model_kwargs":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"model_kwargs","advanced":true,"dynamic":false,"info":"","type":"dict","list":false},"model_name":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"gpt-3.5-turbo-0613","password":false,"options":["gpt-3.5-turbo-0613","gpt-3.5-turbo","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4-0613","gpt-4-32k-0613","gpt-4","gpt-4-32k"],"name":"model_name","advanced":false,"dynamic":false,"info":"","type":"str","list":true},"n":{"required":false,"placeholder":"","show":false,"multiline":false,"value":1,"password":false,"name":"n","advanced":false,"dynamic":false,"info":"","type":"int","list":false},"openai_api_base":{"required":false,"placeholder":"","show":true,"multiline":false,"password":false,"name":"openai_api_base","display_name":"OpenAI API Base","advanced":false,"dynamic":false,"info":"\nThe base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\n\nYou can change this to use other APIs like JinaChat, LocalAI and Prem.\n","type":"str","list":false},"openai_api_key":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"","password":true,"name":"openai_api_key","display_name":"OpenAI API Key","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"openai_organization":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"openai_organization","display_name":"OpenAI Organization","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"openai_proxy":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"openai_proxy","display_name":"OpenAI Proxy","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"request_timeout":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"request_timeout","advanced":false,"dynamic":false,"info":"","type":"float","list":false},"streaming":{"required":false,"placeholder":"","show":false,"multiline":false,"value":false,"password":false,"name":"streaming","advanced":false,"dynamic":false,"info":"","type":"bool","list":false},"tags":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"tags","advanced":false,"dynamic":false,"info":"","type":"str","list":true},"temperature":{"required":false,"placeholder":"","show":true,"multiline":false,"value":"0.2","password":false,"name":"temperature","advanced":false,"dynamic":false,"info":"","type":"float","list":false},"tiktoken_model_name":{"required":false,"placeholder":"","show":false,"multiline":false,"password":false,"name":"tiktoken_model_name","advanced":false,"dynamic":false,"info":"","type":"str","list":false},"verbose":{"required":false,"placeholder":"","show":false,"multiline":false,"value":false,"password":false,"name":"verbose","advanced":false,"dynamic":false,"info":"","type":"bool","list":false},"_type":"ChatOpenAI"},"description":"`OpenAI` Chat large language models API.","base_classes":["BaseLanguageModel","BaseChatModel","ChatOpenAI","BaseLLM"],"display_name":"ChatOpenAI","custom_fields":{},"output_types":[],"documentation":"https://python.langchain.com/docs/modules/model_io/models/chat/integrations/openai"},"id":"ChatOpenAI-37IXU","value":null},"selected":false,"positionAbsolute":{"x":1198.6499340125472,"y":-704.8915816630376},"dragging":false},{"width":384,"height":366,"id":"CSVLoader-qZVdz","type":"genericNode","position":{"x":-362.21202136855834,"y":-1302.5794135797648},"data":{"type":"CSVLoader","node":{"template":{"file_path":{"required":true,"placeholder":"","show":true,"multiline":false,"value":"documentation_langflow.csv","suffixes":[".csv"],"password":false,"name":"file_path","advanced":false,"dynamic":false,"info":"","type":"file","list":false,"fileTypes":["csv"],"file_path":"C:\\Users\\xande\\AppData\\Local\\langflow\\langflow\\Cache\\78b28e87-c30b-469d-b945-54a7995f3f1f\\22827d8bbec4ab9e8adf36ffeeea40482bec755e3613f21ee7256aeb160c950e.csv"},"metadata":{"required":false,"placeholder":"","show":true,"multiline":false,"value":[{"":""}],"password":false,"name":"metadata","display_name":"Metadata","advanced":false,"dynamic":false,"info":"","type":"dict","list":false},"_type":"CSVLoader"},"description":"Load a `CSV` file into a list of Documents.","base_classes":["Document"],"display_name":"CSVLoader","custom_fields":{},"output_types":["Document"],"documentation":"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/csv","beta":false,"error":null},"id":"CSVLoader-qZVdz"},"selected":false,"positionAbsolute":{"x":-362.21202136855834,"y":-1302.5794135797648},"dragging":false}],"edges":[{"source":"VectorStoreInfo-Sxevb","target":"VectorStoreAgent-y0gVB","sourceHandle":"VectorStoreInfo|VectorStoreInfo-Sxevb|VectorStoreInfo","targetHandle":"VectorStoreInfo|vectorstoreinfo|VectorStoreAgent-y0gVB","id":"reactflow__edge-VectorStoreInfo-SxevbVectorStoreInfo|VectorStoreInfo-Sxevb|VectorStoreInfo-VectorStoreAgent-y0gVBVectorStoreInfo|vectorstoreinfo|VectorStoreAgent-y0gVB","style":{"stroke":"#555"},"className":"","animated":false,"selected":false},{"source":"Chroma-KTk0H","target":"VectorStoreInfo-Sxevb","sourceHandle":"Chroma|Chroma-KTk0H|Chroma|VectorStore|BaseRetriever|VectorStoreRetriever","targetHandle":"VectorStore|vectorstore|VectorStoreInfo-Sxevb","id":"reactflow__edge-Chroma-KTk0HChroma|Chroma-KTk0H|VectorStore|Chroma|BaseRetriever|VectorStoreRetriever-VectorStoreInfo-SxevbVectorStore|vectorstore|VectorStoreInfo-Sxevb","style":{"stroke":"#555"},"className":"","animated":false,"selected":false},{"source":"RecursiveCharacterTextSplitter-R5R9R","target":"Chroma-KTk0H","sourceHandle":"RecursiveCharacterTextSplitter|RecursiveCharacterTextSplitter-R5R9R|Document","targetHandle":"Document|documents|Chroma-KTk0H","id":"reactflow__edge-RecursiveCharacterTextSplitter-R5R9RRecursiveCharacterTextSplitter|RecursiveCharacterTextSplitter-R5R9R|Document-Chroma-KTk0HDocument|documents|Chroma-KTk0H","style":{"stroke":"#555"},"className":"","animated":false,"selected":false},{"source":"ChatOpenAI-37IXU","target":"VectorStoreAgent-y0gVB","sourceHandle":"ChatOpenAI|ChatOpenAI-37IXU|BaseLanguageModel|BaseChatModel|ChatOpenAI|BaseLLM","targetHandle":"BaseLanguageModel|llm|VectorStoreAgent-y0gVB","id":"reactflow__edge-ChatOpenAI-37IXUChatOpenAI|ChatOpenAI-37IXU|BaseLanguageModel|ChatOpenAI|BaseChatModel|BaseLLM-VectorStoreAgent-y0gVBBaseLanguageModel|llm|VectorStoreAgent-y0gVB","style":{"stroke":"#555"},"className":"","animated":false,"selected":false},{"source":"OpenAIEmbeddings-NaFe9","target":"Chroma-KTk0H","sourceHandle":"OpenAIEmbeddings|OpenAIEmbeddings-NaFe9|OpenAIEmbeddings|Embeddings","targetHandle":"Embeddings|embedding|Chroma-KTk0H","id":"reactflow__edge-OpenAIEmbeddings-NaFe9OpenAIEmbeddings|OpenAIEmbeddings-NaFe9|Embeddings|OpenAIEmbeddings-Chroma-KTk0HEmbeddings|embedding|Chroma-KTk0H","style":{"stroke":"#555"},"className":"","animated":false,"selected":false},{"source":"CSVLoader-qZVdz","sourceHandle":"CSVLoader|CSVLoader-qZVdz|Document","target":"RecursiveCharacterTextSplitter-R5R9R","targetHandle":"Document|documents|RecursiveCharacterTextSplitter-R5R9R","style":{"stroke":"#555"},"className":"","animated":false,"id":"reactflow__edge-CSVLoader-qZVdzCSVLoader|CSVLoader-qZVdz|Document-RecursiveCharacterTextSplitter-R5R9RDocument|documents|RecursiveCharacterTextSplitter-R5R9R"}],"viewport":{"x":347.84608864555173,"y":799.2054467313637,"zoom":0.5268905430705235}},"id":"78b28e87-c30b-469d-b945-54a7995f3f1f","user_id":"482d9265-fb56-4919-bffa-92cde4d8a6ca"}

RAG retrieving information from csv file

The flow in Langflow to retrieve information from a csv file using RAG can be found in the Community Examples under the name CSV Loader. The json file containing the flow is found above.


This post has demonstrated how to construct a system (flow) to retrieve information from a csv file and generate the answer using RAG. Langflow allows you to load almost any type of document to retrieve information from it and to generate the LLM answer. Feel free to use the platform to adapt the flow for your specific needs.