openai / openai-dotnet

The official .NET library for the OpenAI API
https://www.nuget.org/packages/OpenAI
MIT License
707 stars 60 forks source link

detailed Content filter info #55

Closed wolfgangschneider closed 2 weeks ago

wolfgangschneider commented 2 weeks ago

When completion is cancelnd in case of contentfilter Version one throes an Azure.RequestFailedException with detailed information as Json stored in Content:

_Azure.RequestFailedException: The response was filtered due to the prompt triggering Azure OpenAI's content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766
Status: 400 (model_error)
ErrorCode: content_filter

Content:
{"error":{"message":"The response was filtered due to the prompt triggering Azure OpenAI's content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766","type":null,"param":"prompt","code":"content_filter","status":400,"innererror":

{"code":"ResponsibleAIPolicyViolation","content_filter_result":{"hate":{"filtered":false,"severity":"safe"},"self_harm":

{"filtered":false,"severity":"safe"},"sexual":{"filtered":true,"severity":"high"},"violence":{"filtered":false,"severity":"safe"}}}}}_

Version 2 throws System.ClientModel.ClientResultException without this information

_System.ClientModel.ClientResultException: HTTP 400 (content_filter)
Parameter: prompt

The response was filtered due to the prompt triggering Azure OpenAI's content management policy. 
Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766_

Is it possible to get the Content filter reason in one or an other way?

joseharriaga commented 2 weeks ago

Hello, @wolfgangschneider. Thank you for reaching out! This repo is for the official OpenAI library for .NET. If you're working with Azure OpenAI and using the Azure.AI.OpenAI library, please open an issue in the azure-sdk-for-net repo instead.

wolfgangschneider commented 2 weeks ago

I will do so