🔨 refactor(prompts.py): swap suffix and format_instructions fields

🔨 refactor(util.py): add format_instructions to the list of fields to format in format_dict function
The suffix and format_instructions fields in the ZeroShotPromptNode class were swapped to improve the readability of the code. The format_instructions field is now above the suffix field, which makes more sense as it is a required field. In the util.py file, the format_instructions field was added to the list of fields to format in the format_dict function. This ensures that the format_instructions field is properly formatted when the function is called.
This commit is contained in:
Gabriel Almeida 2023-05-29 18:52:47 -03:00
commit 46959acaa9
2 changed files with 10 additions and 5 deletions

View file

@ -89,18 +89,18 @@ class ZeroShotPromptNode(BasePromptFrontendNode):
is_list=False,
show=True,
multiline=True,
value=prompt.SUFFIX,
name="suffix",
value=prompt.FORMAT_INSTRUCTIONS,
name="format_instructions",
),
TemplateField(
field_type="str",
required=False,
required=True,
placeholder="",
is_list=False,
show=True,
multiline=True,
value=prompt.FORMAT_INSTRUCTIONS,
name="format_instructions",
value=prompt.SUFFIX,
name="suffix",
),
],
)
@ -109,3 +109,7 @@ class ZeroShotPromptNode(BasePromptFrontendNode):
def to_dict(self):
return super().to_dict()
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
PromptFrontendNode.format_field(field, name)

View file

@ -273,6 +273,7 @@ def format_dict(d, name: Optional[str] = None):
"examples",
"code",
"headers",
"format_instructions",
]
# Replace dict type with str