Skip to content

Commit 0508f35

Browse files
committed
added formatting rules
1 parent 13a46f8 commit 0508f35

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/com/jakegodsall/services/prompt/impl/PromptServiceGPTImpl.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ public String generateRequestBody(String prompt) throws JsonProcessingException
3737

3838
@Override
3939
public String generatePrompt(String targetWord, FlashcardType flashcardType, Language language, Options options) {
40-
return generateBasePrompt() + getDescriptionOfContent(flashcardType) + getFlashcardStructure(flashcardType) + "The word is " + targetWord + " and the target language is " + language.getName() + ".\n";
40+
return generateBasePrompt() +
41+
getDescriptionOfContent(flashcardType) +
42+
getFlashcardStructure(flashcardType) +
43+
"The word is \"" + targetWord + "\" and the target language is " + language.getName() + ".\n" +
44+
getFormattingRules();
4145
}
4246

4347
@Override
@@ -48,7 +52,8 @@ public String generatePromptForMultipleFlashcards(String targetWord, FlashcardTy
4852
getFlashcardStructure(flashcardType) +
4953
"The word is \"" + targetWord + "\" and the target language is " + language.getName() + ".\n" +
5054
"Each flashcard should use different example sentences and translations while maintaining accuracy.\n" +
51-
"Remember: Every flashcard MUST use the exact word \"" + targetWord + "\" - not synonyms, not related words.\n";
55+
"Remember: Every flashcard MUST use the exact word \"" + targetWord + "\" - not synonyms, not related words.\n" +
56+
getFormattingRules();
5257
}
5358

5459
@Override
@@ -75,4 +80,12 @@ private String getFlashcardStructure(FlashcardType flashcardType) {
7580
default -> throw new IllegalArgumentException("Unsupported FlashcardType: " + flashcardType);
7681
};
7782
}
83+
84+
private String getFormattingRules() {
85+
return "Please follow these formatting rules:\n" +
86+
"1. If the word is a verb in the infinitive form, prefix it with \"to \" in both native and target languages\n" +
87+
"2. The native word and target word should be in lowercase\n" +
88+
"3. Example sentences must start with a capital letter and end with a period\n" +
89+
"4. Ensure proper sentence structure and punctuation in all example sentences\n";
90+
}
7891
}

0 commit comments

Comments
 (0)