Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Purview/PurviewSettings.cs
T
eoindoherty1 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

89 lines
3.2 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
namespace Microsoft.Agents.AI.Purview;
/// <summary>
/// Represents the configuration settings for a Purview application, including tenant information, application name, and
/// optional default user settings.
/// </summary>
/// <remarks>This class is used to encapsulate the necessary configuration details for interacting with Purview
/// services. It includes the tenant ID and application name, which are required, and an optional default user ID that
/// can be used for requests where a specific user ID is not provided.</remarks>
public class PurviewSettings
{
/// <summary>
/// Initializes a new instance of the <see cref="PurviewSettings"/> class.
/// </summary>
/// <param name="appName">The publicly visible name of the application.</param>
public PurviewSettings(string appName)
{
this.AppName = appName;
}
/// <summary>
/// The publicly visible app name of the application.
/// </summary>
public string AppName { get; set; }
/// <summary>
/// The version string of the application.
/// </summary>
public string? AppVersion { get; set; }
/// <summary>
/// The tenant id of the user making the request.
/// If this is not provided, the tenant id will be inferred from the token.
/// </summary>
public string? TenantId { get; set; }
/// <summary>
/// Gets or sets the location of the Purview resource.
/// If this is not provided, a location containing the client id will be used instead.
/// </summary>
public PurviewAppLocation? PurviewAppLocation { get; set; }
/// <summary>
/// Gets or sets a flag indicating whether to ignore exceptions when processing Purview requests. False by default.
/// If set to true, exceptions calling Purview will be logged but not thrown.
/// </summary>
public bool IgnoreExceptions { get; set; }
/// <summary>
/// Gets or sets the base URI for the Microsoft Graph API.
/// Set to graph v1.0 by default.
/// </summary>
public Uri GraphBaseUri { get; set; } = new Uri("https://graph.microsoft.com/v1.0/");
/// <summary>
/// Gets or sets the message to display when a prompt is blocked by Purview policies.
/// </summary>
public string BlockedPromptMessage { get; set; } = "Prompt blocked by policies";
/// <summary>
/// Gets or sets the message to display when a response is blocked by Purview policies.
/// </summary>
public string BlockedResponseMessage { get; set; } = "Response blocked by policies";
/// <summary>
/// The size limit of the default in memory cache in bytes. This only applies if no cache is provided when creating Purview resources.
/// </summary>
public long? InMemoryCacheSizeLimit { get; set; } = 100_000_000;
/// <summary>
/// The TTL of each cache entry.
/// </summary>
public TimeSpan CacheTTL { get; set; } = TimeSpan.FromMinutes(30);
/// <summary>
/// The maximum number of background jobs that can be queued up.
/// </summary>
public int PendingBackgroundJobLimit { get; set; } = 100;
/// <summary>
/// The maximum number of concurrent job consumers.
/// </summary>
public int MaxConcurrentJobConsumers { get; set; } = 10;
}