From 46959acaa95dec3f5bade648eacc0124f723d469 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 29 May 2023 18:52:47 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(prompts.py):=20swap=20s?= =?UTF-8?q?uffix=20and=20format=5Finstructions=20fields=20=F0=9F=94=A8=20r?= =?UTF-8?q?efactor(util.py):=20add=20format=5Finstructions=20to=20the=20li?= =?UTF-8?q?st=20of=20fields=20to=20format=20in=20format=5Fdict=20function?= =?UTF-8?q?=20The=20suffix=20and=20format=5Finstructions=20fields=20in=20t?= =?UTF-8?q?he=20ZeroShotPromptNode=20class=20were=20swapped=20to=20improve?= =?UTF-8?q?=20the=20readability=20of=20the=20code.=20The=20format=5Finstru?= =?UTF-8?q?ctions=20field=20is=20now=20above=20the=20suffix=20field,=20whi?= =?UTF-8?q?ch=20makes=20more=20sense=20as=20it=20is=20a=20required=20field?= =?UTF-8?q?.=20In=20the=20util.py=20file,=20the=20format=5Finstructions=20?= =?UTF-8?q?field=20was=20added=20to=20the=20list=20of=20fields=20to=20form?= =?UTF-8?q?at=20in=20the=20format=5Fdict=20function.=20This=20ensures=20th?= =?UTF-8?q?at=20the=20format=5Finstructions=20field=20is=20properly=20form?= =?UTF-8?q?atted=20when=20the=20function=20is=20called.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/template/frontend_node/prompts.py | 14 +++++++++----- src/backend/langflow/utils/util.py | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/template/frontend_node/prompts.py b/src/backend/langflow/template/frontend_node/prompts.py index 830623a7e..7d7b1cde2 100644 --- a/src/backend/langflow/template/frontend_node/prompts.py +++ b/src/backend/langflow/template/frontend_node/prompts.py @@ -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) diff --git a/src/backend/langflow/utils/util.py b/src/backend/langflow/utils/util.py index af49856d7..0c9a18335 100644 --- a/src/backend/langflow/utils/util.py +++ b/src/backend/langflow/utils/util.py @@ -273,6 +273,7 @@ def format_dict(d, name: Optional[str] = None): "examples", "code", "headers", + "format_instructions", ] # Replace dict type with str