Loading...

Azure Static Web Apps Community Standup: Create a RAG App with App Spaces

Azure Static Web Apps Community Standup: Create a RAG App with App Spaces

thumb.jpg

 

 

At the last Azure Static Web Apps Community Standup through the Youtube - Microsoft Azure Developers channel, it was demonstrated how to create a Retrieval-Augmented Generation (RAG) application using Azure Static Web Apps and App Spaces.

 

The event was led by Dheeraj Bandaru, who is Product Manager of Azure Static Web Apps at Microsoft. Dheeraj was joined by Skyler Hardle, who is Senior Manager of Apps Spaces at Microsoft.

 

Skyler presented a practical guide on the integration between these services and the implementation of a RAG (Retrieval Augmented Generation) application. Next, I will share with you what was covered during the event, detailing the application architecture and the development steps.

 

But first, we need to understand this new service and how it can be useful for creating modern applications.

 

In addition, if you want to watch the event in full, you can access the link below:

 

 

What are App Spaces?

 

 

App Spaces is an intelligent service for developers that reduces the complexity of creating and managing web applications. It helps identify the correct services for your applications on Azure and provides a simplified management experience for the development process.

 

App Spaces also offers the benefits of deploying an application through existing Azure services, such as Azure Container Apps and Azure Static Web Apps, with an experience focused on development and deployment in a simplified and fast way.

 

In short....

 

app-spaces-definition.png

 

 

What is RAG?

 

Retrieval-Augmented Generation (RAG) is a technique that combines external information retrieval with the generation of responses by language models (LLMs).

 

This approach makes it possible to enrich the context of AI models, providing more accurate and relevant responses. In the case of our application, we use vector databases to store documents and embeddings, allowing efficient and contextualized information retrieval.

 

 

First, let's understand some basic concepts about RAG

 

Large Language Models (LLMs) like ChatGPT are trained with public data available on the internet at the time of training. They can answer questions related to the data they were trained on. However, this public data may not be sufficient to meet all your needs.

 

You may want answers based on your private data or the public data may simply be outdated. The solution to this problem is Retrieval-Augmented Generation (RAG), a pattern used in AI that uses an LLM to generate answers based on your own data.

 

How does RAG work?

 

RAG is a standard pattern that uses your data with an LLM to generate specific answers to your data. When a user asks a question, the data storage is searched based on the user input. The user's question is then combined with the corresponding results and sent to the LLM using a prompt (explicit instructions for an AI or machine learning model) to generate the desired answer. This can be illustrated as follows.

 

The image below represents the RAG workflow:

 

rag-workflow.png

 

If you want to know more about RAG, I recommend reading the article Retrieval-Augmented Generation (RAG).

 

 

RAG Application Architecture with App Spaces

 

At the event, Skyler presented the architecture of the RAG application that would be developed during the presentation. a frontend in React, a backend in FastAPI, and a vector database. These components work together to provide a complete and integrated solution. Below, I detail the operation of each of these components.

 

Below, I detail how each of these components works.

 

Frontend with React

 

The application's frontend is developed in React and makes calls to a FastAPI backend to retrieve and store embeddings in a vector database (Quadrant). The user interface allows you to enter questions and view the answers generated by the system.

 

Backend with FastAPI

 

The backend is responsible for two main functionalities:

 

  1. Generate and store embeddings: Uses the OpenAI embeddings API to generate vectors from the provided text and store them in the vector database.

  2. Retrieve and generate answers: Searches for relevant embeddings in the vector database and uses OpenAI GPT-4 to generate answers based on these embeddings.

app-running.png

 

The application used Quadrant, a vector database that allows you to store and retrieve embeddings efficiently. Quadrant is a scalable and high-performance solution for applications that require the retrieval of relevant information based on user queries.

 

Implementing the RAG Application

 

Initial Configuration

 

To get started, go to App Spaces on the Azure portal and select the option to create a new application 'space'. You can choose a GitHub repository or use one of the provided templates, such as the RAG App. Configure the necessary environment variables, including the OpenAI API keys.

 

rag-app-spaces.png

 

 

 

Frontend implementation

 

The application's frontend is a React application that can be deployed on Azure Static Web Apps. To do this, simply configure the GitHub repository and set the application's output directory. Azure Static Web Apps will automatically create a CI/CD pipeline to deploy the application.

 

Configuration and Deployment of the Backend

 

The FastAPI backend is deployed using Azure Container Apps in Azure. It handles requests for generating and storing embeddings, as well as retrieving and generating answers.

 

backend-app.png

 

Demonstration of RAG Application

 

  • Indexing and Storing Text: The user enters text in the frontend, which is sent to the backend to generate and store embeddings in the vector database.

  • Asking Questions and Receiving Answers: The user asks questions through the frontend, which are processed by the backend to search for relevant embeddings and generate answers using OpenAI's GPT-4.

 

app-demo.png

 

If you would like to learn more about the application developed at the event, you can access the GitHub repository app-spaces-rag-app

 

In fact, Julia Muiruri, who is a Developer Advocate at Microsoft, recorded a video about the application developed at the event. You can watch the video below:

 

 

Management and Extensibility

 

App Spaces makes it easy to add new components to your application, such as new frontends or integrations with other services. The management interface allows you to view logs, metrics, and configure environment variables intuitively.

 

The most interesting thing about all this is that regardless of the programming language on the backend, you can use App Spaces to manage and deploy your application. Whether you are a Python, .NET, Node.js, Java, Go developer, etc., App Spaces is an excellent option for managing your applications.

 

If you would like to see other examples of applications in different programming languages, you can access the GitHub repository app-spaces-samples.

 

repo-spaces-repo.png

 

And I recommend you to start testing App Spaces now! You can start testing for free. Access now: HERE or by clicking on the image below:

 

try-it-now.png

 

Conclusion

 

At the Azure Static Web Apps community meeting, we learned how to create a Retrieval-Augmented Generation (RAG) application using Azure Static Web Apps and App Spaces. We explored the application architecture, configured the necessary components, and implemented a practical solution that enriches the context of AI models, providing more accurate and relevant answers.

 

Remember that you can review the event in full by accessing the link below:

 

 

Microsoft Reactor YouTube Channel

 

Did you know that we have one of the largest communities with diverse topics on technology, the cloud and software development? Then you need to get to know Microsoft Reactor.

 

 

It also has numerous online, face-to-face events, workshops, meetups, and much more. Access the link to the official Microsoft Reactor page and subscribe to the channel to stay on top of everything that happens in the community.

 

reactor-page.png

 

Additional Resources

 

Did you like App Spaces? Do you want to know more about the service and how it can help simplify the development of web applications? Or better still, do you want to learn how to create an application with App Spaces through a practical tutorial?

 

I hope you enjoyed the article and that it was useful to you. If you have any questions or suggestions, don't hesitate to leave a comment below.

 

See you next time! :cool:

Published on:

Learn more
Azure Developer Community Blog articles
Azure Developer Community Blog articles

Azure Developer Community Blog articles

Share post:

Related posts

Azure Database for PostgreSQL Flexible Server - Elastic Clusters, faster disks, and AI updates

Increase scalability, optimize performance, and integrate advanced AI features with Azure Database for PostgreSQL Flexible Server. Scale up wi...

5 days ago

Introducing the new Linux-based Azure Cosmos DB Emulator (Preview)

We are excited to announce the preview release of the new Linux-based Azure Cosmos DB Emulator! This latest version is built to provide faster...

7 days ago

Azure Cosmos DB Shines at Microsoft Ignite 2024!

Microsoft Ignite 2024 took over the Windy City this week, bringing with it new technological innovation and exciting product announcements apl...

7 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy