Skip to content

Valid Python Guardrails AI validator - Validates that there are no Python syntactic bugs in the generated code.

License

Notifications You must be signed in to change notification settings

smohiuddin/valid_python_validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guardrails Validator Template

How to create a Guardrails Validator

  • On the top right of the page, click "Use this template", select "create a new repository" and set a name for the package.
  • Modify the class in validator/main.py with source code for the new validator
    • Make sure that the class still inherits from Validator and has the register_validator annotation.
    • Set the name in the register_validator to the name of the repo and set the appropriate data type.
  • Change validator/init.py to your new Validator classname instead of RegexMatch
  • Locally test the validator with the test instructions below
  • Note: This package uses a pyproject.toml file, on first run, run pip install . to pull down and install all dependencies

Testing and using your validator

  • Open test/test-validator.py to test your new validator
  • Import your new validator and modify ValidatorTestObject accordingly
  • Modify the TEST_OUTPUT and TEST_FAIL_OUTPUT accordingly
  • Run python test/test-validator.py via terminal, make sure the returned output reflects the input object
  • Write advanced tests for failures, etc.

Upload your validator to the validator hub

  • Update the pyproject.toml file and make necessary changes as follows:
    • Update the name field to the name of your validator
    • Update the description field to a short description of your validator
    • Update the authors field to your name and email
    • Add/update the dependencies field to include all dependencies your validator needs.
  • If there are are any post-installation steps such as downloading tokenizers, logging into huggingface etc., update the post-install.py file accordingly.
  • You can add additional files to the validator directory, but don't rename any existing files/directories.
    • e.g. Add any environment variables (without the values, just the keys) to the .env file.
  • Ensure that there are no other dependencies or any additional steps required to run your validator.

About

Valid Python Guardrails AI validator - Validates that there are no Python syntactic bugs in the generated code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published