File tree Expand file tree Collapse file tree 2 files changed +0
-39
lines changed Expand file tree Collapse file tree 2 files changed +0
-39
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,6 @@ def substitute_constants(self, text):
48
48
"""Substitute constants in the prompt."""
49
49
# Substitute constants by reading the constants file.
50
50
# Regex to extract all occurrences of ${gr.<constant_name>}
51
- if self .uses_old_constant_schema (text ):
52
- warnings .warn (
53
- "It appears that you are using an old schema for gaurdrails variables, "
54
- "follow the new namespaced convention "
55
- "documented here: https://docs.guardrailsai.com/0-2-migration/"
56
- )
57
-
58
51
matches = re .findall (r"\${gr\.(\w+)}" , text )
59
52
60
53
# Substitute all occurrences of ${gr.<constant_name>}
@@ -66,13 +59,6 @@ def substitute_constants(self, text):
66
59
67
60
return text
68
61
69
- def uses_old_constant_schema (self , text ) -> bool :
70
- matches = re .findall (r"@(\w+)" , text )
71
- if len (matches ) == 0 :
72
- return False
73
- else :
74
- return True
75
-
76
62
def get_prompt_variables (self ):
77
63
return self .variable_names
78
64
Original file line number Diff line number Diff line change @@ -232,31 +232,6 @@ def test_substitute_constants(prompt_str, final_prompt):
232
232
assert prompt .source == final_prompt
233
233
234
234
235
- # TODO: Deprecate when we can confirm migration off the old, non-namespaced standard
236
- @pytest .mark .parametrize (
237
- "text, is_old_schema" ,
238
- [
239
- (RAIL_WITH_OLD_CONSTANT_SCHEMA , True ), # Test with a single match
240
- (
241
- RAIL_WITH_FORMAT_INSTRUCTIONS ,
242
- False ,
243
- ), # Test with no matches/correct namespacing
244
- ],
245
- )
246
- def test_uses_old_constant_schema (text , is_old_schema ):
247
- with mock .patch ("warnings.warn" ) as warn_mock :
248
- guard = gd .Guard .from_rail_string (text )
249
- assert guard .prompt .uses_old_constant_schema (text ) == is_old_schema
250
- if is_old_schema :
251
- # we only check for the warning when we have an older schema
252
- warn_mock .assert_called_once_with (
253
- """It appears that you are using an old schema for gaurdrails\
254
- variables, follow the new namespaced convention documented here:\
255
- https://docs.guardrailsai.com/0-2-migration/\
256
- """
257
- )
258
-
259
-
260
235
class TestResponse (BaseModel ):
261
236
grade : int = Field (description = "The grade of the response" )
262
237
You can’t perform that action at this time.
0 commit comments