So i want to translate a specific prompt like 3 times and give different options for this, sometimes it seems to work and sometimes ChatGPT gives text after he should translate in the response aswell because he doesn’t understand the prompt all the time, how can i fix this is there any way to make it better?
The following code makes the basic prompt for what he should translate to which language
`public async Task<List> TranslateVariant(TranslateModel model)
{
_model = new TranslateModel()
{
Default = model.Default,
Variant = model.Variant,
Property = model.Property,
Id = model.Id
};
_textModel = new GenerateTextModel()
{
Prompt = $"Translate the following text from {_model.Default} to the language of the language code {_model.Variant} Only answer with the translation for that specific text nothing else. This is the text you should translate: {_model.Property} "
};
var choices = await _chatGPTService.CreateMultipleOptionsForTranslation(_textModel);
return choices;
}`
This code will give 3 options and add a prompt with the previous message as an option already given, but sometimes the response gives me the translation with “Make it different than the previous translation” after the translation.
`public async Task<List> CreateMultipleOptionsForTranslation(GenerateTextModel model)
{
var api = new OpenAIAPI(_settings.ApiKey);
var choices = new List<string>();
for (int i = 0; i < 3; i++)
{
var result = await api.Chat.CreateChatCompletionAsync(new ChatRequest()
{
Model = _model,
NumChoicesPerMessage = 1,
Temperature = 0.7,
MaxTokens = 2000,
PresencePenalty = 0.7,
Messages = new ChatMessage[]
{
new ChatMessage(ChatMessageRole.User, model.Prompt)
}
});
var choice = result.Choices[0].Message.Content.Trim();
bool isDuplicate = choices.Contains(choice);
if (!isDuplicate)
{
choices.Add(choice);
var optionNumber = choices.Count;
model.Prompt += $"{(optionNumber > 1 ? "and " : "")}Make it different than the previous translation {optionNumber}: {choice}";
}
}
return choices;
}`
How can i make this better anyone got any ideas?