-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add prompt injection protection mechanism #28
Conversation
Signed-off-by: nextedoff <[email protected]>
…g injection protection Signed-off-by: nextedoff <[email protected]>
Signed-off-by: nextedoff <[email protected]>
Signed-off-by: nextedoff <[email protected]>
36d880f
to
7d2d98b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this!
Left some comments with suggestions, but I'm not finished yet. I'll continue tomorrow to check the core of the implementation and the frontend changes (which I'm duly excited about)!
…nisms Signed-off-by: nextedoff <[email protected]>
Signed-off-by: nextedoff <[email protected]>
Fixed docstrings in promptprotection.py, slightly rephrasing some for clarity and making sure that they're in proper markdown so that they are rendered correctly in the documentation. Renamed the 'config' dictionary of the 'PromptProtection' class to 'protections'. Signed-off-by: Phoevos Kalemkeris <[email protected]>
Signed-off-by: Phoevos Kalemkeris <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do some quick manual testing, but other than that LGTM!
Signed-off-by: Phoevos Kalemkeris <[email protected]>
Signed-off-by: Phoevos Kalemkeris <[email protected]>
Purpose
This feature is adding a way to implement new protection methods for the query, focusing on prompt injection protection in this PR. For injection protection model, model named
protectai/deberta-v3-base-prompt-injection
was used.New models and guard mechanisms can be added to
promptprotection.py
.Currently, the injection protection can either be turned on via API and user interface as seen in the screenshot, or it can be set via environment variables:
USE_INJECTION_PROTECTION="true"
Does this introduce a breaking change?
When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.
Does this require changes to learn.microsoft.com docs?
Type of change
Code quality checklist
python -m pytest
).python -m pytest --cov
to verify 100% coverage of added linespython -m mypy
to check for type errorsruff
andblack
manually on my code.