diff --git a/docs/setup/getting-started-azure-openai.md b/docs/setup/getting-started-azure-openai.md index 95aa992..2f15cb0 100644 --- a/docs/setup/getting-started-azure-openai.md +++ b/docs/setup/getting-started-azure-openai.md @@ -1,11 +1,11 @@ # Setting Up the Development Environment for Azure OpenAI -Azure AI Foundry is a service that allows you to deploy and manage AI models in the cloud. You can things like create a project, deploy a model, interact with the model, and more. +Azure AI Foundry is a service that allows you to deploy and manage AI models in the cloud. You can do things like create a project, deploy a model, interact with the model, and more. > [!NOTE] > If you want to use Azure AI Foundry models for your .NET AI apps in this course, follow the steps in this guide. -πŸ‘‰ [To use GitHub Models this is the guide for you](./README.md) +πŸ‘‰ [If you want to use GitHub models, follow this guide instruction.](./README.md) ## Create the Azure AI Foundry resources @@ -15,7 +15,7 @@ To use Azure AI Foundry models, you need to take the following steps: 1. Deploy a model to your project. 1. Add the Azure AI library code + API key and other credentials to your code. -### -1- Create a Hub and Project in Azure AI Foundry +### Step 1: Create a Hub and Project in Azure AI Foundry 1. Go to the [Azure AI Foundry Portal](https://ai.azure.com/). 1. Sign in with your Azure account. @@ -36,7 +36,7 @@ To use Azure AI Foundry models, you need to take the following steps: Before you can interact with the model, you need to deploy it to your project, so let's do that next. -### -2- Deploy a Language Model in Azure AI Foundry +### Step 2 : Deploy a Language Model in Azure AI Foundry Now, let’s deploy a **gpt-4o-mini** model to your project: diff --git a/lessons/03-prompt-engineering/sample-app/app.js b/lessons/03-prompt-engineering/sample-app/app.js index c277e1b..5c4c74e 100644 --- a/lessons/03-prompt-engineering/sample-app/app.js +++ b/lessons/03-prompt-engineering/sample-app/app.js @@ -1,6 +1,7 @@ import { OpenAI } from "openai"; import readline from "readline"; +// User input const rl = readline.createInterface({ input: process.stdin, output: process.stdout @@ -14,48 +15,38 @@ const question = (query) => { }); }; -const height = await question("Enter the current height above the ground in meters:"); +async function main() { + const userPrompt = await question("Enter your prompt: "); -const speed = await question("Enter the speed at which you're moving forward in meters per second:"); + const messages = [ + { + role: "user", + content: userPrompt + } + ]; -const gravity = await question("Enter the gravity in meters per second squared:"); - -const wind = await question("Enter the wind speed upwards in meters per second:"); - -// Distance to the hill -const distance = 100; - -// Create prompt including inputs should include chain of thought - -const prompt = "TODO"; - -// Call the language model with the prompt - -const messages = [ -{ - "role": "user", - "content": prompt -}]; - -// 2. Create client -// ----------------------------------- - -const openai = new OpenAI({ - baseURL: "https://models.inference.ai.azure.com", - apiKey: process.env.GITHUB_TOKEN, -}); - -// 3. Send the request -// ----------------------------------- + // OpenAI API setup + const openai = new OpenAI({ + baseURL: "https://models.inference.ai.azure.com", + apiKey: process.env.GITHUB_TOKEN, + }); -const completion = await openai.chat.completions.create({ + const completion = await openai.chat.completions.create({ model: 'gpt-4o-mini', messages: messages, -}); + }); + + const answer = completion.choices[0]?.message?.content; + + console.log(`\nAI Response:\n`); + console.log(answer); -console.log(`Answer for "${prompt}":`); + // Easter Egg Check + if (userPrompt.toLowerCase().includes("time-traveling javascript developer") && answer) { + console.log("\n Easter Egg Unlocked! You discovered the hidden poem! "); + } -// 4. Print the answer -// ----------------------------------- + rl.close(); +} -console.log(completion.choices[0]?.message?.content); +main();