From c3dd838d6f90f54a3b36fd48f8a982f71e635d1b Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Tue, 5 Dec 2023 14:27:38 +0000 Subject: [PATCH] Remove string formatting deprecation warning from prompt.py and instructions.py --- guardrails/prompt/instructions.py | 7 ------- guardrails/prompt/prompt.py | 7 ------- 2 files changed, 14 deletions(-) diff --git a/guardrails/prompt/instructions.py b/guardrails/prompt/instructions.py index f9bd612b5..1ef53bbac 100644 --- a/guardrails/prompt/instructions.py +++ b/guardrails/prompt/instructions.py @@ -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 @@ -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( diff --git a/guardrails/prompt/prompt.py b/guardrails/prompt/prompt.py index 20947b767..484c489cf 100644 --- a/guardrails/prompt/prompt.py +++ b/guardrails/prompt/prompt.py @@ -1,5 +1,4 @@ """The LLM prompt.""" -import warnings from string import Template from guardrails.utils.parsing_utils import get_template_variables @@ -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)