DEV Community

Cover image for Using Datastax Langflow and AstraDB to Create a Multi-Agent Research Assistant with Safety Check - Part 1: Safety and Search
Alan Knox
Alan Knox

Posted on • Edited on

Using Datastax Langflow and AstraDB to Create a Multi-Agent Research Assistant with Safety Check - Part 1: Safety and Search

This is the first part of a multipart post about creating a multi-agent research assistant using Datastax AstraDB and Langflow.

The goal of this post is to explain how multiple Langflow flows can be integrated to create a multi-agent application. For this project, the application will assist a researcher in finding websites about a particular topic in 3 steps:

  1. Examine the user's request to determine whether or not it is a safe request.
  2. Find web pages that correspond to the user's request.
  3. Summarize the contents of each web page.

Part 1: Safety and Search

For any AI project, observability and safety are ultimate concerns. When I design an AI project, I begin and end with observability and safety. It's important to know what's happening throughout the application, and to ensure that the application is returning safe outputs to the user.

For the "Safety Check", I created a simple flow using Langflow:

Image description

This flow accepts the user's input and provides a system prompt to the model which then provides the output.

The important part of this flow is the system prompt. I begin with a simple system prompt to test the flow:

Simple SafetyCheck System Prompt
Image description

Simple SafetyCheck System Prompt Results
Image description

Next, I optimized the system prompt to include additional unsafe parameters as well as to block against prompt injection:

Optimized SafetyCheck System Prompt
Image description

Optimized SafetyCheck System Prompt Results
Image description

Web Search

For the second section of Part 1, I create an agent that can search the web based on the user's input. It's important that the agent only returns a list of URL's, so once again prompt engineering is necessary.

Also, in order to demonstrate the flexibility of Langflow, I use OpenAPI models for this agent.

Here is the final agentic flow:

Image description

I begin with a simple prompt until I get the results that I want:

Web search agent simple prompt
Image description

Web search agent results with simple prompt
Image description

Next, I optimized the prompt. The optimized prompt was more concise and added an example. The results were also good.

Web search agent optimized prompt
Image description

Web search agent optimized prompt results
Image description

At this point, I have a flow that checks my user's input for safety. I also have an agent that returns a list of websites. The next step for the multi-agent research assistant will be to search each website and summarize the contents. That will be Part 2.

Top comments (0)