Building a RAG Pattern chat bot with Azure OpenAI and LangChain.js | Azure Developers JavaScript Day

Building a RAG Pattern chat bot with Azure OpenAI and LangChain.js | Azure Developers JavaScript Day



In this second article on this year's Microsoft event aimed at JavaScript developers: Azure Developers JavaScript Day 2024, we're going to talk about creating a chatbot using the RAG (Retrieval Augmentation Generation) architecture with Azure OpenAI and LangChain.js! And this time we have the special participation of Lars Gyrup, a Microsoft MVP from Denmark, GitHub star, NX Champion, Angular hero of education and a fervent community organizer. And, also with Wassim Chegham, a Senior Developer Advocate Engineer at Microsoft with a long history in JavaScript development, and Natalia Venditto, a Principal Product Manager at Microsoft focused on the Developer Experience in Azure.


Let's get to the content!


What was covered during the session?


If you wish, watch the video below and find out what happened during the talk!


The Confluence of Expertise


Lars introduced his extensive background, highlighting his contributions to Developer Technologies, Open-Source projects, and educational initiatives. His foundational work with the This is Learning community, which evolved from an Angular-centric hub to a broader tech community, showcases his commitment to fostering growth and knowledge sharing among tech enthusiasts of all skill levels.


Wassim and Natalia, complemented the discussion with their vast experiences. Their collaboration has led to the development of samples that guide the community on best practices for application implementation using Azure services and Developer Tools.


You can check out Wassim's profile on GitHub and Natalia's on GitHub. All the code and projects they develop are available there!


Unraveling the RAG Pattern


The core of the session was the deep dive into the RAG pattern, a sophisticated architecture designed to enhance AI-driven applications by leveraging large language models for predictive content generation. This pattern, integral to generative AI technologies like GitHub Copilot, empowers applications to construct responses to user queries with unprecedented accuracy and relevance.


Architectural Overview and Implementation


Wassim and Natalia walked through the architecture of the sample RAG chatbot application, detailing the utilization of various Azure services, including:


  • Azure Static Web Apps for the UI deployment
  • Azure Container Apps for the backend logic
  • Azure AI Search for data indexing and retrieval


The integration with OpenAI’s APIs plays a pivotal role in fetching predictive models and responses.


The session also shed light on the application's backend components: the indexer and the search API, highlighting the use of Fastify for API exposure and the strategic implementation of the sliding window algorithm for efficient text chunking and indexing.


Below you can see a diagram of the project's architecture:



Engaging with the Code


The practical segment involved a detailed code walkthrough, emphasizing npm workspaces, monorepo organization, and the use of libraries like LangChain.js for seamless interaction with Azure OpenAI. The discussion also touched on the importance of semantic search and vector embeddings in improving the chatbot's response quality.




You can get an overview of the project's code at GitHub. Help us improve the project with your contributions and feedback! The project is completely open-source and available to the community. And give stars to the repository if you like it! ;)




Frontend Realizations and Angular Insights


Lars provided a comprehensive overview of the latest features and improvements in Angular, including:


  • Signals for managing state changes.
  • Standalone components for modular development.
  • And the evolution of template syntax for more intuitive code structuring.


The session illustrated how these Angular advancements could be leveraged in the context of the RAG chatbot application, enhancing its functionality and user interaction.


You can see in the image below an example of how the chatbot has been implemented in the user interface, making use of Angular's new features:




Deployment and Contributions to the Project


The deployment process to Azure was demystified, showcasing the use of:


  • Azure Developer CLI: which is a command line tool that allows you to create, manage and deploy Azure resources directly from the terminal.

  • Bicep: which is an Infrastructure as Code (IaC) language that allows Azure resources to be defined declaratively.

The open invitation for community contributions to the project underscores the collaborative spirit of the initiative.


Conclusion for the Session


This enriching session at the JavaScript Developer Days 2024 not only offered a comprehensive guide to developing a RAG pattern chatbot but also illuminated the potential of combining Angular’s new features with Azure's robust cloud services. The contributions of Lars, Wassim, and Natalia provided attendees with valuable insights into leveraging modern web development practices and AI technologies to create dynamic, responsive applications.


The collaborative effort to build and refine this project invites developers from across the spectrum to contribute, learn, and grow within this innovative domain, further bridging the gap between AI advancements and practical web development applications.


Azure Developers JavaScript Day Cloud Skills Challenge




As mentioned in previous article, the event also featured a cloud skills challenge focused on JavaScript Developers, where participants could test their knowledge and skills in Azure. Although the challenge is over, you can continue your studies!


Link to the challenge: JavaScript and Azure Cloud Skills Challenge


Additional Resources



Stay Tuned!


If you wish, you can follow what happened during the two days of the event via the playlist on YouTube. The event was full of interesting content and insights for JavaScript developers!


Stay tuned for more articles about this event and keep learning with us!


Published on:

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

Azure Developer Community Blog articles

Share post:

Related posts

Announcing Azure Monitoring Agent support in Azure Landing Zones

Introduction   Hello and welcome to another blog post about Azure Landing Zones, the best practice framework for accelerating your cloud...

2 days ago

Out-of-band updates to address Azure Synapse SQL issue caused by Windows updates

Microsoft has issued an out-of-band update to resolve an issue with Azure Synapse SQL Serverless Pool databases entering a "Recovery pending" ...

2 days ago

[Mitigated] Azure Lab Services - Lab Plan Outage

Azure Lab Service is experiencing an outage that is affecting Lab Plans, but not Lab Accounts. This outage intermittently impacts all operatio...

2 days ago

Azure Lab Services Tutorial Video

This is a complete tutorial about Azure Lab Services' features. It walks through the steps of setting up a Lab Account, creating a Lab, and ac...

2 days ago

What's new in the Azure Lab Services

This is a presentation highlighting the new features introduced in the latest preview for Azure Lab Services.

2 days ago

Update to Azure Lab Services

The product team has been busy working on fundamental improvements for the service to boost performance, reliability, and scalability. It has ...

2 days ago

Build scalable cross-subscription applications with Azure Load Balancer

We are thrilled to announce that Azure cross-subscription Load Balancer is now available for public preview in all Azure public and national c...

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