November 21st, 2024

Announcing the GA Release of Filters for .NET and Python in Semantic Kernel

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

  1. 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.
  2. 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).
  3. 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

 

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!

Author

0 comments