Skip to content
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

[backport -> release/3.6.x] feat(plugins): ai-prompt-guard-plugin #12337 #12427

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

tysoekong
Copy link
Contributor

Automated backport to release/3.6.x, triggered by a label in #12341.

Original description

Summary

This commit offers another plugin that extends the functionality of "AI Proxy" in #12207.

It compares the user's llm/v1/chat or llm/v1/completions request against a series of regular expressions, in two config arrays:

  • Allow
  • Deny

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

* 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]>
@github-actions github-actions bot added chore Not part of the core functionality of kong, but still needed schema-change-noteworthy labels Jan 25, 2024
@flrgh flrgh added this to the 3.6.0 milestone Jan 25, 2024
@flrgh flrgh merged commit 8f901e4 into release/3.6.x Jan 25, 2024
29 checks passed
@flrgh flrgh deleted the backport-12337-to-release-3.6.x branch January 25, 2024 22:38
@tysoekong tysoekong added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Jan 25, 2024
@team-gateway-bot
Copy link
Collaborator

Cherry-pick failed for release/3.6.x: couldn't find remote ref release/3.6.x.
Please ensure that this Github repo has a branch named release/3.6.x.

@team-gateway-bot
Copy link
Collaborator

Cherry-pick failed for release/3.6.x, because it was unable to create a new branch.

Please cherry-pick the changes locally.

git remote add upstream https://github.com/kong/kong-ee
git fetch upstream release/3.6.x
git worktree add -d .worktree/cherry-pick-12427-to-release/3.6.x-to-upstream upstream/release/3.6.x
cd .worktree/cherry-pick-12427-to-release/3.6.x-to-upstream
git checkout -b cherry-pick-12427-to-release/3.6.x-to-upstream
ancref=$(git merge-base 31f40482368ec5c16acfa0c334e2f1347828286d b3308d575605626aea054849f8e0bcedb9e7e0c2)
git cherry-pick -x $ancref..b3308d575605626aea054849f8e0bcedb9e7e0c2

This was referenced Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee chore Not part of the core functionality of kong, but still needed schema-change-noteworthy size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants