Code Monkey home page Code Monkey logo

mslearn-openai's Introduction

Develop AI solutions with Azure OpenAI

This repo contains the instructions and assets required to complete the exercises in the Develop AI solutions with Azure OpenAI learning path on Microsoft Learn.

Reporting issues

If you encounter any problems in the exercises, please report them as issues in this repo.

mslearn-openai's People

Contributors

ethanknights avatar graememalcolm avatar infhyroyage avatar ivorb avatar layzeedk avatar massimobonanni avatar mihai-ac avatar mkennten avatar msftnutta avatar paul-msft avatar sherzyang avatar thediverdk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mslearn-openai's Issues

Update Lab 5 to use DALL-E 3 model so that Sweden Central can be an alternative Azure Region

Module: 5

Lab/Demo: 5

Task: Use the REST API to generate images

Step: 00

Description of issue
Currently Lab 5 is using DALL-E 2 which is only available in East US. Suggest using DALL-E 3 which is now available in both East US & Sweden Central to avoid a single point of failure and for load balancing purposes.

Repro steps:

Both C# & Python environment needs to include a third variable to account for the DALL-E 3 deployment ID. Also the request string the main code body needs to be changed as well. Reference this document for more details. https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#request-a-generated-image-dall-e-3

Single 8-hour lab VM instead of Six 1-hour labs?

The AI-050 has 6 labs, which are rather similar from the code boiler-plate perspective. The lab hoster (Skillable) has these as 6 separate labs, each only allows the VM to run for 60-90 minutes. It wastes a lot of time for 1-day class. You have to boot up each lab, then re-download the lab files, re-install any packages for Python, build a new OpenAI environment and then deploy a model... Like 10-15 minutes for each lab.

Is there any discussion about making this just one 8-hour VM environment so we only have to build everything once, and can then just work through the code for each lab?

Unable to create deployment with gpt-35-turbo model

Module: 03

Lab/Demo: 03

Task: Deploy a model, https://github.com/MicrosoftLearning/mslearn-openai/blob/main/Instructions/Labs/03-prompt-engineering.md#deploy-a-model

Step: 02

Description of issue
Instructions read "In Azure OpenAI Studio, create a new deployment with the following settings:
Model: gpt-35-turbo"

I was unable to complete the instructions because I received an error message when I tried to create a deployment for the gpt-35-turbo model. Please see screen image 1.

When I selected the command to request more quota, this message was displayed:
Azure OpenAI Service: Request for Quota Increase
This form is used to submit requests for increased Azure OpenAI TPM (tokens-per-minute) quota.

Quota increases for text-davinci-003, gpt-35-turbo, and gpt-4 are temporarily paused due to substantial demand for these models. However, we are accepting requests and will fill them in the order they are received once our process resumes. Priority will be given to customers who generate traffic that consumes the existing quota allocation, and your request may be denied if this condition is not met.

Please see screen image 2.
link->Azure OpenAI Service: Request for Quota Increase (microsoft.com)

I was able to complete the steps by using the gpt-35-turbo-16k model instead.

Repro steps:

Followed instructions as written.
Screen image 1
Screen image 2

Web App deployment failed.

Module: 01

Lab/Demo: 01

Task: Deploy your model to a web app

Step: 02

Description of issue
Client tried to deploy the web app in all regions but with no success.

image

Lab 6 - where is "Search Resource"?

Lab 6: Use your own data with Azure OpenAI

Section: Connect your data in the chat playground

Step: 5

Description of issue
Step 5 says:
While the storage account resource is being created, return to Azure OpenAI Studio and select Create a new Azure AI Search resource with the following settings.

The issue is where is the button or link to create the AI Search Resource in the OpenAI Studio?

Lab 2 wrong package used for C#

Lab/Demo: 2

Task: Configure your application

Step: 4 : Navigate to the folder for your preferred language and install the necessary packages

Description of issue

dotnet add package Azure.AI.OpenAI --prerelease

The above package is no longer available, suggest to use the same package as described in Lab 3

image

Lab6-YourData: many learners having issues with Search index

Module: 00

Lab/Demo: Use your own data with Azure OpenAI

Task: Connect your data in the chat playground

Step: 10

Description of issue

After saving the data upload/indexing setup, it takes many minutes to finish (even if index is ready , as we can see in Azure Portal).
Many times it even gives a warning of index not found.

WORKAROUND IN CLASS:

  1. Delete data source that is failing
  2. Connect data source to the Search service > index margiestravel-index > same settings as before for rest.

Typo on Run your application, Step 10

Module: 03

Lab/Demo: 03

Task: Run your application, https://github.com/MicrosoftLearning/mslearn-openai/blob/main/Instructions/Labs/03-prompt-engineering.md#run-your-application

Step: 10

Description of issue
Typo

Observe the prompt input, and generated output. This time you'll likely see the email in a similar format, but with a much less informal tone. You'll likely even see jokes included!

Should read:
Observe the prompt input, and generated output. This time you'll likely see the email in a similar format, but with a much more informal tone. You'll likely even see jokes included!

Repro steps:

Lab 1 Assistant Setup --> Setup

Module: 00

Lab/Demo: 00

Task: 00

Step: 00

Description of issue
Not sure if it affects other labs too, Assistant Setup has been renamed to Setup. Some learners confused it with Assistant (playground).
image

Repro steps:

Cannot run python without python-dotenv

Module: 02-03-04-05-06

Lab/Demo: 02-03-04-05-06

Description of issue

All python imports python-dotenv:

from dotenv import load_dotenv

but throw ModuleNotFoundError: No module named 'dotenv' if not install python-dotenv in advance.

Lab 06 - Wrong context in "Configure your application"

Module: 06

Lab: 06 (Implement Retrieval Augmented Generation (RAG) with Azure OpenAI Service)

Task: Configure your app

Step: 00

Description of issue:
The following text provided doesn't match the lab scenario, it's not about summarization and there's no sample text file provided.

"Applications for both C# and Python have been provided, as well as a sample text file you’ll use to test the summarization. Both apps feature the same functionality."

Lab4: code-generation.py not finding sample code

Module: 00

Lab/Demo: 00

Task: 00

Step: 00

Description of issue
In Lab4, the python script could never find the function.py file.

Note I am running this on my local machine.

Repro steps:
Run the script and choose #1, enter in a prompt, and it will return err 2

Resolution
I added in the following code which changed my working folder to the folder containing the lab 4 script:

            # Change the current working directory to the script's directory
            script_directory = os.path.dirname(os.path.abspath(__file__))
            os.chdir(script_directory)

Lab 05 always fails

Lab/Demo: 05

When running the code for Lab05 Image generation with DALL-E.

I always get an 'The given header was not found' when executing this line:

var callback_url = init_response.Headers.GetValues("operation-location").FirstOrDefault();

the init_response gives me a 404 error

the AzureOAIEndpoint is the same as in other labs that are working,

Instructions/Exercises /02-natural-language-azure-openai | Maintain conversation history (python)

Module: 02

Lab/Demo: 02-natural-language-azure-openai

Task: Maintain conversation history

Step: 05

Description of issue
New messages (completions) from the model should be added with "assistant" role and not "system" to the messages array.

Repro steps:
Python code provided for step 5:

# Add code to send request...
# Send request to Azure OpenAI model
messages_array.append({"role": "user", "content": input_text})

response = client.chat.completions.create(
    model=azure_oai_deployment,
    temperature=0.7,
    max_tokens=1200,
    messages=messages_array
)
generated_text = response.choices[0].message.content
# Add generated text to messages array
messages_array.append({"role": "system", "content": generated_text})

# Print generated text
print("Summary: " + generated_text + "\n")

Recommended to change from "system" to "assistant":

# Add generated text to messages array
messages_array.append({"role": "assistant", "content": generated_text})

Changes break code in lab 2

Module: 02

Lab/Demo: 02

Task: 0

Step: Add code to use the Azure OpenAI service

Description of issue
Having changed the appsettings /env entries to aoiDeployment name, the code also needs to be updated as it still references aoiModelname

Repro steps:

Lab2 azure_oai_deployment

Module: 00

Lab/Demo: 00

Task: 00

Step: 00

Description of issue
Based on the changes introduced by PR #34
We need to change instructions line 146 to

model=azure_oai_deployment

Repro steps:

Facing an issue with Lab Exercises instructions- 02-natural-language-azure-openai.md

Hi,
I am trying to follow the instructions in the repo https://github.com/MicrosoftLearning/mslearn-openai/blob/main/Instructions/Exercises/02-natural-language-azure-openai.md and in the section:
Add code to use the Azure OpenAI service -> Step 2 -> while adding a new chat message I am facing an error. Is it because the class chatmessage doesn't exist in the Azure.AI.OpenAI namespace and documentation has to be corrected as below. Could you please help on this?

Messages =
{
// new ChatMessage(ChatRole.System, "You are a helpful assistant."), --> old code
new ChatRequestSystemMessage(""You are a helpful assistant.""),
// new ChatMessage(ChatRole.User, "Summarize the following text in 20 words or less:\n" + text), -->old code
new ChatRequestUserMessage("Summarize the following text in 20 words or less:\n" + text),
},
AzureOpenAI
Error: The type or namespace name 'ChatMessage' could not be found

Thanks,
Nethra

Getting the error "Unsupported data type"

Module: 00

Lab/Demo: 00

Task: 00

Step: 00

Description of issue

Repro steps:

getting error in python executing.
\Labfiles\02-nlp-azure-openai\Python\test-openai-model.py

print("Summary: " + response.choices[0].message.content + "\n")

Error on lab file 05

Module: 00

Lab/Demo: 05

Task: 00

Step: generate-image.py

Description of issue
Upon executing the code, line 26 does not complete successfully.
submission = requests.post(url, headers=headers, json=body)
Printing the error message shows the following error
POST request status code: 404
POST request response: {'error': {'code': 'notFound', 'message': 'Task not found.'}}
As a result, the next command errors and throws an exception:
operation_location = submission.headers['Operation-Location']

Repro steps:

Lab 03 (Prompt Engineering): Code and instructions not aligned.

Module: "Apply prompt engineering with Azure OpenAI Service"

Lab/Demo: 03

Task: "Run your application"

Description of issue

  • Instructions say student is supposed to enter system prompt interactively vs. code reads system prompt from system.txt.
  • Example prompts contain multi-line user prompts with line breaks but Console.ReadLine() will only get the first line and submit this as user prompt.

Missing step/conf

Module: 00

Lab/Demo: Use your own data with Azure OpenAI

Task: 00

Step: 00

Description of issue
When uploading data to Search, we need to provide search type know
image

Repro steps:

The lab instructions improvements

Module: 3

Lab/Demo: 02-nlp-azure-openai

Task: Configure your application

Step: 4-6

Description of issue: The guidelines are not clear; it's not specified in which file the modification should be done, and it's not clear when we're referring to PowerShell or Code Editor. Please review the suggested modifications in the repro steps.

Repro steps:
4. Replace "Navigate to the folder for your preferred language and install the necessary packages" with "Install the necessary packages for your preferred language in Bash in your Cloud Shell."
5. Replace "Navigate to your preferred language folder, select the code file, and add the necessary libraries." with "Navigate to your preferred language folder, and open the file named 'test-openai-model.py' or 'program.cs'. Then, add the necessary libraries by including the following code:"
6. Replace "Open up the application code for your language and add the necessary code for building the request, which specifies the various parameters for your model such as prompt and temperature." by "In the same file as in the previous step, add the missing necessary code for building the request. This code specifies various parameters for your model, such as prompt and temperature."

Lab 06 (RAG): Instructions do not align with UI (anymore)

Module: 00

Lab/Demo: 06

Task: "Connect your data in the chat playground"

  • Instructions say "While the storage account resource is being created, return to Azure OpenAI Studio and select Create a new Azure AI Search resource". I did not find where I can create the AI Search resource in the OpenAI Studio. I ended up creating it via the portal.
  • I did not find a upload section to do "On the Upload files page, upload the PDFs you downloaded, and then select Next." I uploaded the files into the Storage Account via the portal.
  • However, this required me to re-create the index. (It seems it would make sense to ask student to upload files to Storage Account before adding the data source?)

ai-102 module 6

Step 5
Add code to use the Azure OpenAI service
I try to update the code like you can see
but i have error

image

// Implicit using statements are included
using System.Text;
using System.Text.Json;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Azure;

// Add Azure OpenAI package
using Azure.AI.OpenAI;

// Build a config object and retrieve user settings.
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
string? oaiEndpoint = config["AzureOAIEndpoint"];
string? oaiKey = config["AzureOAIKey"];
string? oaiDeploymentName = config["AzureOAIDeploymentName"];

if(string.IsNullOrEmpty(oaiEndpoint) || string.IsNullOrEmpty(oaiKey) || string.IsNullOrEmpty(oaiDeploymentName) )
{
Console.WriteLine("Please check your appsettings.json file for missing or incorrect values.");
return;
}

// Initialize the Azure OpenAI client...
// Initialize the Azure OpenAI client
OpenAIClient client = new OpenAIClient(new Uri(oaiEndpoint), new AzureKeyCredential(oaiKey));

// System message to provide context to the model
string systemMessage = "I am a hiking enthusiast named Forest who helps people discover hikes in their area. If no area is specified, I will default to near Rainier National Park. I will then provide three suggestions for nearby hikes that vary in length. I will also share an interesting fact about the local nature on the hikes when making a recommendation.";

do {
Console.WriteLine("Enter your prompt text (or type 'quit' to exit): ");
string? inputText = Console.ReadLine();
if (inputText == "quit") break;

// Generate summary from Azure OpenAI
if (inputText == null) {
    Console.WriteLine("Please enter a prompt.");
    continue;
}

Console.WriteLine("\nSending request for summary to Azure OpenAI endpoint...\n\n");

// Add code to send request...
// Build completion options object
ChatCompletionsOptions chatCompletionsOptions = new ChatCompletionsOptions()
{
Messages =
{
new ChatRequestSystemMessage(systemMessage),
new ChatRequestUserMessage(inputText),

},
MaxTokens = 400,
Temperature = 0.7f,
DeploymentName = oaiDeploymentName
};

// Send request to Azure OpenAI model
ChatCompletions response = client.GetChatCompletions(chatCompletionsOptions);

// Print the response
string completion = response.Choices[0].Message.Content;
Console.WriteLine("Response: " + completion + "\n");

} while (true);

Copy/Paste error in Code-Generation lab

In 04-code-generation.md, it looks like the intro paragraph to the Generate code in chat playground section was copied from a previous lab (unless the code creates animals with really fun names!)

Here's what's there:

Generate code in chat playground

Before using your app, examine how prompt engineering improves the model response in the playground. In this first example, imagine you are trying to write a python app of animals with fun names.

Is missing the new exercise from learning path 6.

Module: 6

Lab/Demo: 1

Description of issue

With the March 2024 update, the learning path 6 exercise was changed to 'Exercise: Implement Retrieval Augmented Generation (RAG) with Azure OpenAI Service', previously it was 'Exercise: Use your own data with Azure OpenAI Service'. The repository doesn't have the instructions for the update exercise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.