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:

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 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:

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

Connecting User Actions to DeepResearcher

Now, let’s connect the user’s actions to the backend. When the button is clicked, you want to call research_main with the user’s input and show the result.

Here’s how you can do it step by step:

Researching when the Button is clicked

To trigger the research process only when the user clicks the button and has entered a valid topic, use an if statement that checks both conditions. This ensures that the research only runs when appropriate:

  • st.button("Run Research") returns True only when the button is clicked.
  • user_query.strip() checks that the input is not empty or just spaces.
  • Place your research logic inside this block to ensure it only runs when both conditions are met.
Showing a Loading Spinner

Research can take some time, so it’s good to show a spinner while the app is working:

  • st.spinner displays a message while the code inside runs.
  • research_main(user_query, iteration_limit=max_iterations) calls your backend function with the user’s topic and chosen number of iterations.
  • The result is stored in report.
Displaying the Result

Once the research is done, you want to show the user a success message and the final report:

  • st.success shows a green success message.
  • st.markdown displays the report using Markdown formatting, which makes it look nice in the app.
Full Example: The Complete Connected App

Let’s put all the pieces together. Here is the complete code for your Streamlit app that connects to DeepResearcher:

What happens when you run this app?

  • The user sees a title, a description, a text box, a slider, and a button.
  • When the user enters a topic and clicks the button, the app runs the research and shows a loading spinner.
  • When the research is done, the app displays the final report.
Summary and Practice Preview

In this lesson, you learned how to connect your Streamlit frontend to the DeepResearcher backend. You:

  • Imported your research function into the app,
  • Built a user interface for input and controls,
  • Connected user actions to the backend,
  • Displayed the research results in the app.

You now have a working web app that lets anyone use DeepResearcher with just a browser. In the next practice exercises, you will get hands-on experience building and customizing this connection yourself. Great job getting this far—let’s keep going!

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