Skip to content

Commit b039d22

Browse files
authored
Merge pull request #18 from Azure-Samples/main
sync changes to my branch
2 parents 1ba350e + 676ba34 commit b039d22

File tree

9 files changed

+109
-45
lines changed

9 files changed

+109
-45
lines changed

.github/steps/1-genai-prototype.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ With GitHub Models, you can use GitHub Personal Access Tokens (PAT) to authentic
2323
1. Right click [GitHub Models](https://github.com/marketplace/models) and open in a new tab
2424

2525
> [!NOTE]
26-
> Open the link IN A NEW TAB so you can keep this page open for reference.
26+
> Open the link IN A NEW TAB so you can keep this page open for reference. You can use the _Split Screen_ feature on Edge to have this instructions and GitHub Models/ VS Code open side-by-side
2727
2828
2. Click on **explore the full model catalog** to see the available models.
2929

@@ -142,7 +142,7 @@ Now that you have a better understanding of the models from the GitHub Models pl
142142

143143
## 📌 Exercise: Convert a hand-drawn sketch to a web page
144144

145-
1. Download the contoso website hand-drawn sketch from [this link](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/contoso_layout_sketch.jpg), and save it `contoso_layout_sketch.jpg` in the same directory as your `sample.js` file.
145+
1. Download the contoso website hand-drawn sketch from [this link](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/contoso_layout_sketch.jpg), _(right click and open in new tab)_. and save it `contoso_layout_sketch.jpg` in the same directory as your `sample.js` file.
146146

147147
> **Note**
148148
>
@@ -214,11 +214,12 @@ To complete this quest and **AUTOMATICALLY UPDATE** your progress, you MUST push
214214

215215
Here are some additional resources to help you learn more about experimenting with AI models and building prototypes:
216216

217+
- [About GitHub Models](https://docs.github.com/en/github-models/about-github-models)
218+
- [Choosing the right AI model for your task](https://docs.github.com/en/copilot/using-github-copilot/ai-models/choosing-the-right-ai-model-for-your-task)
219+
- [Introducing GitHub Models: A new generation of AI engineers building on GitHub](https://github.blog/news-insights/product-news/introducing-github-models/)
220+
- [📹 DEM500: Prototype, build, and deploy AI apps quickly with GitHub Models](https://build.microsoft.com/en-US/sessions/DEM500?source=sessions)
221+
- [What is the AI Toolkit for Visual Studio Code?](https://learn.microsoft.com/en-us/windows/ai/toolkit/)
217222
- [Lesson 1: Introduction to Generative AI and LLMs for JavaScript Developers](https://github.com/microsoft/generative-ai-with-javascript/tree/main/lessons/01-intro-to-genai#lesson-1-introduction-to-generative-ai-and-llms-for-javascript-developers)
218223
- [Lesson 2: Writing your first AI app](https://github.com/microsoft/generative-ai-with-javascript/blob/main/lessons/02-first-ai-app/README.md#lesson-2-writing-your-first-ai-app)
219224
- [Lesson 3: Prompt Engineering](https://github.com/microsoft/generative-ai-with-javascript/blob/main/lessons/03-prompt-engineering/README.md)
220-
- [GitHub Models - Your AI toolbox built into GitHub](https://github.com/features/models)
221-
- [Install the AI Toolkit](https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.windows-ai-studio&ssr=false#overview) to browse and download public and custom models; author, test and evaluate prompts; fine-tune; and use them in your applications.
222-
- [What is the AI Toolkit for Visual Studio Code?](https://learn.microsoft.com/en-us/windows/ai/toolkit/)
223-
- [Build Apps and Agents with Visual Studio Code and Azure blog](https://devblogs.microsoft.com/blog/build-apps-and-agents-with-visual-studio-code-and-azure)
224-
- A curated set of essential extensions for building generative AI applications and agents in Visual Studio Code. Install [the Microsoft AI Tools Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.microsoft-ai-tools-pack)
225+
- [Microsoft AI Tools Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.microsoft-ai-tools-pack), a curated set of essential extensions for building generative AI applications and agents in VS Code

.github/steps/2-to-azure.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To continue working with your deployed model in VS Code, you will need to instal
7070
6. Create a `.env` file in your project folder and update it with the following environment variables:
7171

7272
```bash
73-
AZURE_INFERENCE_API_KEY=your_api_key
73+
AZURE_INFERENCE_SDK_KEY=your_api_key
7474
AZURE_INFERENCE_SDK_ENDPOINT=your_api_endpoint
7575
```
7676

@@ -126,8 +126,5 @@ Here are some additional resources to help you learn more about getting started
126126

127127
- [Azure AI Foundry Extension for Visual Studio Code is Available in Preview](https://devblogs.microsoft.com/foundry/azure-ai-foundry-vscode-extension-preview/)
128128
- [Work with the Azure AI Foundry for Visual Studio Code extension docs](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/get-started-projects-vs-code)
129-
- [📹 DEM500: Prototype, build, and deploy AI apps quickly with GitHub Models](https://build.microsoft.com/en-US/sessions/DEM500?source=sessions)
130129
- [📹 BRK107: Develop, Build and Deploy LLM Apps using GitHub Models and Azure AI Foundry](https://build.microsoft.com/en-US/sessions/BRK107?source=sessions)
131-
- [Build with the AI Foundry JavaScript SDK](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/sdk-overview?pivots=programming-language-javascript)
132-
<!-- - [JavaScript SDK for Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/sdk-overview?tabs=sync&pivots=programming-language-python) -->
133-
- A curated set of essential extensions for building generative AI applications and agents in Visual Studio Code. Install [the Microsoft AI Tools Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.microsoft-ai-tools-pack)
130+
- [Microsoft AI Tools Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-windows-ai-studio.microsoft-ai-tools-pack), a curated set of essential extensions for building generative AI applications and agents in VS Code

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ In your current working directory, _(at the root)_, run the following command to
3737
azd init -t Azure-Samples/vite-chat-interface
3838
```
3939

40+
> [!Note]
41+
> After running the above command, select **Keep my existing files unchanged** for the following option to prevent your README from being overwritten
42+
>
43+
> ![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)
44+
4045
This will initialize a new Vite project and add the necessary files and folders to your project:
4146

4247
```markdown
@@ -226,7 +231,7 @@ The project is already configured to deploy the webapp (frontend) to Azure Stati
226231

227232
```yaml
228233
webapp:
229-
project: packages/webapp
234+
project: webapp
230235
host: staticwebapp
231236
language: js
232237
dist: dist
@@ -254,11 +259,13 @@ module webapp 'br/public:avm/res/web/static-site:0.7.0' = {
254259
}
255260
}
256261
```
262+
However, remember you updated the path to the `webapp` folder when we moved it to the `packages` folder. **So change the project path in `azure.yaml` to `project: packages/webapp` for the webapp service**
263+
257264
The webapi service is not yet configured in the `azure.yaml` file. To add the webapi service, add the following code to the `azure.yaml` file inside the `services` node:
258265

259266
```yaml
260267
webapi:
261-
project: packages/webapp
268+
project: packages/webapi
262269
host: appservice
263270
language: js
264271
```
@@ -281,6 +288,7 @@ module webapi 'br/public:avm/res/web/site:0.15.1' = {
281288
params: {
282289
kind: 'app'
283290
name: webapiName
291+
tags: union(tags, { 'azd-service-name': webapiName })
284292
serverFarmResourceId: serverfarm.outputs.resourceId
285293
}
286294
}
@@ -289,7 +297,7 @@ module webapi 'br/public:avm/res/web/site:0.15.1' = {
289297
Declare the following parameters at the top of the `main.bicep` file to pass the names of the webapi and app service plan to the module:
290298

291299
```bash
292-
param webapiName string = 'webapi'
300+
param webapiName string = '<your-unique-string>' #use a unique string. avoid common names like webapi, website etc.
293301
param appServicePlanName string = 'appserviceplan'
294302
```
295303

@@ -337,8 +345,6 @@ To complete this quest and **AUTOMATICALLY UPDATE** your progress, you MUST push
337345

338346
Here are some additional resources to help you learn more about tools used in this step:
339347

340-
- https://vite.dev/
341-
- https://lit.dev/
342348
- [Accelerate your journey to the cloud with azd](https://azure.github.io/awesome-azd/getting-started)
343349
- [📹 BRK118: Accelerate Azure Development with GitHub Copilot, VS Code & AI](https://build.microsoft.com/en-US/sessions/BRK118?source=sessions)
344350
- [Introducing the Azure Developer CLI (azd): A faster way to build apps for the cloud blog](https://devblogs.microsoft.com/azure-sdk/introducing-the-azure-developer-cli-a-faster-way-to-build-apps-for-the-cloud/)

.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)

.github/steps/5-frameworks.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ The current api code uses the Azure REST SDK directly. By switching to LangChain
3838
Open `server.js` and replace:
3939

4040
```javascript
41-
import ModelClient, { isUnexpected } from "@azure-rest/ai-inference";
4241
import { AzureKeyCredential } from "@azure/core-auth";
42+
import { isUnexpected } from "@azure-rest/ai-inference";
4343
```
4444

4545
with:
@@ -71,6 +71,9 @@ const chatModel = new AzureChatOpenAI({
7171
});
7272
```
7373

74+
> [!Note]
75+
> Update your `.env` with the missing variables
76+
7477
### Update chat endpoint
7578

7679
Replace the Azure REST SDK api call logic in the try-catch block (_app.post("/chat")_) with the following code:
@@ -124,7 +127,7 @@ import { ChatMessageHistory } from "langchain/stores/message/in_memory";
124127
Store session histories, allowing you to maintain separate chat histories for different users or sessions.
125128

126129
```javascript
127-
const sessionHistories = {};
130+
const sessionMemories = {};
128131
```
129132

130133
### Add a helper function to get/create a session history
@@ -170,8 +173,7 @@ app.post("/chat", async (req, res) => {
170173
? {
171174
role: "system",
172175
content: sources.length > 0
173-
? `You are a helpful assistant for Contoso Electronics. You must ONLY use the information provided below to answer.\n\n--- EMPLOYEE HANDBOOK EXCERPTS ---\n${sources.join('\n\n')}\n--- END OF EXCERPTS ---`
174-
: `You are a helpful assistant for Contoso Electronics. The excerpts do not contain relevant information for this question. Reply politely: "I'm sorry, I don't know. The employee handbook does not contain information about that."`,
176+
? `You are a helpful assistant for Contoso Electronics. You must ONLY use the information provided below to answer.\\n\\n--- EMPLOYEE HANDBOOK EXCERPTS ---\\n${sources.join('\\n\\n')}\\n--- END OF EXCERPTS ---`\n : `You are a helpful assistant for Contoso Electronics. The excerpts do not contain relevant information for this question. Reply politely: \"I'm sorry, I don't know. The employee handbook does not contain information about that.\"`,
175177
}
176178
: {
177179
role: "system",
@@ -233,5 +235,8 @@ To complete this quest and **AUTOMATICALLY UPDATE** your progress, you MUST push
233235
## 📚 Further Reading
234236

235237
Here are some additional resources to help you learn more about LangChain.js and its features:
236-
- [Serverless AI Chat with RAG using LangChain.js sample](https://github.com/Azure-Samples/serverless-chat-langchainjs)
238+
- [Get started with Serverless AI Chat with RAG using LangChain.js](https://github.com/Azure-Samples/serverless-chat-langchainjs)
239+
- [LangChain.js x Microsoft docs](https://js.langchain.com/docs/integrations/platforms/microsoft/)
240+
- [Ask YouTube: LangChain.js + Azure Quickstart](https://github.com/Azure-Samples/langchainjs-quickstart-demo)
241+
- [LangChain.js + Azure: A Generative AI App Journey](https://techcommunity.microsoft.com/blog/educatordeveloperblog/langchain-js--azure-a-generative-ai-app-journey/4101258)
237242
- [LangChain.js docs](https://js.langchain.com/docs/introduction/)

.github/steps/6-build-agent.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@ options:
152152

153153
Save the `bing.yaml` file.
154154

155-
On the Agent Designer, click on the + icon next to the "Tools" section. This will prompt you to select a yaml file for the tool. Select the `bing.yaml` file you created earlier. Click on **Deploy to Azure AI Foundry** to deploy your updated agent with the new tool to Azure AI Foundry.
155+
On the Agent Designer, click on the + icon next to the "Tools" section. This will prompt you to select a yaml file for the tool. Select the `bing.yaml` file you created earlier. Click on **Update Agent on Azure AI Foundry** to update your agent with the new tool to Azure AI Foundry.
156156

157-
![Add bing tool via extension](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/add-bing.png?raw=true)
157+
![Add bing tool via extension](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/update-tool.png?raw=true)
158158

159159
Now that we have added the Bing Search API tool to our agent, we can test it in the Playground. Open the "Agent Playground" and send the agent a message like _"What's the weather in Nairobi right now?"_ The agent should use the Bing Search API tool to fetch the current weather information and respond with a friendly message.
160160

161161
![Weather with Bing](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/weather-with-bing.png?raw=true)
162162

163163

164-
## Step 4️⃣: Agent playground to Code
164+
<!-- ## Step 4️⃣: Agent playground to Code
165165
166166
The Agent Playground is a great way to test your agent's capabilities, but it's not the only way to interact with it. In this step, we will update our application to use the agent we just created. This will allow us to use the agent in our application and make it more useful.
167167
@@ -463,10 +463,10 @@ On the app, select the **Agent** mode from the dropdown. Type a message in the i
463463
464464
If you ask the agent a question that requires real-time information, such as _"What's the current weather in Spain?"_, the agent should ground its response using the Bing Search API and provide you with the latest information.
465465
466-
![Weather in Spain in Agent mode](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/weather-in-spain.png?raw=true)
466+
![Weather in Spain in Agent mode](https://github.com/Azure-Samples/JS-AI-Build-a-thon/blob/assets/jsai-buildathon-assets/weather-in-spain.png?raw=true) -->
467467

468468

469-
## ✅ Activity: Push your updated code to the repository
469+
## ✅ Activity: Push your updated code to the repository - TBD
470470

471471
### Quest Checklist
472472

@@ -494,5 +494,6 @@ To complete this quest and **AUTOMATICALLY UPDATE** your progress, you MUST push
494494
Here are some additional resources to help you learn more about building AI agents and extending their capabilities with tools:
495495
- [Azure AI Agents JavaScript examples](https://github.com/Azure-Samples/azure-ai-agents-javascript)
496496
- [Your First AI Agent in JS with Azure AI Agent Service](https://www.youtube.com/live/RNphlRKvmJQ?si=I3rUp-LmnvS008ym)
497-
- [Create a new Agent - JS/TS](https://learn.microsoft.com/en-us/azure/ai-services/agents/quickstart?pivots=programming-language-javascript)
498-
- [📹 DEMFP781: From Prompt to Product: Build an AI Agent That Generates UI](https://build.microsoft.com/en-US/sessions/DEMFP781?source=sessions)
497+
- [Build Apps and Agents with Visual Studio Code and Azure blog](https://devblogs.microsoft.com/blog/build-apps-and-agents-with-visual-studio-code-and-azure)
498+
- [📹 DEMFP781: From Prompt to Product: Build an AI Agent That Generates UI](https://build.microsoft.com/en-US/sessions/DEMFP781?source=sessions)
499+
- [Build with the AI Foundry JavaScript SDK](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/sdk-overview?pivots=programming-language-javascript)

0 commit comments

Comments
 (0)