microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.88k stars 3.26k forks source link

.Net: Bug: C# Content filtering annotations missing #9593

Open rsaundersbdo opened 1 day ago

rsaundersbdo commented 1 day ago

Describe the bug When receiving a 400 content filter exception from sending a message to an Azure OpenAI model the inner exception that is supposed to include the reasoning for the exception is null.

To Reproduce Steps to reproduce the behavior: 1.Setup an Azure OpenAI model with content filter set to block on message inputs.

  1. Send a streaming message request that would trigger the content filtering to the model.
  2. Inspect the expectation and see that the inner exception is null.

Expected behavior The inner exception is expected to be populated with the information on why the message was blocked.

Screenshots Image

Platform

evchaki commented 11 hours ago

@SergeyMenshykh - can you take a look at this - from Office Hours this week. @rsaundersbdo - thanks for putting this in, we will take a look.

RogerBarreto commented 10 hours ago

Just to add a bit more context

when we get a 400 back we also get this Response Body, for some reason this is not returned, wondering what might be occluding the information or this is lost in the Azure SDK...

{
    "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"
                },
                "jailbreak": {
                    "filtered": false,
                    "detected": false
                },
                "self_harm": {
                    "filtered": false,
                    "severity": "safe"
                },
                "sexual": {
                    "filtered": false,
                    "severity": "safe"
                },
                "violence": {
                    "filtered": true,
                    "severity": "medium"
                }
            }
        }
    }
}