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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 feat(google): Add safety settings configuration #2591

Conversation

lidonius1122
Copy link
Contributor

@lidonius1122 lidonius1122 commented May 1, 2024

Pull Request: Add Safety Settings Configuration for Google Gemini API

Summary

This pull request addresses the feature request raised in issue #2564. It adds the ability to configure safety settings for the Google Gemini API in LibreChat. Users can now customize the thresholds for various safety categories, providing more control over the content filtering behavior of the Gemini API.

The changes include:

  • Implement safety settings configuration in GoogleClient.js
  • Add safety settings variables in .env.example
  • Update documentation to explain safety settings and clarify model usage

These changes give developers the flexibility to tailor the Gemini API's safety settings to their specific requirements, ensuring that the API's functionality is not unnecessarily limited by the default settings.

Change Type

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Testing

To test these changes:

  1. Set the desired safety settings in the .env file based on the variables defined in .env.example.
  2. Run the LibreChat application and verify that the Gemini API is using the configured safety settings.
  3. Test various scenarios to ensure the safety settings are working as expected.

Test Configuration:

  • LibreChat version: latest
  • Google Vertex AI APi

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.
  • New documents have been locally validated with mkdocs

Closes #2564

@lidonius1122 lidonius1122 reopened this May 1, 2024
lidonius1122 and others added 3 commits May 8, 2024 21:24
- Implement safety settings configuration in GoogleClient.js
- Add safety settings variables in .env.example
- Update documentation to explain safety settings and clarify model usage
Previously, the safety settings were being applied to all models, regardless of whether they were Gemini models or not. This commit ensures that the safety settings are only applied to models that contain the "gemini" string in their name.

The changes include:

- Extracting the model name from `payload.parameters.model`
- Checking if the model name exists and contains the "gemini" string
- Only applying the safety settings if the model name contains "gemini"
- Ignoring the safety settings for non-Gemini models

This fix ensures that the safety settings are only used for the intended Gemini models, and not applied to other models where they may not be applicable.
@danny-avila
Copy link
Owner

Thanks @lidonius1122!

I made some minor changes and opened a new PR to get them in

@danny-avila danny-avila closed this May 9, 2024
@lidonius1122
Copy link
Contributor Author

Thank you. That was my first time :D

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.

Enhancement: Add SafetySettings Configuration for Google Gemini in LibreChat
2 participants