Adding a new scanner
LLM Guard can be extended to support new scanners, and to support additional models for the existing. These scanners could be added via code or ad-hoc as part of the request.
Note
Before writing code, please read the contributing guide.
Extending the input (prompt) scanners
- Create a new class in the
llm_guard/input_scanners
that inherits frombase.Scanner
and implements thescan
method. Thescan
method should return a tuplestr, bool, float
. - Add test cases for the new scanner in
tests/input_scanners
. - Add the new scanner to the
llm_guard/input_scanners/__init__.py
__all__
enum. - Write documentation in the
docs/input_scanners
folder and add a link to themkdocs.yml
file. - Also, add a link to the documentation in
README.md
, and update thedocs/changelog.md
file.
Extending the output scanners
- Create a new class in the
llm_guard/output_scanners
that inherits frombase.Scanner
and implements thescan
method. Thescan
method should return a tuplestr, bool, float
. - Add test cases for the new scanner in
tests/output_scanners
. - Add the new scanner to the
llm_guard/output_scanners/__init__.py
__all__
enum. - Write documentation in the
docs/output_scanners
folder and add a link to themkdocs.yml
file. - Also, add a link to the documentation in
README.md
, and update thedocs/changelog.md
file.