Skip to content

Commit

Permalink
Remove string formatting deprecation warning from prompt.py and instr…
Browse files Browse the repository at this point in the history
…uctions.py
  • Loading branch information
irgolic committed Dec 5, 2023
1 parent e80ba5c commit c3dd838
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
7 changes: 0 additions & 7 deletions guardrails/prompt/instructions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Instructions to the LLM, to be passed in the prompt."""
from string import Template
from warnings import warn

from guardrails.utils.parsing_utils import get_template_variables

Expand Down Expand Up @@ -30,12 +29,6 @@ def format(self, **kwargs):
# Only use the keyword arguments that are present in the prompt.
vars = get_template_variables(self.source)
filtered_kwargs = {k: v for k, v in kwargs.items() if k in vars}
if len(filtered_kwargs) == 0:
warn(
"Instructions do not have any variables, "
"if you are migrating follow the new variable convention "
"documented here: https://docs.guardrailsai.com/0-2-migration/"
)

# Return another instance of the class with the formatted prompt.
formatted_instructions = Template(self.source).safe_substitute(
Expand Down
7 changes: 0 additions & 7 deletions guardrails/prompt/prompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""The LLM prompt."""
import warnings
from string import Template

from guardrails.utils.parsing_utils import get_template_variables
Expand All @@ -21,12 +20,6 @@ def format(self, **kwargs):
# Only use the keyword arguments that are present in the prompt.
vars = get_template_variables(self.source)
filtered_kwargs = {k: v for k, v in kwargs.items() if k in vars}
if len(filtered_kwargs) == 0:
warnings.warn(
"Prompt does not have any variables, "
"if you are migrating follow the new variable convention "
"documented here: https://docs.guardrailsai.com/0-2-migration/"
)

# Return another instance of the class with the formatted prompt.
formatted_prompt = Template(self.source).safe_substitute(**filtered_kwargs)
Expand Down

0 comments on commit c3dd838

Please sign in to comment.