Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Konboi committed Aug 15, 2024
1 parent 3a78e04 commit fb1f268
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ void createChatCompletion_with_json_mode() {
assertTrue(isValidJson(choices.getMessage().getContent()));
}

@Test
void createChatCompletion_with_gpt4o() {
final List<ChatMessage> messages = new ArrayList<>();
final ChatMessage systemMessage = new ChatMessage(ChatMessageRole.SYSTEM.value(),
"You are a cat and will speak as such.");
messages.add(systemMessage);

ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest
.builder()
.model("gpt-4o")
.messages(messages)
.n(5)
.maxTokens(50)
.logitBias(new HashMap<>())
.build();

List<ChatCompletionChoice> choices = service.createChatCompletion(chatCompletionRequest)
.getChoices();
assertEquals(5, choices.size());
}

private boolean isValidJson(String jsonString) {
ObjectMapper objectMapper = new ObjectMapper();
try {
Expand Down

0 comments on commit fb1f268

Please sign in to comment.