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: expose HarmBlockMethod to external callers #4668

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

Conversation

telpirion
Copy link
Contributor

@telpirion telpirion commented Nov 18, 2024

This enum is required for the SafetySettings() class to allow users to toggle harmful content blocking.

Without exposing this type, the following code won't work (as of version 1.72.0).

generative_models.SafetySetting(
        category=generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
        method=generative_models.HarmBlockMethod.SEVERITY,
        threshold=generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    ),

Found here.

This enum is required for the SafetySettings() class to allow users to toggle harmful content blocking
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: vertex-ai Issues related to the googleapis/python-aiplatform API. labels Nov 18, 2024
@Ark-kun
Copy link
Contributor

Ark-kun commented Nov 19, 2024

It should be exposed via SafetySettings.HarmBlockMethod. Is it not?

@telpirion
Copy link
Contributor Author

telpirion commented Nov 21, 2024

It should be exposed via SafetySettings.HarmBlockMethod. Is it not?

Ah, now I see it. It is accessed through SafetySetting (no 's').

Question: why is HarmBlockThreshold and HarmCategory exposed directly in the generative_models module but not HarmBlockThreshold?

@Ark-kun
Copy link
Contributor

Ark-kun commented Dec 5, 2024

Question: why is HarmBlockThreshold and HarmCategory exposed directly in the generative_models module but not HarmBlockThreshold?

Historical reasons. Initially we tried to use safety_settings: dict[HarmCategory, HarmBlockThreshold] instead of safety_settings: list[SafetySetting]. So SafetySetting was not exposed and HarmBlockThreshold and HarmCategory we exposed directly. Then HarmBlockMethod was added and we had to expose SafetySetting and switch to safety_settings: list[SafetySetting]. Now there are 4 classes related to safety. To avoid the generative_models module crowding we decided not to expose HarmBlockMethod and any subsequent classes, choosing to group them under SafetySetting.

Maybe we're wrong and we should just expose HarmBlockMethod the same way...

@telpirion
Copy link
Contributor Author

Okay, makes sense. If you decide not to expose HarmBlockMethod in this module, feel free to delete this PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants