Skip to content

Commit 037452e

Browse files
code fixes for rag quest
1 parent 48fbf94 commit 037452e

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.github/steps/3-add-chat-ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ azd init -t Azure-Samples/vite-chat-interface
3838
```
3939

4040
> [!Note]
41-
> After running the above command, select **Keep my existing files unchanged** for the following option.
41+
> After running the above command, select **Keep my existing files unchanged** for the following option to prevent your README from being overwritten
4242
>
4343
> ![azd files option to kep](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/azd-files-options.png?raw=true)
4444

.github/steps/4-add-rag.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In this step, you will learn how to add RAG (**R**etrieval-**A**ugmented **G**en
2525
2626
To complete this step, you will need to get a sample dataset in any format (e.g., PDF, CSV, JSON) to work with.
2727

28-
An example, will use a [sample Contoso Electronics Employee Handbook PDF](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/employee_handbook.pdf) file. **You can bring any file of your choice**, but make sure it contains relevant information that you want your AI app to use for RAG. The code provided here will work with any text-based file.
28+
For this quest, as an example, will use a [sample Contoso Electronics Employee Handbook PDF](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/employee_handbook.pdf) file. **You can bring any file of your choice**, but make sure it contains relevant information that you want your AI app to use for RAG. The code provided here will work with any text-based file.
2929

3030
- Create a new folder `data` in the root of your project and move the file in it. To search and read your PDF, you will need to extract the text from it. You can use any PDF parser library of your choice, but for this example, we will use the `pdf-parse` library.
3131

@@ -51,8 +51,7 @@ Open your server code `webapi/server.js` and modify it to include the following
5151

5252
```javascript
5353
// add at the top of the file -----------------------------------------
54-
import ModelClient, { isUnexpected } from "@azure-rest/ai-inference";
55-
import { AzureKeyCredential } from "@azure/core-auth";
54+
import { isUnexpected } from "@azure-rest/ai-inference";
5655
import fs from "fs";
5756
import path from "path";
5857
import { fileURLToPath } from 'url';
@@ -79,7 +78,7 @@ async function loadPDF() {
7978

8079
const dataBuffer = fs.readFileSync(pdfPath);
8180
const data = await pdfParse(dataBuffer);
82-
pdfText = data.text; /
81+
pdfText = data.text;
8382
let currentChunk = "";
8483
const words = pdfText.split(/\s+/);
8584

@@ -135,7 +134,7 @@ app.post("/chat", async (req, res) => {
135134
Use ONLY the following information from the handbook to answer the user's question.
136135
If you can't find relevant information in the provided context, say so clearly.
137136
--- EMPLOYEE HANDBOOK EXCERPTS ---
138-
${sources.join('\n\n')}
137+
${sources.join('')}
139138
--- END OF EXCERPTS ---`
140139
});
141140
} else {
@@ -172,10 +171,9 @@ app.post("/chat", async (req, res) => {
172171
}
173172
});
174173

175-
const PORT = process.env.PORT || 3001;
176-
app.listen(PORT, () => {
177-
console.log(`AI API server running on port ${PORT}`);
178-
});
174+
// --------------------------------------------------------------------
175+
// rest of the code from const PORT ...
176+
179177
```
180178
</details>
181179
@@ -415,4 +413,8 @@ To complete this quest and **AUTOMATICALLY UPDATE** your progress, you MUST push
415413
## 📚 Further Reading
416414
417415
Here are some additional resources to help you learn more about RAG and how to implement it in your applications:
418-
- [Lesson 5: Talk to your data with Retrieval-Augmented Generation (RAG)](https://github.com/microsoft/generative-ai-with-javascript/blob/main/lessons/05-rag/README.md)
416+
- [Lesson 5: Talk to your data with Retrieval-Augmented Generation (RAG)](https://github.com/microsoft/generative-ai-with-javascript/blob/main/lessons/05-rag/README.md)
417+
- [What is retrieval-augmented generation (RAG)?](https://azure.microsoft.com/en-us/resources/cloud-computing-dictionary/what-is-retrieval-augmented-generation-rag)
418+
- [Retrieval augmented generation and indexes](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/retrieval-augmented-generation)
419+
- [Get started with Serverless AI Chat with RAG using LlamaIndex](https://learn.microsoft.com/en-us/azure/developer/javascript/ai/get-started-app-chat-template-llamaindex?tabs=github-codespaces)
420+
- [Get started with Serverless AI Chat with RAG using LangChain.js](https://learn.microsoft.com/en-us/azure/developer/javascript/ai/get-started-app-chat-template-langchainjs?tabs=github-codespaces)

0 commit comments

Comments
 (0)