2025-03-08 20:13:08 +01:00
|
|
|
namespace AIStudio.Chat;
|
|
|
|
|
|
|
|
|
|
public static class ChatThreadExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the specified provider is allowed for the chat thread.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
2026-10-22 18:57:12 +02:00
|
|
|
/// A provider the organization prohibited is never allowed, whatever the chat thread.<br/><br/>
|
|
|
|
|
///
|
2025-03-08 20:13:08 +01:00
|
|
|
/// We don't check if the provider is allowed to use the data sources of the chat thread.
|
2026-09-09 18:43:37 +02:00
|
|
|
/// That kind of check is done when the available data sources are resolved.<br/><br/>
|
2026-10-28 13:28:30 +01:00
|
|
|
///
|
2025-03-08 20:13:08 +01:00
|
|
|
/// One thing which is not so obvious: after RAG was used on this thread, the entire chat
|
|
|
|
|
/// thread is kind of a data source by itself. Why? Because the augmentation data collected
|
|
|
|
|
/// from the data sources is stored in the chat thread. This means we must check if the
|
2026-09-09 18:43:37 +02:00
|
|
|
/// selected provider is allowed to use this thread's data security and confidence level.
|
2026-10-28 13:28:30 +01:00
|
|
|
/// The check itself is ChatRestrictionsExtensions.IsLLMProviderAllowed, which content that left
|
|
|
|
|
/// the thread is checked with as well.
|
2025-03-08 20:13:08 +01:00
|
|
|
/// </remarks>
|
2026-10-28 13:28:30 +01:00
|
|
|
/// <param name="chatThread">The chat thread to check; null for a new chat, which demands nothing yet.</param>
|
2025-03-08 20:13:08 +01:00
|
|
|
/// <param name="provider">The provider to check.</param>
|
|
|
|
|
/// <returns>True, when the provider is allowed for the chat thread. False, otherwise.</returns>
|
2026-10-28 13:28:30 +01:00
|
|
|
public static bool IsLLMProviderAllowed<T>(this ChatThread? chatThread, T provider) => (chatThread?.CaptureRestrictions() ?? ChatRestrictions.NONE).IsLLMProviderAllowed(provider);
|
2026-09-04 15:48:07 +02:00
|
|
|
}
|