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

🚔 feat: OpenAI Moderation update #4827

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

berry-13
Copy link
Collaborator

@berry-13 berry-13 commented Dec 1, 2024

Summary

This pull request introduces significant improvements to the moderation functionality and configuration management within the codebase. The key changes include adding a new violation type, enhancing the moderation middleware, and refactoring the configuration loading process for better caching and error handling

Moderation Enhancements:

  • api/server/middleware/moderateText.js: Replaced axios with OpenAI for moderation requests, added new functions for formatting violations, and implemented a more robust moderation flow with configurable actions and thresholds

Configuration Management:

Middleware Adjustments:

  • api/server/routes/ask/gptPlugins.js, api/server/routes/ask/openAI.js, api/server/routes/edit/gptPlugins.js, api/server/routes/edit/openAI.js: Moved the moderateText middleware to ensure it is applied correctly across routes. [1] [2] [3] [4]

Cache Updates:

Change Type

  • Refactor
  • New feature (non-breaking change which adds functionality)

Testing

Tested with the OpenAI's endpoint by sending explicit messages containing self-harm/intent, self-harm, hate, harassment and sexual words

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • Any changes dependent on mine have been merged and published in downstream modules.
  • A pull request for updating the documentation has been submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant