0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-19 17:02:13 +02:00

Add a system message to improve completions from chat models

This commit is contained in:
Alexander01998 2024-05-14 14:17:27 +02:00
parent 447b30fdc7
commit 0c0e76b64d
2 changed files with 14 additions and 8 deletions

View File

@ -23,15 +23,15 @@ public final class ModelSettings
{
public final EnumSetting<OpenAiModel> openAiModel = new EnumSetting<>(
"OpenAI model",
"The model to use for OpenAI API calls.\n\n"
+ "\u00a7lGPT-3.5-Turbo-Instruct\u00a7r is an older, non-chat model"
+ " based on GPT-3.5 that works well for auto-completion tasks.\n\n"
"The model to use for OpenAI API calls.\nRecommended models:\n\n"
+ "\u00a7lGPT-4o-2024-05-13\u00a7r is the world's smartest model at"
+ " the time of writing, but it's optimized to be an assistant"
+ " rather than an auto-completion system. You will get some weird"
+ " results if you use it. Basically, it will reply to your"
+ " messages rather than completing them.",
OpenAiModel.values(), OpenAiModel.GPT_3_5_TURBO_INSTRUCT);
+ " the time of writing and will often produce the best completions."
+ " However, it's meant to be an assistant rather than an"
+ " auto-completion system, so you will see it produce some odd"
+ " completions at times.\n\n"
+ "\u00a7lGPT-3.5-Turbo-Instruct\u00a7r is an older, non-chat model"
+ " based on GPT-3.5 that works well for auto-completion tasks.",
OpenAiModel.values(), OpenAiModel.GPT_4O_2024_05_13);
public enum OpenAiModel
{

View File

@ -48,6 +48,12 @@ public final class OpenAiMessageCompleter extends MessageCompleter
if(modelSettings.openAiModel.getSelected().isChatModel())
{
JsonArray messages = new JsonArray();
JsonObject systemMessage = new JsonObject();
systemMessage.addProperty("role", "system");
systemMessage.addProperty("content",
"Complete the following text. Reply only with the completion."
+ " You are not an assistant.");
messages.add(systemMessage);
JsonObject promptMessage = new JsonObject();
promptMessage.addProperty("role", "user");
promptMessage.addProperty("content", prompt);