-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Freshness pass --------- Co-authored-by: Genevieve Warren <[email protected]>
- Loading branch information
1 parent
80b63fe
commit df11762
Showing
11 changed files
with
37 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/ai/get-started-app-chat-scaling-with-azure-container-apps.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
// <chatCompletionFlow> | ||
using Azure; | ||
using Azure.AI.OpenAI; | ||
using Azure.AI.OpenAI; | ||
using Azure.Identity; | ||
using Microsoft.Extensions.AI; | ||
|
||
string endpoint = "YOUR_OPENAI_ENDPOINT"; | ||
string key = "YOUR_OPENAI_KEY"; | ||
IChatClient client = | ||
new AzureOpenAIClient( | ||
new Uri("YOUR_MODEL_ENDPOINT"), | ||
new DefaultAzureCredential()).AsChatClient("YOUR_MODEL_DEPLOYMENT_NAME"); | ||
|
||
OpenAIClient client = new(new Uri(endpoint), new AzureKeyCredential(key)); | ||
|
||
var chatCompletionsOptions = new ChatCompletionsOptions() | ||
try | ||
{ | ||
DeploymentName = "YOUR_DEPLOYMENT_NAME", | ||
Messages = | ||
{ | ||
new ChatRequestSystemMessage("You are a helpful assistant."), | ||
new ChatRequestUserMessage("YOUR_PROMPT") | ||
} | ||
}; | ||
|
||
Response<ChatCompletions> response = client.GetChatCompletions(chatCompletionsOptions); | ||
Console.WriteLine(response.Value.Choices[0].Message.Content); | ||
Console.WriteLine(); | ||
// </chatCompletionFlow> | ||
ChatCompletion completion = await client.CompleteAsync("YOUR_PROMPT"); | ||
|
||
// <printContentFilteringResult> | ||
foreach (var promptFilterResult in response.Value.PromptFilterResults) | ||
Console.WriteLine(completion.Message); | ||
} | ||
catch (Exception e) | ||
{ | ||
var results = promptFilterResult.ContentFilterResults; | ||
Console.WriteLine(@$"Hate category is filtered: | ||
{results.Hate.Filtered} with {results.Hate.Severity} severity."); | ||
Console.WriteLine(@$"Self-harm category is filtered: | ||
{results.SelfHarm.Filtered} with {results.SelfHarm.Severity} severity."); | ||
Console.WriteLine(@$"Sexual category is filtered: | ||
{results.Sexual.Filtered} with {results.Sexual.Severity} severity."); | ||
Console.WriteLine(@$"Violence category is filtered: | ||
{results.Violence.Filtered} with {results.Violence.Severity} severity."); | ||
Console.WriteLine(e.Message); | ||
} | ||
// </printContentFilteringResult> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters