From 4e59cb35b32b484b2f2c320520f23164cf8d4d1d Mon Sep 17 00:00:00 2001 From: Deepak K <89829542+Deepak-Kesavan@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:58:05 +0530 Subject: [PATCH] [FIX] Fixed issue in prompt construction (#767) Fixed issue in prompt construction Signed-off-by: Deepak <89829542+Deepak-Kesavan@users.noreply.github.com> --- prompt-service/src/unstract/prompt_service/helper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prompt-service/src/unstract/prompt_service/helper.py b/prompt-service/src/unstract/prompt_service/helper.py index fc0628a3f..4a1d3e2dd 100644 --- a/prompt-service/src/unstract/prompt_service/helper.py +++ b/prompt-service/src/unstract/prompt_service/helper.py @@ -287,10 +287,7 @@ def construct_prompt( context: str, platform_postamble: str, ) -> str: - prompt = ( - f"{preamble}\n\nContext:\n---------------\n{context}\n" - f"-----------------\n\nQuestion or Instruction: {prompt}\n" - ) + prompt = f"{preamble}\n\nQuestion or Instruction: {prompt}" if grammar_list is not None and len(grammar_list) > 0: prompt += "\n" for grammar in grammar_list: @@ -305,7 +302,10 @@ def construct_prompt( {", ".join(synonyms)} in both the quesiton and the context.' # noqa if platform_postamble: platform_postamble += "\n\n" - prompt += f"\n\n{postamble}\n\n{platform_postamble}Answer:" + prompt += ( + f"\n\n{postamble}\n\nContext:\n---------------\n{context}\n" + f"-----------------\n\n{platform_postamble}Answer:" + ) return prompt