๐Ÿ”ฌ
Vigil: Documentation
GitHub Repo
  • ๐Ÿ›ก๏ธVigil
  • Overview
    • ๐Ÿ—๏ธRelease Blog
    • ๐Ÿ› ๏ธInstall Vigil
      • ๐Ÿ”ฅInstall PyTorch (optional)
    • ๐ŸงชUse Vigil
      • โš™๏ธConfiguration
        • ๐Ÿ”„Auto-updating vector database
      • ๐Ÿ—„๏ธLoad Datasets
      • ๐ŸŒWeb server
        • ๐ŸคAPI Endpoints
        • ๐ŸชWeb UI playground
      • ๐ŸPython library
      • ๐ŸŽฏScanners
        • ๐Ÿค—Transformer
        • โ•YARA / Heuristics
        • ๐Ÿ“‘Prompt-response Similarity
        • ๐Ÿ’พVector database
        • ๐ŸคCanary Tokens
    • ๐Ÿ›ก๏ธCustomize Detections
      • ๐ŸŒŸAdd custom YARA signatures
      • ๐Ÿ”ขAdd embeddings
      • ๐ŸCustom scanners
    • ๐Ÿช„Sample scan results
Powered by GitBook
On this page
  • Initialize scanners
  • Scan Prompts and Responses
  • Canary Tokens
  1. Overview
  2. Use Vigil

Python library

Use Vigil as a Python library

Vigil can also be used within your own Python application as a library. This allows you to access the input and output scanners, canary token, and vector database functionality.

The Vigil library must be installed via

pip install -e .

Then import the Vigil class and pass it your config file.

Initialize scanners

from vigil.vigil import Vigil

app = Vigil.from_config('conf/openai.conf')

Pass your configuration file to Vigil.from_config. This exposes the following functions:

  • input_scanner.perform_scan(prompt)

  • output_scanner.perform_scan(prompt, response)

  • canary_tokens.add

  • canary_tokens.check

  • vectordb.add_texts

  • vectordb.add_embeddings

  • embedder.generate

Scan Prompts and Responses

app.input_scanner.perform_scan(
    input_prompt="prompt goes here"
)

app.output_scanner.perform_scan(
    input_prompt="prompt goes here",
    input_resp="LLM response goes here"
)

The scanners return a Python dictionary with the full results and any metadata.

Canary Tokens

updated_prompt = app.canary_tokens.add(
    prompt=application_prompt,          # prompt to add canary token to
    always=always if always else False, # add suffix to always include canary
    length=length if length else 16,    # canary token length
    header=header if header else '<-@!-- {canary} --@!->', # customize canary header
)

# canary_tokens.check() returns True if a canary is found
result = app.canary_tokens.check(prompt=llm_response)
PreviousWeb UI playgroundNextScanners

Last updated 1 year ago

๐Ÿงช
๐Ÿ