Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwolfmsft committed Jul 16, 2024
1 parent aeaf5bd commit d2d5ff1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/azure/sdk/protocol-convenience-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ The preceding code demonstrates the following `System.ClientModel` protocol meth

> [!NOTE]
> The preceding code configures the `ClientErrorBehaviors.NoThrow` for the `RequestOptions`. This option prevents non-success service responses status codes from throwing an exception, which means the app code should manually handle the response status code checks.
---

## Protocol and convenience method usage guidance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@
prompt,
new RequestContext() { ErrorOptions = ErrorOptions.NoThrow});

// Any response code other than 200 from Azure ContentSafety AnalyzeText REST API is not considered a success response
// See REST API details at https://azure-ai-content-safety-api-docs.developer.azure-api.net/api-details#api=content-safety-service-2023-10-01&operation=TextOperations_AnalyzeText
if (response.Status != 200)
{
throw new RequestFailedException(response);
}

// Display the results
Console.WriteLine(response.Content);
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
ChatClient chatClient = client.GetChatClient("gpt-4");

// Call the convenience method
ClientResult<ChatCompletion> completion
ChatCompletion completion
= chatClient.CompleteChat("What is Azure?");

// Display the results
Console.WriteLine($"{completion.Value.Role}: {completion.Value.Content}");
Console.WriteLine($"{completion.Role}: {completion.Content}");

0 comments on commit d2d5ff1

Please sign in to comment.