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: Add convenience function for LlamaGuard Filter #555

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

Conversation

KavithaSiva
Copy link
Contributor

@KavithaSiva KavithaSiva commented Feb 17, 2025

Context

Closes SAP/ai-sdk-js-backlog#205.

What this PR does and why it is needed

This PR adds a convenience function to enable filter categories for Llama guard filter.

Screenshot 2025-02-20 at 14 41 31

The built filter can then be used in the filtering configuration of the Orchestration client.

Copy link
Contributor

@deekshas8 deekshas8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion:

Since the default for is false for all properties of the filter, the user only needs to set categories which they want to enable. As such, setting to true seems like a redundant effort. We could allow the user to just pass an array of strings (from union type of all existing properties) and we set them to true.
The pro here would be less typing and less confusion (setting false makes no sense, but this might not very obvious).
The con is it deviates from azure filter a bit where we have a key: value style of input.

@KavithaSiva
Copy link
Contributor Author

KavithaSiva commented Feb 18, 2025

A suggestion:

Since the default for is false for all properties of the filter, the user only needs to set categories which they want to enable. As such, setting to true seems like a redundant effort. We could allow the user to just pass an array of strings (from union type of all existing properties) and we set them to true. The pro here would be less typing and less confusion (setting false makes no sense, but this might not very obvious). The con is it deviates from azure filter a bit where we have a key: value style of input.

I would personally prefer if the user explicitly sets the properties to true as even if it is verbose, it is clear that we are turning some categories on.

buildLlamaGuardFilter({ hate: true, sexual_content: true})  //Very clear
buildLlamaGuardFilter([hate', 'sexual_content']) //Not clear, if we are enabling or disabling the category 

@deekshas8
Copy link
Contributor

buildLlamaGuardFilter([hate', 'sexual_content']) //Not clear, if we are enabling or disabling the category

From my understanding of the filter, you basically can enable a category, the default is false for all the rest categories. What I personally find more confusing is allowing to disable something thats going to be disabled anyway.

@KavithaSiva KavithaSiva marked this pull request as ready for review February 21, 2025 07:48
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