We are excited to announce the General Availability (GA) release of Filters for our .NET and Python Semantic Kernel! This vital enhancement strengthens the control and visibility developers have when running functions, ensuring responsible AI practices are instilled from the ground up. Filters not only improve security but also contribute to building enterprise-ready solutions that you can feel confident deploying.
What Are Filters?
Filters in Semantic Kernel provide a mechanism for developers to manage how and when functions operate within their applications. For example, validation filters can be employed to remove PII before sending data to a model. These filters enrich the development ecosystem by providing layers of protection and refinement.
Types of Filters
- Function Invocation Filter: This filter is executed each time a
KernelFunction
is invoked. It allows:- Access to information about the executing function and its arguments.
- Handling of exceptions during function execution.
- Overriding of the function result.
- Retrying of the function in case of failure, such as switching to an alternative AI model.
- Prompt Render Filter: Triggered before the prompt rendering operation, enabling:
- Viewing and modifying the prompt sent to the AI (e.g., for retrieval-augmented generation or PII redaction).
- Preventing prompt submission to the AI by overriding the function result (e.g., for semantic caching).
- Auto Function Invocation Filter: This filter operates within the automatic function calling scope, providing additional context, such as chat history and iteration counters. It allows for the termination of the process if a desired result is obtained before all planned functions are executed.
Each filter type includes a context object containing relevant information about function execution or prompt rendering. Furthermore, they have a next
delegate/callback, facilitating control over function execution—even in scenarios involving potentially malicious prompts or arguments.
Learn More
- Go to the Filter page on the Semantic kernel learn site to go deeper.
- Learn how to use Filters to stop prompt injection attacks
- Check out the samples
The introduction of Filters in Semantic Kernel marks a significant step towards ensuring the secure and responsible deployment of AI solutions. By incorporating these filters, developers can enhance control over the execution flow of their functions and ensure that their applications uphold best practices in AI safety.
We encourage you to explore the capabilities of Filters in your own projects and look forward to seeing how you implement these enhancements. Together, let’s continue to develop secure, intelligent, and user-centric AI applications!
0 comments
Be the first to start the discussion.