Skip to content

Conversation

@sharanshirodkar7
Copy link
Contributor

Description

This PR introduces new guardrail components for Prediction Guard (PG) to enhance the safety and reliability of AI interactions. The following guardrails have been added:

1.	Factuality Detection
2.	Toxicity Detection
3.	Prompt Injection Detection
4.	PII detection

Issues

n/a

Type of change

New feature (non-breaking change which adds new functionality)

Dependencies

PREDICTIONGUARD_API_KEY needs to be added to CI/CD to test the microservice.

Tests

The following tests were conducted to verify the functionality and integration of the new guardrail components:

•	Unit tests for each guardrail component to validate detection accuracy and reliability.
•	Integration tests to ensure smooth operation alongside existing Prediction Guard components.
•	Performance tests to verify the guardrails do not introduce significant latency or performance overhead.

All tests have passed, confirming the effective integration of the guardrail components.

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
…pace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@sharanshirodkar7
Copy link
Contributor Author

@chensuyue PG guardrails comp ready for review.

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@lvliang-intel
Copy link
Collaborator

@sharanshirodkar7,

Please fix the pre-commit issue.

image

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
…pace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@sharanshirodkar7
Copy link
Contributor Author

@lvliang-intel updated.

@sharanshirodkar7
Copy link
Contributor Author

@letonghan @lvliang-intel ready for review.

@chensuyue
Copy link
Collaborator

chensuyue commented Sep 18, 2024

What's the relationship between those 2 dockerfile, if they belong to 2 different implementation for the service, then the original one should be package into a folder. Based on the new structure, the path with Dockerfile* will be recognized as the service path belong to a single service. That means the CI recognize comps/guardrails/pii_detection/predictionguard belong to comps/guardrails/pii_detection. I think that's not what you want.
image
image

@sharanshirodkar7
Copy link
Contributor Author

@chensuyue so those files already exist in the repo main right now outside of any folder within toxicity detection. I created a folder predictionguard and added our files there. I was not sure if I have to move the files not related to our service as it might affect some links in examples repo too. Let me know what we should do here.

lkk12014402 pushed a commit that referenced this pull request Sep 19, 2024
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
@sharanshirodkar7
Copy link
Contributor Author

@letonghan ready for review and merge.

@letonghan
Copy link
Collaborator

Can you explain the relationship of prediction guard and other four implementations (Factuality Detection, Toxicity Detection, ...)? So we can discuss how to reorg your new components folders.
After that, remember to update the README of GenAIComps\comps\guardrails\README.md. Thanks : )

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@sharanshirodkar7
Copy link
Contributor Author

@lvliang-intel, thanks for your feedback. I’m working on addressing your suggestions.
@letonghan, sure so Prediction Guard is an end-to-end GenAI platform that provides access to the latest open models from Hugging Face, including LLMs, LVMs, and embeddings (these three microservices have already been merged into OPEA). The platform’s key value proposition is its focus on privacy and security features, such as PII detection, prompt injection checks, factuality, and toxicity checks. These services are integral to Prediction Guard, which is why I created dedicated folders for predictionguard and added the corresponding code.

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@codecov
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
comps/cores/proto/docarray.py 99.34% <100.00%> (+0.05%) ⬆️

... and 1 file with indirect coverage changes

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
…pace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
sharanshirodkar7 and others added 3 commits September 20, 2024 10:37
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
@sharanshirodkar7
Copy link
Contributor Author

sharanshirodkar7 commented Sep 20, 2024

@lvliang-intel @XuhuiRen updated.

@lvliang-intel lvliang-intel merged commit 4bbc7a2 into opea-project:main Sep 23, 2024
@joshuayao joshuayao added this to the v1.1 milestone Nov 7, 2024
@joshuayao joshuayao added feature New feature or request r1.1 labels Nov 7, 2024
madison-evans pushed a commit to SAPD-Intel/GenAIComps that referenced this pull request May 12, 2025
* added files for PG guardrails components

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* Fix pre-commit issues: end-of-file, requirements.txt, trailing whitespace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* added package

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* added package

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* added package

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* file structure updated to latest

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* Fix pre-commit issues: end-of-file, requirements.txt, trailing whitespace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* Add .DS_Store to .gitignore

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* updated readme,requirements+changes based on feedback

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* references classes in init.py

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* fix readme link error

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* Fix pre-commit issues: end-of-file, requirements.txt, trailing whitespace, imports, and formatting

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* removed duplicatesa

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

* removed added readme content

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>

---------

Signed-off-by: sharanshirodkar7 <ssharanshirodkar7@gmail.com>
WenjiaoYue pushed a commit that referenced this pull request Jul 7, 2025
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request r1.1

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants