Skip to content

Commit d34dfbd

Browse files
committed
base_prompt: Remove warning on old schema
1 parent 58d2316 commit d34dfbd

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

guardrails/prompt/base_prompt.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ def substitute_constants(self, text):
4848
"""Substitute constants in the prompt."""
4949
# Substitute constants by reading the constants file.
5050
# 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-
5851
matches = re.findall(r"\${gr\.(\w+)}", text)
5952

6053
# Substitute all occurrences of ${gr.<constant_name>}
@@ -66,13 +59,6 @@ def substitute_constants(self, text):
6659

6760
return text
6861

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-
7662
def get_prompt_variables(self):
7763
return self.variable_names
7864

tests/unit_tests/test_prompt.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,31 +232,6 @@ def test_substitute_constants(prompt_str, final_prompt):
232232
assert prompt.source == final_prompt
233233

234234

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-
260235
class TestResponse(BaseModel):
261236
grade: int = Field(description="The grade of the response")
262237

0 commit comments

Comments
 (0)