Skip to content

Commit 1dc9ccc

Browse files
rbenzaAirsaid
authored andcommitted
Different role test
1 parent 3af1cdb commit 1dc9ccc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ public String getRequestBody(@NotNull Lang fromLang, @NotNull Lang toLang, @NotN
8585
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. " +
8686
"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());
8787

88-
ChatGPTMessage role = new ChatGPTMessage("system", roleSystem);
89-
ChatGPTMessage msg = new ChatGPTMessage("user", String.format("Text to translate: %s", text));
88+
ChatGPTMessage role = new ChatGPTMessage("system", roleSystem); // todo find out why gives SocketTimeOUt exception
9089

91-
OpenAIRequest body = new OpenAIRequest("gpt-3.5-turbo", List.of(role, msg));
90+
String instruction = String.format("Translate the text below into %s while maintaining the original formatting and style. Keep translations concise and repeat the original text for unchanged translations (e.g. 'OK'). Text to translate: %s", toLang.getEnglishName(), text);
91+
92+
ChatGPTMessage msg = new ChatGPTMessage("user", instruction);
93+
94+
OpenAIRequest body = new OpenAIRequest("gpt-3.5-turbo", List.of(msg));
9295

9396
return GsonUtil.getInstance().getGson().toJson(body);
9497
}

0 commit comments

Comments
 (0)