Skip to content

Commit 0af3f35

Browse files
glaucia86sinedied
andauthored
docs: add tutorials: 02-setting-up-azure-functions.md, 03-understanding-rag.md and 04-understanding-preparing-language-models.md (#45)
* feat: create tutorial for: 02 - Setting Up the Serverless Environment using Azure Functions * docs: update link to next step in introduction tutorial * fix: typos and let more accurate the tutorial * docs: add new tutorial for understanding the RAG architecture * docs: add `03-understanding-rag.md` tutorial * docs: update `03-understanding-rag.md` tutorial and `chat` API * docs: update link to next step in introduction tutorial * docs: add tutorial `04-preparing-understanding-language-models.md` * docs: add tutorial for developing the `chat` API * Update 04-preparing-understanding-language-models.md fix: typo * docs: add note about alternative CLI options for running Azure Developer commands * docs: some important changes in the tutorial files * fix: according to Dina's feedback * docs: change from ChatGPT word to Chat Application * fix: typos and more clarity * fix: typos for clarity * feat: Update tutorial files and fix typos for clarity * fix: Update tutorial files and fix typos for clarity * Update docs/tutorial/02-setting-up-azure-functions.md Co-authored-by: Yohan Lasorsa <[email protected]> * chore: update information about the `chat-post.ts` file * docs: Update tutorial files and fix typos for clarity * docs: Update tutorial files and fix typos for clarity --------- Co-authored-by: Yohan Lasorsa <[email protected]>
1 parent 046bc16 commit 0af3f35

15 files changed

+494
-26
lines changed

docs/tutorial/01-introduction.md

+43-25
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
# Tutorial - Create a Serverless ChatGPT with RAG using LangChain.js and TypeScript
1+
# Tutorial - Create a Serverless AI Chat with RAG using LangChain.js and TypeScript
22

3-
Welcome to the tutorial _Create a Serverless ChatGPT with RAG using LangChain.js and TypeScript_.
3+
Welcome to the tutorial _Create a Serverless AI Chat with RAG using LangChain.js and TypeScript_.
44

5-
This tutorial will guide you through creating a serverless a ChatGPT and RAG (Retrieval-Augmented Generation) application using **[LangChain.js](https://js.langchain.com/docs/get_started/introduction)**, **[Azure Functions](https://learn.microsoft.com/azure/azure-functions/)**, **[Azure Cosmos DB for MongoDB vCore](https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/)**, **[Azure Blob Storage](https://learn.microsoft.com/azure/storage/blobs/)**, and **[Azure Static Web Apps](https://learn.microsoft.com/azure/static-web-apps/)**.
5+
This tutorial will guide you through creating a serverless a AI Chat and RAG (Retrieval-Augmented Generation) application using LangChain.js, Azure Functions, Azure Cosmos DB for MongoDB vCore, Azure Blob Storage, and Azure Static Web Apps.
66

7-
The chatbot will be able to answer questions based on a set of enterprise documents uploaded from a fictional company called _Contoso Real Estate_.
7+
The chatbot you're building can answer questions based on a set of enterprise documents uploaded from a fictional company called _Contoso Real Estate_.
88

99
Here's an example of the application in action:
1010

1111
![AI Chat with RAG](../../docs/images/demo.gif)
1212

13-
The goal of the tutorial is to provide you with a hands-on experience building a serverless application using Azure Services and LangChain.js. You'll be guided through each step of the process from setting up the environment to deploying the application.
13+
This tutorial will teach you how to build a serverless application using Azure Functions and LangChain.js.
1414

15-
The frontend of the application is provided so that you can focus on the backend code and technologies.
15+
LangChain.js is a library used for building AI apps. It integrates LLMs, large language models like GPT, Claude-2 and more. It also makes it easy to develop AI-driven chatbots. Next, you'll learn how to set up the environment and deploy the application.
16+
17+
The front end of the application is provided so that you can focus on the backend code and technologies.
1618

1719
## Prerequisites
1820

19-
You can follow tutorial and run the application using one of the following options:
21+
You can run the application in the tutorial using one of the following options:
2022

21-
- Run the application locally on your machine
23+
- Run the application locally on your machine.
2224
- Run the application using Codespaces.
2325

24-
> It is highly recommended to use Codespaces for this tutorial. Codespaces is a cloud-based tool that enables you to run development environments without installing any tools on your computer. This way, you can focus on the development process without worrying about the environment setup.
25-
2626
### Run using Codespaces
2727

28+
> It is highly recommended to use Codespaces for this tutorial. Codespaces is a cloud-based tool that enables you to run development environments without installing any tools on your computer. This way, you can focus on the development process without worrying about the environment setup.
29+
2830
If you decide to continue using **[Codespaces](https://github.com/features/codespaces)**, you can follow the steps described in the README.md file at the root of the project.
2931

3032
> **Note**: If you are using Codespaces, you don't need to install any of the prerequisites mentioned above. Codespaces already has all the necessary tools installed. Codespaces can be used for free for up to 60 hours per month, and this is renewed every month.
3133
3234
### Run Locally
3335

34-
If you choose to use a local environment, you will need to install:
36+
If you choose to use a local environment, you'll need to install:
3537

3638
- [Node.js](https://nodejs.org/en/download/)
3739
- [TypeScript](https://www.typescriptlang.org/download)
@@ -40,11 +42,11 @@ If you choose to use a local environment, you will need to install:
4042
- [Git](https://git-scm.com/downloads)
4143
- [Azure Developer CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
4244

43-
> If you're a Windows user, you'll need to install [PowerShell](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4), [Git Bash](https://git-scm.com/downloads) or [WSL2](https://learn.microsoft.com/windows/wsl/install) to run the bash commands.
45+
> If you are a Windows user, you'll need to install [PowerShell](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4), [Git Bash](https://git-scm.com/downloads) or [WSL2](https://learn.microsoft.com/windows/wsl/install) to run the bash commands.
4446
4547
## Project Overview
4648

47-
Building AI applications can be complex and time-consuming. By using LangChain.js and Azure serverless technologies, you can greatly simplify the process. This application is a chatbot that uses a set of enterprise documents to generate AI responses to user queries.
49+
Building AI applications can be complex and time-consuming. By using LangChain.js and Azure Functions including Serverless technologies, you can greatly simplify the process. These tools streamline the development by managing infrastructure concerns and scaling automatically, allowing you to focus more on building the chatbot functionality and less on the underlying system architecture. This application is a chatbot that uses a set of enterprise documents to generate AI responses to user queries.
4850

4951
The code sample includes sample data to make trying the application quick and easy, but feel free to replace it with your own. You'll use a fictitious company called Contoso Real Estate, and the experience allows its customers to ask support questions about the usage of the company's products. The sample data includes a set of documents that describes the company's terms of service, privacy policy, and support guide.
5052

@@ -58,15 +60,15 @@ To understand the architecture of the project, let's break it down into its indi
5860

5961
1. **Web App:**
6062

61-
- The user interface for the chatbot is a web application built with **[Lit](https://lit.dev/)** (a library for building web components) and hosted using **[Azure Static Web Apps](https://learn.microsoft.com/azure/static-web-apps/overview)**. It renders a chat interface for users to interact with and ask questions.
62-
- The code is located in the `packages/webapp` folder.
63+
- The user interface for the chatbot is a web application built with **[Lit](https://lit.dev/)** (a library for building web components) and hosted using **[Azure Static Web Apps](https://learn.microsoft.com/azure/static-web-apps/overview)**. It provides a chat interface for users they can use to ask questions.
64+
- The code is in the `packages/webapp` folder.
6365

6466
2. **Serverless API:**
6567

66-
- When a user submits a query through the web app, it is sent via HTTP to an API built using Azure Functions.
68+
- When a user sends a query through the web app, it is sent via HTTP to an API built using Azure Functions.
6769
- The API uses LangChain.js to process the query.
68-
- The API handles the logic of ingesting enterprise documents and generating responses to the chat queries.
69-
- The code for this functionality will be shown later in the tutorial and is located in the `packages/api` folder.
70+
- The API manages the logic of corporate documents and responds with answers to chat queries.
71+
- The code for this functionality will be shown later in the tutorial and is in the `packages/api` folder.
7072

7173
3. **Database:**
7274

@@ -79,14 +81,14 @@ To understand the architecture of the project, let's break it down into its indi
7981

8082
5. **Azure OpenAI Service:**
8183

82-
- This service is where the AI Model (a Large Language Model or LLM) is hosted. The model is capable of understanding and generating natural language. This is used to embed text chunks or generate answers based on the vector search from the database.
84+
- This service is where the AI Model (a Large Language Model or LLM) is hosted. The model can understand and generate natural language. This is used to embed text chunks or generate answers based on the vector search from the database.
8385

8486
Let's examine the application flow based on the architecture diagram:
8587

8688
- A user interacts with the chat interface in the web app
8789
- The web app sends the user's query to the Serverless API via HTTP calls
8890
- The Serverless API interacts with Azure OpenAI Service to generate a response, using the data from Azure Cosmos DB for MongoDB vCore.
89-
- If there's a need to reference the original documents, Azure Blob Storage is used to retrieve the PDF documents.
91+
- If there's a need to reference the documents, Azure Blob Storage is used to retrieve the PDF documents.
9092
- The generated response is then sent back to the web app and displayed to the user.
9193

9294
The architecture is based on the RAG (Retrieval-Augmented Generation) architecture. This architecture combines the ability to retrieve information from a database with the ability to generate text from a language model. You'll learn more about RAG later in the tutorial.
@@ -95,7 +97,7 @@ The architecture is based on the RAG (Retrieval-Augmented Generation) architectu
9597

9698
Now that you understand the project's architecture, let's run it!
9799

98-
Once you have `forked` and `cloned` the project, use the `starter` branch to continue with the tutorial. The `main` branch contains the finished project if you wish to view it!
100+
Once you have `forked` and `cloned` the project, use the `starter` branch to continue with the tutorial. The `main` branch has the finished project if you wish to view it!
99101

100102
To execute the project, follow these steps:
101103

@@ -105,20 +107,36 @@ To execute the project, follow these steps:
105107
npm install
106108
```
107109

108-
2. To run the project, with only FrontEnd, execute the following command:
110+
2. To run the project, with only Front-end, execute the following command:
109111

110112
```bash
111-
start:webapp
113+
npm run start:webapp
112114
```
113115

114-
> At this point, don't worry about the other scripts in the `package.json` file at the root of the project. They will be used throughout the tutorial.
116+
> At this point, do not worry about the other scripts in the `package.json` file at the root of the project. They will be used throughout the tutorial.
115117
116118
3. Open your browser and go to `http://localhost:8000`. The application will be displayed, as shown in the image below:
117119

118120
![FrontEnd application](./images/application-webapp.png)
119121

120122
## Next Steps
121123

124+
Here are some additional resources for you to delve into:
125+
126+
- **[Azure Functions Documentation](https://learn.microsoft.com/azure/azure-functions/)**
127+
- **[Azure Cosmos DB for MongoDB vCore Documentation](https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/)**
128+
- **[Azure Blob Storage Documentation](https://learn.microsoft.com/azure/storage/blobs/)**
129+
- **[Azure Static Web Apps Documentation](https://learn.microsoft.com/azure/static-web-apps/)**
130+
- **[LangChain.js Documentation](https://js.langchain.com/docs/get_started/introduction)**
131+
- **[OpenAI API Documentation](https://platform.openai.com/docs/introduction)**
132+
- **[Lit Documentation](https://lit.dev/)**
133+
- **[TypeScript Documentation](https://www.typescriptlang.org/docs/)**
134+
- **[Node.js Documentation](https://nodejs.org/en/docs/)**
135+
- **[Visual Studio Code Documentation](https://code.visualstudio.com/docs)**
136+
- **[Git Documentation](https://git-scm.com/doc)**
137+
- **[Azure Developer CLI Documentation](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)**
138+
- **[PowerShell Documentation](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4)**
139+
122140
In the next section, we will start to create the API using Azure Functions. See you there!
123141

124-
**[Next Step: Setting Up the Serverless Environment using Azure Functions](./02-setting-up-azure-functions.md)**
142+
**[Next Step: Setting Up the Serverless Environment using Azure Functions ➡️](./02-setting-up-azure-functions.md)**

0 commit comments

Comments
 (0)