Skip to content

Intermittent Connection Aborted Error on Moderation Endpoint #368

Closed as not planned
@jackadair

Description

@jackadair

Describe the bug

I'll leave this specific to my use case but as others have reported on the forums there is a intermittent error:

Error communicating with OpenAI: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

In our case we are encountering this on the Moderation endpoint. Only started happening within the last week or so.

To Reproduce

  1. Make Request to Moderation endpoint using openai.Moderation.create()
  2. It may work it may not, our users have found that this most often happens at the beginning of a conversation thread, the fact that it is so intermittent is what is making me believe this is a server error on OpenAI's part.

Code snippets

try:
        input = body["messages"][-1]["content"]
        moderation = openai.Moderation.create(input=input, model='text-moderation-latest')
        moderation_flagged = moderation["results"][0]["flagged"]
    except Exception as e:
        print(e) #error is received here
        return EventSourceResponse(error_generate(message="Error: Unable to moderate prompt", status_code=500))

OS

macOS/Windows

Python version

Python v3.9.16

Library version

0.27.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions