Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a spelling error in the deserialization of the message returned when the completions API triggers the content filter. #23936

Closed
wants to merge 2 commits into from

Conversation

bilinxing
Copy link

Fixed a spelling error in the deserialization of the message returned when the completions API triggers the content filter. "innererror" 、 "content_filter_results" has been corrected to "inner_error" 、"content_filter_result",

Microsoft's documentation also has a spelling error for "innererror"、"content_filter_result". When I actually called the API, it returned "inner_error" 、 "content_filter_result". I don't know where the problem is, but to ensure my program can run correctly, please merge this pull request. Thank you.
Here are the actual return data when calling the API:

{
    "error": {
        "inner_error": {
            "code": "ResponsibleAIPolicyViolation",
            "content_filter_results": {
                "sexual": {
                    "filtered": true,
                    "severity": "medium"
                },
                "violence": {
                    "filtered": false,
                    "severity": "safe"
                },
                "hate": {
                    "filtered": false,
                    "severity": "safe"
                },
                "self_harm": {
                    "filtered": false,
                    "severity": "safe"
                }
            }
        },
        "code": "content_filter",
        "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: \r\nhttps://go.microsoft.com/fwlink/?linkid=2198766.",
        "param": "prompt",
        "type": null
    }
}

@microsoft-github-policy-service agree

chenxingya added 2 commits January 11, 2025 15:55
…ge returned when the completions API triggers the content filter. "innererror" has been corrected to "inner_error".
…ge returned when the completions API triggers the content filter. "content_filter_results" has been corrected to "content_filter_result".
@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jan 11, 2025
Copy link

Thank you for your contribution @bilinxing! We will review the pull request and get back to you soon.

@richardpark-msft
Copy link
Member

@bilinxing, I've just run this same test and the JSON is formatted as we have it in our current code (not your patch). I'm wondering if this is a possible difference in models, or possibly API version.

Can you tell me:

  • What model you're using?
  • What package version you're using?

@bilinxing
Copy link
Author

bilinxing commented Jan 15, 2025

@bilinxing, I've just run this same test and the JSON is formatted as we have it in our current code (not your patch). I'm wondering if this is a possible difference in models, or possibly API version.

Can you tell me:

  • What model you're using?
  • What package version you're using?

model : gpt-4o(2024-11-20)
package :
github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai v0.7.1
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0

Even if we use curl to request the original API, we will still get a response that is inconsistent with the document definition:
https://{my-endpoint}.openai.azure.com/openai/deployments/{my-deploy}/chat/completions?api-version=2024-02-15-preview

{
    "error": {
        "inner_error": {
            "code": "ResponsibleAIPolicyViolation",
            "content_filter_results": {
                "sexual": {
                    "filtered": true,
                    "severity": "medium"
                },
                "violence": {
                    "filtered": false,
                    "severity": "safe"
                },
                "hate": {
                    "filtered": false,
                    "severity": "safe"
                },
                "self_harm": {
                    "filtered": false,
                    "severity": "safe"
                }
            }
        },
        "code": "content_filter",
        "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: \r\nhttps://go.microsoft.com/fwlink/?linkid=2198766.",
        "param": "prompt",
        "type": null
    }
}

@richardpark-msft
Copy link
Member

@bilinxing, I've tried several ways to trigger this, but I can't. I've matched your exact model, using the latest API version, and I don't see any differences. The results always look like this:

"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"
                }
            }
        }
    }

Looking at your result, I note you're missing some fields that should be present, like "status".

It's possible there's something specific to your instance, or deployment, that causes it to return different results, in which case you'll need to file a support ticket so someone can look at the your OpenAI instance, and help you troubleshoot. Instructions for that are here: link

I also wonder if you, possibly, have a proxy or some intervening software that is changing the results in-transit.

Closing this PR, as I can't reproduce the issue, and we wouldn't want to take the fix, as-is, until we know the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants