Skip to main content

Langflow in OpenRAG

OpenRAG leverages Langflow's Agent component to power the OpenRAG OpenSearch Agent flow.

Flows in Langflow are functional representations of application workflows, with multiple component nodes connected as single steps in a workflow.

In the OpenRAG OpenSearch Agent flow, components like the Langflow Agent component and OpenSearch component are connected to intelligently chat with your knowledge by embedding your query, comparing it the vector database embeddings, and generating a response with the LLM.

OpenRAG Open Search Agent Flow

The Agent component shines here in its ability to make decisions on not only what query should be sent, but when a query is necessary to solve the problem at hand.

How do agents work?

Agents extend Large Language Models (LLMs) by integrating tools, which are functions that provide additional context and enable autonomous task execution. These integrations make agents more specialized and powerful than standalone LLMs.

Whereas an LLM might generate acceptable, inert responses to general queries and tasks, an agent can leverage the integrated context and tools to provide more relevant responses and even take action. For example, you might create an agent that can access your company's documentation, repositories, and other resources to help your team with tasks that require knowledge of your specific products, customers, and code.

Agents use LLMs as a reasoning engine to process input, determine which actions to take to address the query, and then generate a response. The response could be a typical text-based LLM response, or it could involve an action, like editing a file, running a script, or calling an external API.

In an agentic context, tools are functions that the agent can run to perform tasks or access external resources. A function is wrapped as a Tool object with a common interface that the agent understands. Agents become aware of tools through tool registration, which is when 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 so that it can decide whether the tool is appropriate for a given request.

Use the OpenRAG OpenSearch Agent flow

If you've chatted with your knowledge in OpenRAG, you've already experienced the OpenRAG OpenSearch Agent chat flow. To switch OpenRAG over to the Langflow visual editor and view the OpenRAG OpenSearch Agentflow, click Settings, and then click Edit in Langflow. This flow contains eight components connected together to chat with your data:

  • The Agent component orchestrates the entire flow by deciding when to search the knowledge base, how to formulate search queries, and how to combine retrieved information with the user's question to generate a comprehensive response. The Agent behaves according to the prompt in the Agent Instructions field.
  • The Chat Input component is connected to the Agent component's Input port. This allows to flow to be triggered by an incoming prompt from a user or application.
  • The OpenSearch component is connected to the Agent component's Tools port. The agent might not use this database for every request; the agent only uses this connection if it decides the knowledge can help respond to the prompt.
  • The Language Model component is connected to the Agent component's Language Model port. The agent uses the connected LLM to reason through the request sent through Chat Input.
  • The Embedding Model component is connected to the OpenSearch component's Embedding port. This component converts text queries into vector representations that are compared with document embeddings stored in OpenSearch for semantic similarity matching. This gives your Agent's queries context.
  • The Text Input component is populated with the global variable OPENRAG-QUERY-FILTER. This filter is the Knowledge filter, and filters which knowledge sources to search through.
  • The Agent component's Output port is connected to the Chat Output component, which returns the final response to the user or application.
  • An MCP Tools component is connected to the Agent's Tools port. This component calls the OpenSearch URL Ingestion flow, which Langflow uses as an MCP server to fetch content from URLs and store in OpenSearch.

All flows included with OpenRAG are designed to be modular, performant, and provider-agnostic. To modify a flow, click Settings, and click Edit in Langflow. OpenRAG's visual editor is based on the Langflow visual editor, so you can edit your flows to match your specific use case.

For an example of changing out the agent's language model in OpenRAG, see the Quickstart.

To restore the flow to its initial state, in OpenRAG, click Settings, and then click Restore Flow. OpenRAG warns you that this discards all custom settings. Click Restore to restore the flow.

Additional Langflow functionality

Langflow includes features beyond Agents to help you integrate OpenRAG into your application, and all Langflow features are included in OpenRAG.

  • Langflow can serve your flows as an MCP server, or consume other MCP servers as an MCP client. Get started with the MCP tutorial.

  • If you don't see the component you need, extend Langflow's functionality by creating custom Python components.

  • Langflow offers component bundles to integrate with many popular vector stores, AI/ML providers, and search APIs.