Skip to content

Docs/formating fix #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/setup/getting-started-azure-openai.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
Expand All @@ -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:

Expand Down
65 changes: 28 additions & 37 deletions lessons/03-prompt-engineering/sample-app/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { OpenAI } from "openai";
import readline from "readline";

// User input
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
Expand All @@ -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();