Skip to content

docs: -adding lesson 2 #7

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

Merged
merged 15 commits into from
Feb 18, 2025
470 changes: 470 additions & 0 deletions lessons/02-first-ai-app/README.md

Large diffs are not rendered by default.

Binary file added lessons/02-first-ai-app/assets/boat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lessons/02-first-ai-app/assets/helicopter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lessons/02-first-ai-app/assets/leonardo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lessons/02-first-ai-app/assets/tokenizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lessons/02-first-ai-app/solution/solution-quiz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Correct: A1, A2
42 changes: 42 additions & 0 deletions lessons/02-first-ai-app/solution/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Here's the solution

```javascript

import { OpenAI } from "openai";
// 1. Define the prompt
// -----------------------------------

const messages = [
{
"role": "developer",
"content": "You're a helpful assistant here to assist Leonardo Da Vinci with the calculations and design of his inventions."

}, {
"role": "user",
"content": "users prompt goes here"
}];

// 2. Create client
// -----------------------------------

const openai = new OpenAI({
baseURL: "https://models.inference.ai.azure.com",
apiKey: process.env.GITHUB_TOKEN,
});


// 3. Send the request
// -----------------------------------

const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: messages,
});

console.log(`Answer for "${question}":`);

// 4. Print the answer
// -----------------------------------

console.log(completion.choices[0]?.message?.content);
```