Skip to content

Commit 250e027

Browse files
rbenzaAirsaid
authored andcommitted
Add system role 3
1 parent dbeb312 commit 250e027

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/airsaid/localization/translate/impl/openai/ChatGPTTranslator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ public String getAppKeyDisplay() {
8282
@Override
8383
@NotNull
8484
public String getRequestBody(@NotNull Lang fromLang, @NotNull Lang toLang, @NotNull String text) {
85-
String roleSystem = String.format("Become a professional translator. You're translating text for an Android app. Your audience are native %s speakers. Keep the exact formatting and style of the original text. Don't add white space. " +
86-
"Try to keep the translated text around the same length or shorter than the original. Just repeat the same text when the translation is not different (e.g a word like 'OK' is written the same in multiple languages). Now translate the text from the user into %s", toLang.getEnglishName(), toLang.getEnglishName());
85+
String roleSystem = String.format("Become a professional translator. You're translating text for the user interface of an Android app. Your audience are native %s speakers so try to keep cultural connotations. Use the exact formatting and style of the original text. " +
86+
"Try to keep the translated text around the same length or shorter than the original. Just repeat the original text when the translation is not different (e.g a word like 'OK'). Now translate the text from the user into %s", toLang.getEnglishName(), toLang.getEnglishName());
87+
8788
ChatGPTMessage role = new ChatGPTMessage("system", roleSystem);
88-
ChatGPTMessage msg = new ChatGPTMessage("user", String.format("Text to translate: %s", toLang.getEnglishName(), text));
89+
ChatGPTMessage msg = new ChatGPTMessage("user", String.format("Text to translate: %s", text));
90+
8991
OpenAIRequest body = new OpenAIRequest("gpt-3.5-turbo", List.of(role, msg));
9092

9193
return GsonUtil.getInstance().getGson().toJson(body);

0 commit comments

Comments
 (0)