Skip to content

Commit b83c746

Browse files
committed
Markdown code workaround
1 parent 8843092 commit b83c746

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

Instructions/Labs/03-prompt-engineering.md

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -89,51 +89,51 @@ Before using your app, examine how prompt engineering improves the model respons
8989
**User:**
9090
9191
```code
92-
New York Baseballers Wins Big Against Chicago
93-
94-
New York Baseballers mounted a big 5-0 shutout against the Chicago Cyclones last night, solidifying their win with a 3 run homerun late in the bottom of the 7th inning.
95-
96-
Pitcher Mario Rogers threw 96 pitches with only two hits for New York, marking his best performance this year.
97-
98-
The Chicago Cyclones' two hits came in the 2nd and the 5th innings, but were unable to get the runner home to score.
92+
New York Baseballers Wins Big Against Chicago
93+
94+
New York Baseballers mounted a big 5-0 shutout against the Chicago Cyclones last night, solidifying their win with a 3 run homerun late in the bottom of the 7th inning.
95+
96+
Pitcher Mario Rogers threw 96 pitches with only two hits for New York, marking his best performance this year.
97+
98+
The Chicago Cyclones' two hits came in the 2nd and the 5th innings, but were unable to get the runner home to score.
9999
```
100100
101101
**Assistant:**
102102
103103
```code
104-
Sports
104+
Sports
105105
```
106106
107107
1. Add another example with the following text.
108108
109109
**User:**
110110
111111
```code
112-
Joyous moments at the Oscars
112+
Joyous moments at the Oscars
113113
114-
The Oscars this past week where quite something!
115-
116-
Though a certain scandal might have stolen the show, this year's Academy Awards were full of moments that filled us with joy and even moved us to tears.
117-
These actors and actresses delivered some truly emotional performances, along with some great laughs, to get us through the winter.
118-
From Robin Kline's history-making win to a full performance by none other than Casey Jensen herself, don't miss tomorrows rerun of all the festivities.
114+
The Oscars this past week where quite something!
115+
116+
Though a certain scandal might have stolen the show, this year's Academy Awards were full of moments that filled us with joy and even moved us to tears.
117+
These actors and actresses delivered some truly emotional performances, along with some great laughs, to get us through the winter.
118+
From Robin Kline's history-making win to a full performance by none other than Casey Jensen herself, don't miss tomorrows rerun of all the festivities.
119119
```
120120
121121
**Assistant:**
122122
123123
```code
124-
Entertainment
124+
Entertainment
125125
```
126126
127127
1. Save those changed to the assistant setup, and send the same prompt about California drought, provided here again for convenience.
128128
129129
```code
130-
Severe drought likely in California
130+
Severe drought likely in California
131131
132-
Millions of California residents are bracing for less water and dry lawns as drought threatens to leave a large swath of the region with a growing water shortage.
133-
134-
In a remarkable indication of drought severity, officials in Southern California have declared a first-of-its-kind action limiting outdoor water use to one day a week for nearly 8 million residents.
135-
136-
Much remains to be determined about how daily life will change as people adjust to a drier normal. But officials are warning the situation is dire and could lead to even more severe limits later in the year.
132+
Millions of California residents are bracing for less water and dry lawns as drought threatens to leave a large swath of the region with a growing water shortage.
133+
134+
In a remarkable indication of drought severity, officials in Southern California have declared a first-of-its-kind action limiting outdoor water use to one day a week for nearly 8 million residents.
135+
136+
Much remains to be determined about how daily life will change as people adjust to a drier normal. But officials are warning the situation is dire and could lead to even more severe limits later in the year.
137137
```
138138
139139
1. This time the model should respond with an appropriate classification, even without instructions.
@@ -155,22 +155,22 @@ To show how to integrate with an Azure OpenAI model, we'll use a short command-l
155155
5. Once the terminal starts, enter the following command to download the sample application and save it to a folder called `azure-openai`.
156156
157157
```bash
158-
rm -r azure-openai -f
159-
git clone https://github.com/MicrosoftLearning/mslearn-openai azure-openai
158+
rm -r azure-openai -f
159+
git clone https://github.com/MicrosoftLearning/mslearn-openai azure-openai
160160
```
161161
162162
6. The files are downloaded to a folder named **azure-openai**. Navigate to the lab files for this exercise using the following command.
163163
164164
```bash
165-
cd azure-openai/Labfiles/03-prompt-engineering
165+
cd azure-openai/Labfiles/03-prompt-engineering
166166
```
167167
168168
Applications for both C# and Python have been provided, as well as a text files that provide the prompts. Both apps feature the same functionality.
169169
170170
Open the built-in code editor, and you can observe the prompt files that you'll be using in `prompts`. Use the following command to open the lab files in the code editor.
171171
172172
```bash
173-
code .
173+
code .
174174
```
175175
176176
## Configure your application
@@ -191,96 +191,96 @@ For this exercise, you'll complete some key parts of the application to enable u
191191
**C#**
192192
193193
```bash
194-
cd CSharp
195-
dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.5
194+
cd CSharp
195+
dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.5
196196
```
197197
198198
**Python**
199199
200200
```bash
201-
cd Python
202-
pip install python-dotenv
203-
pip install openai
201+
cd Python
202+
pip install python-dotenv
203+
pip install openai
204204
```
205205
206206
5. Navigate to your preferred language folder, select the code file, and add the necessary libraries.
207207
208208
**C#**
209209
210210
```csharp
211-
// Add Azure OpenAI package
212-
using Azure.AI.OpenAI;
211+
// Add Azure OpenAI package
212+
using Azure.AI.OpenAI;
213213
```
214214
215215
**Python**
216216
217217
```python
218-
# Add OpenAI import
219-
import openai
218+
# Add OpenAI import
219+
import openai
220220
```
221221
222222
5. Open up the application code for your language and add the necessary code for configuring the client.
223223
224224
**C#**
225225
226226
```csharp
227-
// Initialize the Azure OpenAI client
228-
OpenAIClient client = new OpenAIClient(new Uri(oaiEndpoint), new AzureKeyCredential(oaiKey));
227+
// Initialize the Azure OpenAI client
228+
OpenAIClient client = new OpenAIClient(new Uri(oaiEndpoint), new AzureKeyCredential(oaiKey));
229229
```
230230
231231
**Python**
232232
233233
```python
234-
# Set OpenAI configuration settings
235-
openai.api_type = "azure"
236-
openai.api_base = azure_oai_endpoint
237-
openai.api_version = "2023-03-15-preview"
238-
openai.api_key = azure_oai_key
234+
# Set OpenAI configuration settings
235+
openai.api_type = "azure"
236+
openai.api_base = azure_oai_endpoint
237+
openai.api_version = "2023-03-15-preview"
238+
openai.api_key = azure_oai_key
239239
```
240240
241241
6. In the function that calls the Azure OpenAI model, add the code to format and send the request to the model.
242242
243243
**C#**
244244
245245
```csharp
246-
// Create chat completion options
247-
var chatCompletionsOptions = new ChatCompletionsOptions()
248-
{
249-
Messages =
250-
{
251-
new ChatMessage(ChatRole.System, systemPrompt),
252-
new ChatMessage(ChatRole.User, userPrompt)
253-
},
254-
Temperature = 0.7f,
255-
MaxTokens = 800,
256-
};
257-
258-
// Get response from Azure OpenAI
259-
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(
260-
oaiModelName,
261-
chatCompletionsOptions
262-
);
263-
264-
ChatCompletions completions = response.Value;
265-
string completion = completions.Choices[0].Message.Content;
246+
// Create chat completion options
247+
var chatCompletionsOptions = new ChatCompletionsOptions()
248+
{
249+
Messages =
250+
{
251+
new ChatMessage(ChatRole.System, systemPrompt),
252+
new ChatMessage(ChatRole.User, userPrompt)
253+
},
254+
Temperature = 0.7f,
255+
MaxTokens = 800,
256+
};
257+
258+
// Get response from Azure OpenAI
259+
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(
260+
oaiModelName,
261+
chatCompletionsOptions
262+
);
263+
264+
ChatCompletions completions = response.Value;
265+
string completion = completions.Choices[0].Message.Content;
266266
```
267267
268268
**Python**
269269
270270
```python
271-
# Build the messages array
272-
messages =[
273-
{"role": "system", "content": system_message},
274-
{"role": "user", "content": user_message},
275-
]
276-
277-
# Call the Azure OpenAI model
278-
response = openai.ChatCompletion.create(
279-
engine=model,
280-
messages=messages,
281-
temperature=0.7,
282-
max_tokens=800
283-
)
271+
# Build the messages array
272+
messages =[
273+
{"role": "system", "content": system_message},
274+
{"role": "user", "content": user_message},
275+
]
276+
277+
# Call the Azure OpenAI model
278+
response = openai.ChatCompletion.create(
279+
engine=model,
280+
messages=messages,
281+
temperature=0.7,
282+
max_tokens=800
283+
)
284284
```
285285
286286
## Run your application

0 commit comments

Comments
 (0)