mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 19:27:21 +00:00
39 lines
2.2 KiB
C#
39 lines
2.2 KiB
C#
namespace AIStudio.Tools.Security;
|
|
|
|
public readonly record struct PromptInjectionSource(PromptInjectionSourceKind Kind, string Label)
|
|
{
|
|
public string NotificationLabel => this.Kind is PromptInjectionSourceKind.FILE_CONTENT or PromptInjectionSourceKind.CHAT_ATTACHMENT
|
|
? Path.GetFileName(this.Label)
|
|
: this.Label;
|
|
|
|
public static PromptInjectionSource WebContent(string url) => new(PromptInjectionSourceKind.WEB_CONTENT, url);
|
|
|
|
public static PromptInjectionSource FileContent(string filePath) => new(PromptInjectionSourceKind.FILE_CONTENT, filePath);
|
|
|
|
public static PromptInjectionSource ChatAttachment(string filePath) => new(PromptInjectionSourceKind.CHAT_ATTACHMENT, filePath);
|
|
|
|
public static PromptInjectionSource RetrievalContext(string dataSourceName, string path) => new(PromptInjectionSourceKind.RETRIEVAL_CONTEXT, $"{dataSourceName}: {path}");
|
|
|
|
public static PromptInjectionSource DataSourceDescription(string dataSourceName) => new(PromptInjectionSourceKind.DATA_SOURCE_DESCRIPTION, dataSourceName);
|
|
|
|
/// <summary>
|
|
/// The content of the mails of one mailbox, its header fields included.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Named after the mailbox alone, never after a mail: the label ends up in the log, which keeps
|
|
/// no subjects and no addresses. It also makes all mails of a mailbox one source, so a sync
|
|
/// which filtered ten mails reports one mailbox instead of ten mails.
|
|
/// </remarks>
|
|
/// <param name="mailboxName">The name of the mailbox.</param>
|
|
public static PromptInjectionSource MailContent(string mailboxName) => new(PromptInjectionSourceKind.MAIL_CONTENT, mailboxName);
|
|
|
|
/// <summary>
|
|
/// What an AI wrote, sent on to an assistant or into a new chat.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// An answer may repeat what the AI read, such as a web page or a mail, and the instructions hidden
|
|
/// there with it. Named after the chat or the assistant the answer comes from, as the user knows it.
|
|
/// </remarks>
|
|
/// <param name="senderName">The name of the chat or of the assistant.</param>
|
|
public static PromptInjectionSource ModelAnswer(string senderName) => new(PromptInjectionSourceKind.MODEL_ANSWER, senderName);
|
|
} |