mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 15:52:30 +00:00
Added a prompt injection detection (#857)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
d3163badd9
commit
902a01a4d0
55 files changed
+5598
-70
No files matched your search
@@ -0,0 +1,16 @@
|
||||
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}");
|
||||
}
|
||||
Reference in new issue
Block a user