Create a Retrieval-Augmented Generation (RAG) app instantly with React, FastAPI, and Qdrant
Published Jun 12 2024 12:37 PM 3,115 Views
Microsoft

Deploying web applications in the cloud can often be a complex task, involving multiple steps and intricate configurations. App Spaces aims to streamline this process, offering a straightforward approach to hosting web applications. This blog post will guide you through deploying a "Sample Space," specifically the Retrieval-Augmented Generation (RAG) sample space, to demonstrate how easily you can set up and manage a RAG type application using App Spaces.

 

What is App Spaces?

App Spaces is a versatile service within Microsoft Azure designed to simplify the deployment and management of web applications. It provides several deployment options:

  • GitHub Repository: Directly deploy your code from a GitHub repository.
  • Starter App Templates: Use pre-configured templates for popular frameworks like React, Vue, Express, Django, Flask, and FastAPI.
  • Sample Spaces: Deploy fully provisioned, ready-to-use applications with a single click.

For this tutorial, we will focus on deploying the Retrieval-Augmented Generation (RAG) App sample space, which integrates a React frontend, a FastAPI backend, and a Qdrant vector database.

 

Step 1: Getting Started with App Spaces

To begin, navigate to the App Spaces dashboard (click here to try now) in your Azure portal. Here, you can initiate the process of creating a new app space.

 

Screenshot 2024-06-12 at 12.01.58 PM.png

From the dashboard, you have several deployment options. Select the Retrieval-Augmented Generation (RAG) App sample space from the available sample spaces.

 

Step 2: Automatic Provisioning of Resources

Upon selecting the RAG sample space, App Spaces will automatically provision the necessary resources, including a React frontend, a FastAPI backend, and a Qdrant vector database.

 

Screenshot 2024-06-12 at 12.06.51 PM.png

 

Step 3: Configuring Your App

Next, you need to configure your app by linking it to your GitHub account and specifying repository details. Here’s how to do it:

  1. Connect Your GitHub Account: Link your GitHub account with App Spaces to allow access to your repositories. If not already linked, you’ll be prompted to log in and authorize access.

  2. Select Your Organization: Choose the GitHub organization under which the new repository will be created. This ensures the project is stored in the correct organizational context.

  3. Name Your Repository: Provide a descriptive name for your new repository where App Spaces will push the initial sample app code.

  4. Specify the Branch: Default to the main branch unless you prefer to use a different branch.

  5. Configure App Details: Enter details such as the app space name, subscription, and region. This configuration helps Azure set up the necessary infrastructure.

 

Screenshot 2024-06-12 at 12.02.17 PM.png

 

After completing these steps, App Spaces will create the GitHub repository, push the initial code, and set up a CI/CD pipeline for automatic deployments.

 

Step 4: Managing and Verifying Your Deployment

Once your app is deployed, managing and verifying its deployment is straightforward. App Spaces provides a comprehensive management interface to monitor and control various aspects of your application.

 

Deployment Verification

The deployment status for each component (frontend, backend, database) can be monitored from the App Spaces dashboard. Each deployment entry provides details about the status and timestamps of deployment events.

 

Screenshot 2024-06-12 at 12.28.26 PM.png

 

Viewing Logs

Accessing logs is crucial for debugging and ensuring your application runs smoothly. The logs section provides both system-level and application-level logs.

 

Screenshot 2024-06-12 at 12.13.11 PM.png

 

Monitoring Metrics

The metrics section provides insights into your application's performance, including CPU usage, memory usage, and request counts. This data helps you understand the load on your application and optimize performance.

Screenshot 2024-06-12 at 12.13.19 PM.png

Step 5: Using the Sample App

 

Screenshot 2024-06-12 at 12.07.57 PM.png

 

With the app successfully deployed, you can now interact with it through the provided URL. The RAG sample app offers a user-friendly interface to perform the following actions:

 

  1. Enter Your OpenAI API Key: Input your OpenAI API key to enable querying the OpenAI API. This step is crucial for the app to function correctly as it relies on the OpenAI API for generating embeddings and enhancing search results.

  2. Ask a Question: Submit a query, and the app will use OpenAI’s embeddings to search the vector database for relevant information. This feature is particularly useful for retrieving detailed and contextually relevant information from a large dataset.

  3. Store New Text: Add new data to the vector database for future queries. This feature is great for continuously building and enriching your knowledge base.

Follow the instructions below to get started trying out the sample app:

 

  1. Configuration:

    • Open the app in your browser.
    • In the Configuration section, enter your OpenAI API key. This key is necessary for the app to interact with the OpenAI API.
     
  2. Storing New Text:

    • In the Store new text section, enter a piece of text you want to add to the database. For example, you might enter, "Azure App Spaces simplifies cloud hosting for web applications."
    • Click the Store Text button. This action sends the text to the OpenAI API to generate embeddings, which are then stored in the Qdrant vector database.
     
  3. Asking a Question:

    • In the Ask a question section, type a query related to the stored text. For instance, you could ask, "What service can simplify cloud hosting for web apps?"
    • Click the Search button. The app will use the stored embeddings to find the most relevant information in the database and display the results.
     

This simple interaction demonstrates how the RAG app can be used to build a robust, searchable knowledge base using state-of-the-art retrieval-augmented generation techniques.

 

App Spaces significantly simplifies the process of deploying and managing web applications in the cloud. The Retrieval-Augmented Generation sample space illustrates how you can integrate a powerful backend with a dynamic frontend and a robust vector database. By following these steps, you can quickly set up and manage a sophisticated cloud-based application. Give App Spaces a try and streamline your development workflow.

Co-Authors
Version history
Last update:
‎Jun 12 2024 12:39 PM
Updated by: