betalgo / openai

OpenAI .NET sdk - Azure OpenAI, ChatGPT, Whisper, and DALL-E
https://betalgo.github.io/openai/
MIT License
2.84k stars 513 forks source link

Moderation doesn't work #496

Closed remixtedi closed 3 months ago

remixtedi commented 4 months ago

Describe the bug I'm trying to check the prompt for inappropriate language before it goes to the ChatCompletions endpoint but it returns "404 Resource not found" Error.

I'm using OpenAI services on Azure and URL looks like this: https://MYOPENAISERVICE.openai.azure.com/openai/deployments/Gpt4-model-0125-Deployment/moderations?api-version=2023-12-01-preview

Your code piece

 var moderationResponse = await AzureOpenAIService.CreateModeration(createModerationRequest);
        if (!moderationResponse.Successful)
            throw new ValidationException(moderationResponse.Error.Message ??
                                          "Input text is not appropriate for the audience because it might contain hate, sexual, violence, and self-harm content, please try again with different input.");
kayhantolga commented 3 months ago

I believe the problem lies in your configuration, so I'm converting this to a discussion rather than an issue.

Could you share the initialization part of your code? (Please ensure you do not share any sensitive information like keys, etc.)