private String buildQuery(){
OpenAiService service = new OpenAiService(openAIApiKey, Duration.ofSeconds(60));
List<ChatMessage> messages = new ArrayList<>();
ChatMessage systemMessage = new ChatMessage(ChatMessageRole.USER.value(), "test message in 10 words");
messages.add(systemMessage);
ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest
.builder()
.model(openAIModel)
.messages(messages)
.n(1)
.build();
ChatCompletionResult result = service.createChatCompletion(chatCompletionRequest);
service.shutdownExecutor();
return result.getChoices().get(0).getMessage().getContent();
}
The value this returns is:
"{\n\t\"message\": \"This is a test message with 10 words in it.\"\n}"
Why is it in JSON format? I try to change the prompt to something else, and it gave me better answers, but this one in particular gave JSON results even when not asked to. I also notice, surrounding a message with double quotes gave JSON results.
I have this code:
The value this returns is:
Why is it in JSON format? I try to change the prompt to something else, and it gave me better answers, but this one in particular gave JSON results even when not asked to. I also notice, surrounding a message with double quotes gave JSON results.