Connecting the Streamlit Frontend to DeepResearcher

Introduction: Bringing DeepResearcher to Life with Streamlit

Welcome back! So far, you have learned how to use Streamlit to build interactive web pages and how to prepare your DeepResearcher backend for integration. In this lesson, you will connect these two parts, making it possible for users to interact with DeepResearcher through a simple web interface.

By the end of this lesson, you will know how to:

  • Import your DeepResearcher logic into a Streamlit app,
  • Build a user interface for research input,
  • Run the research process from the frontend,
  • Display the results directly in the app.

This is a key step in turning your research tool into something anyone can use, even if they do not know how to run Python scripts.

Quick Recap: Preparing DeepResearcher for Integration

Before we dive in, let’s quickly remind ourselves of what we did in the last lesson. You adapted the DeepResearcher backend so it could be used as a function. This means you can now call it from other Python code, such as a Streamlit app, by passing in parameters and getting back results.

For example, your DeepResearcher module now has a function like this:

from deepresearcher.main import research_main

# Example usage:
result = research_main("Impact of AI in healthcare", iteration_limit=3)
print(result)

This is important because it allows us to connect the backend logic to any frontend, including Streamlit.

Importing DeepResearcher into Streamlit

Let’s start by importing the DeepResearcher function into your Streamlit app. This is just like importing any other Python function.

import streamlit as st
from deepresearcher.main import research_main
  • import streamlit as st brings in the Streamlit library, which you use to build the web interface.
  • from deepresearcher.main import research_main imports the main function from your DeepResearcher backend.

This step is necessary so that your Streamlit app can use the research logic you have already built.

Building the User Interface for Research (Quick Reminder)

You’ve already built the basic user interface in previous lessons, including:

  • A text input for the research topic,
  • A slider to control the number of research iterations,
  • A button to start the research.

Here’s a quick reminder of what those components look like in Streamlit:

user_query = st.text_input("Enter your research topic:", placeholder="e.g. Impact of AI in healthcare")
max_iterations = st.slider("Max research iterations", 1, 10, 3)

With these UI elements in place, you’re ready to connect them to your DeepResearcher backend.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal