diff --git a/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/prompt/PromptUtil.java b/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/prompt/PromptUtil.java index c494e17b89..3a8a21614e 100644 --- a/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/prompt/PromptUtil.java +++ b/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/prompt/PromptUtil.java @@ -104,8 +104,11 @@ public static String buildSingleStringPrompt( } StringBuilder bldr = new StringBuilder(); - bldr.append(systemPrompt); - bldr.append(NEWLINE); + + if (!Strings.isNullOrEmpty(systemPrompt)) { + bldr.append(systemPrompt); + bldr.append(NEWLINE); + } if (!Strings.isNullOrEmpty(userInstructions)) { bldr.append(userInstructions); bldr.append(NEWLINE);