first commit

This commit is contained in:
Dhananjaya99
2026-09-28 11:44:26 +05:30
parent 721743ae6b
commit bffc9b1686
424 changed files with 46474 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
namespace Fitness_core_BE.AI
{
public class ModificationGuard
{
private static readonly string[] AllowedKeywords =
{
"replace",
"remove",
"allergy",
"change",
"vegetarian",
"calorie",
"protein",
"carb",
"fat",
"meal",
"ingredient"
};
private static readonly string[] BlockedPatterns =
{
"ignore previous instructions",
"system prompt",
"act as",
"bypass",
"developer mode",
"jailbreak"
};
public void Validate(string message)
{
if (string.IsNullOrWhiteSpace(message))
throw new Exception("Modification cannot be empty.");
if (message.Length > 500)
throw new Exception("Modification too long.");
var lower = message.ToLower();
if (BlockedPatterns.Any(p => lower.Contains(p)))
throw new Exception("Invalid modification request.");
//if (!AllowedKeywords.Any(k => lower.Contains(k)))
// throw new Exception("Only meal plan modifications are allowed.");
}
}
}