From bdebe6592782514077d1083f16a14197ea9e503c Mon Sep 17 00:00:00 2001 From: Austin Lee Date: Wed, 11 Oct 2023 14:52:12 -0700 Subject: [PATCH] Check if systemPrompt is null. Signed-off-by: Austin Lee --- .../questionanswering/generative/prompt/PromptUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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);