Skip to content
Merged
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
6 changes: 5 additions & 1 deletion lessons/01-intro-to-genai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ By now, you've likely heard of tools like ChatGPT or Generative AI. The concept

Moreover, Generative AI has evolved into multi modal capabilities, allowing you to provide an image or video as input and receive a variety of outputs. This advancement has significantly enhanced many people's workflows—not only by generating text but also by summarizing, translating, and more.

*Simply put, natural language prompts are becoming the new standard interface for many apps—and your users expect to use them.*
*Simply put, natural language interfaces are becoming the new standard interface for many apps—and your users expect to use them.*

## Narrative: A Journey Through Time

Expand Down Expand Up @@ -349,3 +349,7 @@ Which of the following statements about Generative AI and JavaScript are true?
1. JavaScript powered Generative AI apps can only generate text.
2. JavaScript can be used to build AI-powered applications, including chatbots, text generation tools, and more.
3. Python is the only language used for AI development.

## Self-Study Resources

- [Generative Ai JavaScript video series](https://genai-js)
14 changes: 7 additions & 7 deletions lessons/02-first-ai-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ Leonardo suddenly asked to inspect the time beetle closer, he looked at it from
</div>

> [!NOTE]
> **The aerial screw, also known as the helical air screw,was intended to lift off the ground by compressing air. Leonardo's design featured a large, spiral-shaped rotor made of linen, stiffened with starch, and mounted on a wooden platform. The idea was that a crew of men would run around the platform, turning cranks to rotate the screw rapidly enough to achieve lift
> The aerial screw, also known as the helical air screw,was intended to lift off the ground by compressing air. Leonardo's design featured a large, spiral-shaped rotor made of linen, stiffened with starch, and mounted on a wooden platform. The idea was that a crew of men would run around the platform, turning cranks to rotate the screw rapidly enough to achieve lift
>
> Although Leonardo never built a full-scale version of the aerial screw, his sketches and notes provide detailed insights into how he envisioned it working. He believed that if the screw was turned quickly enough, it would push against the air and lift the entire structure off the ground.
>
Expand Down Expand Up @@ -504,10 +504,10 @@ A3: The context window determines how creative the AI's responses are.

[Solution quiz](./solution/solution-quiz.md)

## References
## Self-Study Resources

- [1] [Text generation](https://platform.openai.com/docs/guides/text-generation)
- [2] [JavaScript library for OpenAI](https://github.com/openai/openai-node/tree/master/examples)
- [3] [Tokenizer](https://platform.openai.com/tokenizer)
- [4] [Completion API](https://platform.openai.com/docs/api-reference/completions)
- [5] [Chat completions](https://platform.openai.com/docs/guides/text-generation#text-generation-models)
- [Text generation](https://platform.openai.com/docs/guides/text-generation)
- [JavaScript library for OpenAI](https://github.com/openai/openai-node/tree/master/examples)
- [Tokenizer](https://platform.openai.com/tokenizer)
- [Completion API](https://platform.openai.com/docs/api-reference/completions)
- [Chat completions](https://platform.openai.com/docs/guides/text-generation#text-generation-models)
14 changes: 7 additions & 7 deletions lessons/03-prompt-engineering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ If you also want to hear some background music of what it could have sounded lik

**Time beetle:** Well, you want to land the aerial screw, right?

**You:** Yes, preferably in one piece. :)
**You:** Yes, preferably in one piece. ☺️

**Time beetle:** I thought so, now listen up! Prompt engineering is about crafting the right prompts to get the desired output from a language model.

Expand Down Expand Up @@ -296,7 +296,7 @@ For the below calculation, take me through your reasoning for each step,

The point to all this is that you shouldn't trust an answer coming from an AI. It's therefore a good idea to take the response through a reasoning process to ensure it is accurate.

**You:** So what I said before :)
**You:** So what I said before ☺️

## Meta prompts

Expand Down Expand Up @@ -362,7 +362,7 @@ As you can see the response mention products that are not provided by Contoso In

**Leonardo:** can your AI gizmo help in calculating to see if we will make it or if we need to make another time jump?

**Time beetle:** I can yes, my name is George though, I prefer that over Gizmo. I'm actually going to leave it to the two of you to figure out how to set up the prompt. :)
**Time beetle:** I can yes, my name is George though, I prefer that over Gizmo. I'm actually going to leave it to the two of you to figure out how to set up the prompt. ☺️

Build an app that asks for:

Expand Down Expand Up @@ -410,10 +410,10 @@ Q: What is prompt engineering?

[Solution quiz](./solutions/solution-quiz.md)

## References
## Self-Study Resources

- [1] [Prompt engineering](https://en.wikipedia.org/wiki/Prompt_engineering)
- [2] [Prompt engineering fundamentals](https://github.com/microsoft/generative-ai-for-beginners/blob/main/04-prompt-engineering-fundamentals/README.md?WT.mc_id=academic-105485-koreyst)
- [3] [Advanced prompt engineering](https://github.com/microsoft/generative-ai-for-beginners/tree/main/05-advanced-prompts)
- [Prompt engineering](https://en.wikipedia.org/wiki/Prompt_engineering)
- [Prompt engineering fundamentals](https://github.com/microsoft/generative-ai-for-beginners/blob/main/04-prompt-engineering-fundamentals/README.md?WT.mc_id=academic-105485-koreyst)
- [Advanced prompt engineering](https://github.com/microsoft/generative-ai-for-beginners/tree/main/05-advanced-prompts)


2 changes: 1 addition & 1 deletion lessons/03-prompt-engineering/solutions/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Here's the solution:

```javascript
import { OpenAI } from "openai";
import readline from "readline";
import readline from "node:readline";

const rl = readline.createInterface({
input: process.stdin,
Expand Down
18 changes: 12 additions & 6 deletions lessons/04-structured-output/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Upon reaching the top of the pyramid, you are led into a grand chamber where Mon

**Leonardo:** "We come in peace," he says, his voice steady. "We seek knowledge and understanding. Allow us to demonstrate the power of our machine and share our knowledge with you."

**Montezuma:** "Very well. I propose a game of Patolli. If I win the best of three games, you will give me your device and tell me how it works. If you win, you are free to go."
**Montezuma:** "Very well. I propose a game of [Patolli](#patolli). If I win the best of three games, you will give me your device and tell me how it works. If you win, you are free to go."

<div>
<img src="./assets/game.png" alt="Playing a game of Patolli" width="300" />
Expand All @@ -104,6 +104,8 @@ With a final, decisive move, Leonardo wins the game. The room erupts in cheers a

**Leonardo:** _smirks_

### Patolli

> [!NOTE]
> Patolli is one of the oldest known games in the Americas, played by various pre-Columbian Mesoamerican cultures, including the Aztecs.
>
Expand Down Expand Up @@ -169,7 +171,7 @@ Generative AI models can output data in various formats. However, output of unst

**You:** Well, aren't you clever ;)

**Time beetle:** I try my best :)
**Time beetle:** I try my best ☺️

Another benefit, even for human readers, is that structured data is easier to read and understand when it follows a familiar format.

Expand All @@ -181,7 +183,7 @@ Let's look at a few examples of input and asking for specific output formats can

**Time beetle:** Let's start with a simple example. Imagine you're Leonardo da Vinci and you're trying to come up with ideas for inventions using 15th-century technology. You want to know what resources you need and how much effort it would take to build each invention. Here's how you can ask for this information:

**Leonardo:** Oh I like this game, everyone pretend you're me :)
**Leonardo:** Oh I like this game, everyone pretend you're me ☺️

> Prompt: Generate ideas for inventions I can build using 15th-century technology. For each invention, specify the required resources and estimate the effort needed to build it.

Expand Down Expand Up @@ -254,9 +256,9 @@ This time we end up with a table that is easier to read and understand.

### Presenting an output template

Another way of getting structured output is to present an output template, here it can be any format, from columns to JSON, XML, or CSV.
Another way of getting structured output is to present an output template, here it can be any format, from columns to JSON, XML, CSV to markdown.

> Prompt Generate ideas for inventions that can be built using 15th-century technology. For each invention, specify the required resources and estimate the effort needed to construct it. Present the information using the following format:
> Prompt: Generate ideas for inventions that can be built using 15th-century technology. For each invention, specify the required resources and estimate the effort needed to construct it. Present the information using the following format (use markdown as output format):
>
> Title: [Invention Name]
> Description: [Brief Explanation]
Expand Down Expand Up @@ -533,7 +535,7 @@ This combination of presenting skills and parameters and extracting data from pr
**Leonardo:** So I managed to fix the damage to the aerial screw but now it needs a boot sequence: left left up right:
You: sounds easy enough, just that text?

**Leonardo:** Yes, but it' special, it needs to be mirrored, that's how I write all my text. And of course I use a Caesar cipher with a shift of 3 because I'm Italian. :)
**Leonardo:** Yes, but it' special, it needs to be mirrored, that's how I write all my text. And of course I use a Caesar cipher with a shift of 3 because I'm Italian. ☺️

**You:** Yes, could you just type it in then?

Expand Down Expand Up @@ -579,3 +581,7 @@ Q: What is structured output used for?


[Solution quiz](./solution/solution-quiz.md)

## Self-Study Resources

- [Generative AI with JavaScript video series](https://aka.ms/genai-js)
4 changes: 2 additions & 2 deletions lessons/04-structured-output/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const distance = 100;

// Create prompt including inputs should include chain of thought

const boot_sequence = `left left up right`;
const bootSequence = `left left up right`;

const prompt = `Provide the boot sequence for the aerial screw, the text should be mirrored and encoded with a Caesar cipher with a shift of 3. The boot sequence is: ${boot_sequence}.`;
const prompt = `Provide the boot sequence for the aerial screw, the text should be mirrored and encoded with a Caesar cipher with a shift of 3. The boot sequence is: ${bootSequence}.`;

// Call the language model with the prompt

Expand Down
7 changes: 2 additions & 5 deletions lessons/05-rag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ for await (const chunk of chunks) {
}
```

> [!IMPORTANT]
> Follow [the dev setup guide](../../docs/dev-setup.md) to see how to setup your environment to run this code.

You can find this code in the `example/rag-cars.js` file along with the `hybrid.csv` file containing the data used for the retrieval.

**Ada:** Once you run this code, you should see the data found by in the CSV file by the retriever, formatted as a markdown table, followed by the AI-generated response to the question. Try changing the question to see how the retrieved data and response changes. You can also try asking questions about unrelated topics to see how the AI model handles them.
Expand Down Expand Up @@ -348,8 +345,8 @@ const text = Object.values(data.query.pages)[0]?.extract;

## Self-Study Resources

- **Learn docs:** [Retrieval-Augmented Generation and Indexes](https://learn.microsoft.com/azure/ai-studio/concepts/retrieval-augmented-generation)
- [Retrieval-Augmented Generation and Indexes](https://learn.microsoft.com/azure/ai-studio/concepts/retrieval-augmented-generation)
- **Sample apps**:
* [Serverless AI Chat with RAG](https://github.com/Azure-Samples/serverless-chat-langchainjs/)
* [Ask Youtube: A RAG-based Youtube Q&A API](https://github.com/Azure-Samples/langchainjs-quickstart-demo)
- **Full length workshop:** [Create your own ChatGPT with RAG](https://moaw.dev/workshop/gh:azure-samples/azure-openai-rag-workshop/docs/workshop-qdrant.md)
- [Full length workshop: Create your own ChatGPT with RAG](https://moaw.dev/workshop/gh:azure-samples/azure-openai-rag-workshop/docs/workshop-qdrant.md)