Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Purview/IScopedContentProcessor.cs
T
b19860b8a8 .NET: Implement Purview middleware in dotnet (#1949)
* Move Purview integration logic into middleware

* Improve error handling and user id management

* Rename purview package

* Handle 402s more explicitly; add Middleware generation methods; don't ignore exceptions

* Use DI container; pass scope id to PC

* Add protection scope caching

* Wrap more exceptions in PurviewClient

* Remove block check dedup; add tests

* Refactor PurviewWrapper intialization; Add unit tests

* Use different .Use method and add IDisposable stub

* Add background job processing for Purview

* Misc comment cleanup

* Apply copilot comments

* Fix formatting

* Formatting other files to fix pipeline

* Small updates to settings and exceptions

* Add README

* Move Purview sample

* Address review comments and update XML comments

* Newline after namespace

* Move public Purview classes to single namespace; Clean up csproj and slnx

* Commit the renames

* Remove unused openAI dependency

---------

Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
2025-11-14 00:50:08 +00:00

29 lines
1.5 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.AI.Purview.Models.Common;
using Microsoft.Extensions.AI;
namespace Microsoft.Agents.AI.Purview;
/// <summary>
/// Orchestrates the processing of scoped content by combining protection scope, process content, and content activities operations.
/// </summary>
internal interface IScopedContentProcessor
{
/// <summary>
/// Process a list of messages.
/// The list of messages should be a prompt or response.
/// </summary>
/// <param name="messages">A list of <see cref="ChatMessage"/> objects sent to the agent or received from the agent..</param>
/// <param name="threadId">The thread where the messages were sent.</param>
/// <param name="activity">An activity to indicate prompt or response.</param>
/// <param name="purviewSettings">Purview settings containing tenant id, app name, etc.</param>
/// <param name="userId">The user who sent the prompt or is receiving the response.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A bool indicating if the request should be blocked and the user id of the user who made the request.</returns>
Task<(bool shouldBlock, string? userId)> ProcessMessagesAsync(IEnumerable<ChatMessage> messages, string? threadId, Activity activity, PurviewSettings purviewSettings, string? userId, CancellationToken cancellationToken);
}