|  | 
| 7 | 7 | 
 | 
| 8 | 8 | import asyncio | 
| 9 | 9 | import pytest | 
| 10 |  | -from pydantic import BaseModel, Field | 
| 11 | 10 | 
 | 
| 12 | 11 | import guardrails as gd | 
| 13 | 12 | from guardrails.utils.casting_utils import to_int | 
|  | 
| 22 | 21 | ) | 
| 23 | 22 | from tests.integration_tests.test_assets.validators import LowerCase, MockDetectPII | 
| 24 | 23 | 
 | 
| 25 |  | -expected_raw_output = {"statement": "I am DOING well, and I HOPE you aRe too."} | 
| 26 |  | -expected_fix_output = {"statement": "i am doing well, and i hope you are too."} | 
| 27 |  | -expected_noop_output = {"statement": "I am DOING well, and I HOPE you aRe too."} | 
| 28 |  | -expected_filter_refrain_output = {} | 
| 29 |  | - | 
| 30 | 24 | 
 | 
| 31 | 25 | @register_validator(name="minsentencelength", data_type=["string", "list"]) | 
| 32 | 26 | class MinSentenceLengthValidator(Validator): | 
| @@ -137,52 +131,6 @@ async def gen(): | 
| 137 | 131 |         self.completion_stream = gen() | 
| 138 | 132 | 
 | 
| 139 | 133 | 
 | 
| 140 |  | -class LowerCaseFix(BaseModel): | 
| 141 |  | -    statement: str = Field( | 
| 142 |  | -        description="Validates whether the text is in lower case.", | 
| 143 |  | -        validators=[LowerCase(on_fail=OnFailAction.FIX)], | 
| 144 |  | -    ) | 
| 145 |  | - | 
| 146 |  | - | 
| 147 |  | -class LowerCaseNoop(BaseModel): | 
| 148 |  | -    statement: str = Field( | 
| 149 |  | -        description="Validates whether the text is in lower case.", | 
| 150 |  | -        validators=[LowerCase(on_fail=OnFailAction.NOOP)], | 
| 151 |  | -    ) | 
| 152 |  | - | 
| 153 |  | - | 
| 154 |  | -class LowerCaseFilter(BaseModel): | 
| 155 |  | -    statement: str = Field( | 
| 156 |  | -        description="Validates whether the text is in lower case.", | 
| 157 |  | -        validators=[LowerCase(on_fail=OnFailAction.FILTER)], | 
| 158 |  | -    ) | 
| 159 |  | - | 
| 160 |  | - | 
| 161 |  | -class LowerCaseRefrain(BaseModel): | 
| 162 |  | -    statement: str = Field( | 
| 163 |  | -        description="Validates whether the text is in lower case.", | 
| 164 |  | -        validators=[LowerCase(on_fail=OnFailAction.REFRAIN)], | 
| 165 |  | -    ) | 
| 166 |  | - | 
| 167 |  | - | 
| 168 |  | -expected_minsentence_noop_output = "" | 
| 169 |  | - | 
| 170 |  | - | 
| 171 |  | -class MinSentenceLengthNoOp(BaseModel): | 
| 172 |  | -    statement: str = Field( | 
| 173 |  | -        description="Validates whether the text is in lower case.", | 
| 174 |  | -        validators=[MinSentenceLengthValidator(on_fail=OnFailAction.NOOP)], | 
| 175 |  | -    ) | 
| 176 |  | - | 
| 177 |  | - | 
| 178 |  | -STR_PROMPT = "Say something nice to me." | 
| 179 |  | - | 
| 180 |  | -PROMPT = """ | 
| 181 |  | -Say something nice to me. | 
| 182 |  | -
 | 
| 183 |  | -${gr.complete_json_suffix} | 
| 184 |  | -""" | 
| 185 |  | - | 
| 186 | 134 | POETRY_CHUNKS = [ | 
| 187 | 135 |     '"John, under ', | 
| 188 | 136 |     "GOLDEN bridges", | 
|  | 
0 commit comments