Skip to content

Add support for VertexAI safety settings#624

Merged
Ying1123 merged 1 commit intosgl-project:mainfrom
AidanCooper:vertex-safety-settings
Jul 16, 2024
Merged

Add support for VertexAI safety settings#624
Ying1123 merged 1 commit intosgl-project:mainfrom
AidanCooper:vertex-safety-settings

Conversation

@AidanCooper
Copy link
Copy Markdown
Contributor

@AidanCooper AidanCooper commented Jul 15, 2024

Enables user to configure VertexAI safety settings. Example usage:

import sglang as sgl
from vertexai.preview.generative_models import HarmBlockThreshold, HarmCategory

client = sgl.VertexAI(
    "gemini-pro",
    safety_settings={
        HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
    },
)

Exposing these safety configurations is valuable as Gemini's default safety settings can be easily triggered (e.g., if you work with data in the medical domain).

Enables user to configure VertexAI safety settings. Example usage:
```python
import sglang as sgl
from vertexai.preview.generative_models import HarmBlockThreshold, HarmCategory

client = sgl.VertexAI(
    "gemini-pro",
    safety_settings={
        HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
        HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
    },
)
```
@merrymercy merrymercy force-pushed the main branch 2 times, most recently from 7eda0c8 to 41d1f67 Compare July 16, 2024 03:44
@Ying1123 Ying1123 merged commit c193002 into sgl-project:main Jul 16, 2024
@AidanCooper AidanCooper deleted the vertex-safety-settings branch July 16, 2024 18:57
@hnyls2002 hnyls2002 mentioned this pull request Jul 16, 2024
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
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.

2 participants