Skip to content

Commit

Permalink
Updated .NET SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeMalcolm committed Nov 7, 2023
1 parent 487ae69 commit 52952b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
19 changes: 9 additions & 10 deletions Instructions/Exercises/02-natural-language-azure-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,18 @@ Now you're ready to use the Azure OpenAI SDK to consume your deployed model.
// Build completion options object
ChatCompletionsOptions chatCompletionsOptions = new ChatCompletionsOptions()
{
Messages =
{
new ChatMessage(ChatRole.System, "You are a helpful assistant."),
new ChatMessage(ChatRole.User, "Summarize the following text in 20 words or less:\n" + text),
},
MaxTokens = 120,
Temperature = 0.7f,
Messages =
{
new ChatMessage(ChatRole.System, "You are a helpful assistant."),
new ChatMessage(ChatRole.User, "Summarize the following text in 20 words or less:\n" + text),
},
MaxTokens = 120,
Temperature = 0.7f,
DeploymentName = oaiModelName
};
// Send request to Azure OpenAI model
ChatCompletions response = client.GetChatCompletions(
deploymentOrModelName: oaiModelName,
chatCompletionsOptions);
ChatCompletions response = client.GetChatCompletions(chatCompletionsOptions);
string completion = response.Choices[0].Message.Content;
Console.WriteLine("Summary: " + completion + "\n");
Expand Down
6 changes: 2 additions & 4 deletions Instructions/Exercises/03-prompt-engineering.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,11 @@ Now you're ready to use the Azure OpenAI SDK to consume your deployed model.
},
Temperature = 0.7f,
MaxTokens = 800,
DeploymentName = oaiModelName
};
// Get response from Azure OpenAI
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(
oaiModelName,
chatCompletionsOptions
);
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(chatCompletionsOptions);
ChatCompletions completions = response.Value;
string completion = completions.Choices[0].Message.Content;
Expand Down
6 changes: 2 additions & 4 deletions Instructions/Exercises/04-code-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,11 @@ Now you're ready to use the Azure OpenAI SDK to consume your deployed model.
},
Temperature = 0.7f,
MaxTokens = 1000,
DeploymentName = oaiModelName
};
// Get response from Azure OpenAI
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(
oaiModelName,
chatCompletionsOptions
);
Response<ChatCompletions> response = await client.GetChatCompletionsAsync(chatCompletionsOptions);
ChatCompletions completions = response.Value;
string completion = completions.Choices[0].Message.Content;
Expand Down
5 changes: 2 additions & 3 deletions Labfiles/06-use-own-data/CSharp/OwnData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
MaxTokens = 600,
Temperature = 0.9f,
DeploymentName = oaiModelName
AzureExtensionsOptions = new AzureChatExtensionsOptions()
{
Extensions =
Expand All @@ -51,9 +52,7 @@
};

// Send request to Azure OpenAI model (Add code here)
ChatCompletions response = client.GetChatCompletions(
deploymentOrModelName: oaiModelName,
chatCompletionsOptions);
ChatCompletions response = client.GetChatCompletions(chatCompletionsOptions);

ChatMessage responseMessage = response.Choices[0].Message;

Expand Down

0 comments on commit 52952b7

Please sign in to comment.