-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start contributor experience changes
- Loading branch information
1 parent
be4718e
commit 33087d5
Showing
9 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# to run these, run | ||
# make tests | ||
|
||
from guardrails import Guard | ||
import pytest | ||
from validator import ValidatorTemplate | ||
|
||
# We use 'exception' as the validator's fail action, | ||
# so we expect failures to always raise an Exception | ||
# Learn more about corrective actions here: | ||
# https://www.guardrailsai.com/docs/concepts/output/#%EF%B8%8F-specifying-corrective-actions | ||
guard = Guard.from_string(validators=[ValidatorTemplate(arg_1="arg_1", arg_2="arg_2", on_fail="exception")]) | ||
|
||
def test_pass(): | ||
test_output = "pass" | ||
result = guard.parse(test_output) | ||
|
||
assert result.validation_passed is True | ||
assert result.validated_output == test_output | ||
|
||
def test_fail(): | ||
with pytest.raises(Exception) as exc_info: | ||
test_output = "fail" | ||
guard.parse(test_output) | ||
|
||
# Assert the exception has your error_message | ||
assert str(exc_info.value) == "Validation failed for field with errors: {A descriptive but concise error message about why validation failed}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .main import RegexMatch | ||
from .main import ValidatorTemplate | ||
|
||
__all__ = ["RegexMatch"] | ||
__all__ = ["ValidatorTemplate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
print("post-install starting...") | ||
print("This is where you would do things like download nltk tokenizers or login to the HuggingFace hub...") | ||
print("post-install complete!") | ||
# If you don't have anything to add here you should delete this file. |