Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[FIX] Fixed issue in prompt construction (#767)

Deepak K4e59cb35b32b
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