deadbits / vigil-llm

⚡ Vigil ⚡ Detect prompt injections, jailbreaks, and other potentially risky Large Language Model (LLM) inputs
https://vigil.deadbits.ai/
Apache License 2.0
270 stars 32 forks source link

Sane scanner initialization #62

Closed deadbits closed 7 months ago

deadbits commented 7 months ago

The creation of vigil/vigil.py to manage initializing the scanners from a config file was a big step towards ease of use, but there's still so much going on there. This project is meant to be extensible, letting users add their own scanners. But with the current implementation, that's realistically not very straight forward.

I want to move the scanners to use a factory registry implementation. There will be a scanner registry and to add a new scanner you will subclass BaseScanner and call registry.create_scanner(name) to register. Then I can do away with all the complicated configuration loading in vigil.py. instead this will just iterate over the list of registered scanners and pass the scanner config.

Some scanners also need config details from the embedding section, so maybe BaseScanner gets extended to specify what it requires and this can be handled dynamically as well. This could be a good idea for future-proofing if I add more non-scanner components that scanners can use.

deadbits commented 7 months ago

Address with PR https://github.com/deadbits/vigil-llm/pull/63

Scanners are now initialized using a factory pattern. There's a decorator to register scanners with the factory, which can optionally take additional arguments: require_vectordb, require_embedding, and require_config