openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Error when trigger Azure OpenAI’s content management policy

Open axiangcoding opened this issue 1 year ago • 1 comments

Describe the bug

Azure OpenAI API will return in some cases

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

it will failed when using like this:

response = openai.Completion.create(
    engine="text-davinci-003",
    prompt="something here",
    temperature=0.3,
    max_tokens=250,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0,
    best_of=1,
    stop=None)

To Reproduce

  1. run the code snippets

Code snippets

response = openai.Completion.create(
    engine="text-davinci-003",
    prompt="SUBREDDIT: r/AskReddit TITLE: Cock blocked by a friend (Who's a girl). POST: So for the past week there's "
         "been this girl in one of my classes I've been talking to, she's pretty cute (dyed red hair, fair skin, "
         "a few freckles, not ginger), she loves star wars and I suspect she's a redditor. I was going to ask her for "
         "her number today, but a girl i met about a year ago came and sat right where the red head had been sitting, "
         "effectively cock-blocking me and driving the girl I was interested in away. Now it seems like the red head "
         "thinks I'm uninterested in her and has since found some other guy to talk to. Has anybody been in a similar "
         "scenario? Advice? \nTL;DR: Got cock blocked by a friend who's a girl.",
    temperature=0.3,
    max_tokens=250,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0,
    best_of=1,
    stop=None)

OS

Windows

Python version

Python v3.11

Library version

openai v0.27.2

axiangcoding avatar Mar 22 '23 08:03 axiangcoding