-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Python: New Feature: Content Safety Layer for Python #9536
Comments
Thanks for filing the feature request, @nmoeller. Could this be accomplished with our prompt filter? Not everyone may want the added latency of every request going through a content safety pipeline (I don't have data to back this up, but just a thought). We will discuss as a team, again thanks! |
@moonbox3 just to clarify this is something that not everybody has to use, the simply idea would be to have something like I think something like this is available in the dotnet already. But i will also check if this can be archived via prompt filters ! |
Understood. I see that in .Net they are using the IPromptRenderFilter interface to create the dependency for something like TextModerationFilter. I see in their getting started docs, one can download the appropriate client. This could be included in a function that implements our prompt filter and then makes the call to the content safety service. |
@moonbox3 is it fine if i would start working on this ? My Idea would be to create the connector in a new folder I would implement a Class for the AzureAIContentSafety. Maybe also an Abstract Class since AWS also have something like this available. And to demonstrate how it works i would add a Sample in Concepts using the ContentFilterConnector as a Filter. |
@nmoeller do you know if something like this is already present in SK .Net? If not, we'd want to make sure we align the design for both languages before jumping into the implementation. |
Sorry, I didn't even read my response to you above. :( It's been a while since I looked at this issue. Yeah, I think it's good to go then. |
Name : Content Safety Layer for Python
Abstract:
The idea is to have some kind of Interceptor when invoking API's that checks for Content Safety, to ensure a stable Content Safety when switching the underlaying Model. Also with Embedded Content Safety Containers, flows
Why is this a good Idea ?
When People switching from GPT4 to Anthropic for Example, they would loose the Content Safety Feature of the Azure AI Services. To ensure Responsible AI when switch between Models, we should have a layer in the Kernel to keep Content Safety when switching Model consistent.
Also when using Hugging Face Models or Onnx Models locally there is no support for content safety except in the model itself. To enable all kind of Models to work with Content Safety a seperate layer in the Kernel would be beneficial.
As far as i saw, this feature is already available in the C# Version of semantic kernel.
How can this be implemented ?
The idea here would be to add a new abstract class named
ContentSafetyConnectorBase
, this class would have abstract methods to enforce subclasses to implement them. Before and After sending data to the Models we could intercept the questions/answers in theChatCompletionClientBase
. We could also add anContentSafetyException
in the Semantic Kernel Exceptions and the user could catch theContentSafetyException
and deal with it accordingly.We could also add the
AzureContentSafety
Service as a Connector for samples. Also there is a offline container of Content Safety, so we could have a complete offline example with SLM's and Content Safety.The text was updated successfully, but these errors were encountered: