-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(plugins): ai-prompt-guard-plugin #12337
Conversation
1733ed4
to
6d0ad98
Compare
d1c0bd7
to
2e8c766
Compare
ecccaf3
to
bcb617b
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.
Couple style nitpicks and a testing request remaining, but once those are addressed it's a 👍 from me.
@locao do we have another gateway reviewer for this PR? |
@flrgh this is on me, reviewing it now. |
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.
This seems pretty close to ready to merge.
@tysoekong do you think it's possible to add an integration test?
a4f5312
to
549609b
Compare
549609b
to
00f5e46
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.
Just one last clean up (but that's not a blocker) and I think we're good to go.
138022f
to
f471cae
Compare
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release/3.6.x
git worktree add -d .worktree/backport-12337-to-release/3.6.x origin/release/3.6.x
cd .worktree/backport-12337-to-release/3.6.x
git switch --create backport-12337-to-release/3.6.x
git cherry-pick -x 93a18877a42855bddedfd01521e420603fd5544f |
Cherry-pick failed for Please cherry-pick the changes locally. git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-12337-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-12337-to-master-to-upstream
git checkout -b cherry-pick-12337-to-master-to-upstream
ancref=$(git merge-base 3ef9235a6c76c76a641933abafcd857c740befe0 f471cae50bb87142a953b5a036e53bf17d38c093)
git cherry-pick -x $ancref..f471cae50bb87142a953b5a036e53bf17d38c093 |
* feat(plugins): ai-prompt-guard-plugin * fix(ai-prompt-guard): fixes from code review * Update kong/plugins/ai-prompt-guard/schema.lua Co-authored-by: Vinicius Mignot <[email protected]> --------- Co-authored-by: Jack Tysoe <[email protected]> Co-authored-by: Vinicius Mignot <[email protected]>
* feat(plugins): ai-prompt-guard-plugin * fix(ai-prompt-guard): fixes from code review * Update kong/plugins/ai-prompt-guard/schema.lua --------- Co-authored-by: Jack Tysoe <[email protected]> Co-authored-by: Vinicius Mignot <[email protected]>
Summary
This commit offers another plugin that extends the functionality of "AI Proxy" in #12207.
It compares the user's
llm/v1/chat
orllm/v1/completions
request against a series of regular expressions, in two config arrays:If the request matches any regex pattern in deny, the caller is 400'd.
If any allow is specified, by the request matches none of them, the caller is also 400'd.
Engineering design document is available for this feature, but it is quite simple. Comprehensive tests supplied.
This reason for its development, is that many of our users would like to block specific prompts, words, phrases, or otherwise more tightly control how an AI / LLM model is used, if being called via Kong, and this applies especially with the
AI Proxy
plugin that will simplify this process.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.md