781 prompt governance detect pii phi #61
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces functionality to call the /promptgov API from Langchain whenever a prompt is sent. This integration ensures enhanced entity extraction and validation against a deny list to improve prompt governance. Initially, this feature is implemented for Pebblo, with plans to extend it to Daxa in future updates.
Changes:-
In PebbloRetrievalQa, we have introduced a new parameter called _enable_prompt_gov, which defaults to True. When _enable_prompt_gov is True and there are values in the semantic_context.pebblo_semantic_entities.deny list, we invoke the _check_prompt_validity function. This function communicates with the /pebblogov API from Pebblo, retrieves entities from the prompt, and compares them against the deny list. If any entity from the prompt is found in the deny list, the function returns False; otherwise, it returns True. If the function returns True, the prompt is blocked.
Output
When we have a deny list
When we don't have a deny list
When we don't have any deny list but we have any entity in the prompt