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_scannersthat inherits frombase.Scannerand implements thescanmethod. Thescanmethod 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_scannersfolder and add a link to themkdocs.ymlfile. - Also, add a link to the documentation in
README.md, and update thedocs/changelog.mdfile.
Extending the output scanners
- Create a new class in the
llm_guard/output_scannersthat inherits frombase.Scannerand implements thescanmethod. Thescanmethod 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_scannersfolder and add a link to themkdocs.ymlfile. - Also, add a link to the documentation in
README.md, and update thedocs/changelog.mdfile.