Lambdua / openai4j

Java client library for OpenAI API.Full support for all OpenAI API models including Completions, Chat, Edits, Embeddings, Audio, Files, Assistants-v2, Images, Moderations, Batch, and Fine-tuning.
MIT License
322 stars 27 forks source link

Unsupported value: 'messages[0].role' does not support 'system' with this model. #62

Closed 1050TIt0p closed 1 month ago

1050TIt0p commented 1 month ago

Returns an error when using the o1-mini model, no such error with 4o-mini

https://pastebin.com/VgZyjjF6

Lambdua commented 1 month ago

https://platform.openai.com/docs/guides/reasoning Currently, o1 does not support the use of system messages. You can refer to the following usage example


    void  o1ModelTest(){
        ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
                .model("o1-mini")
                .messages(Arrays.asList(new UserMessage("9.11和9.8比较,那个大")))
                .build();
        ChatCompletionResult chatCompletion = service.createChatCompletion(chatCompletionRequest);
        assertNotNull(chatCompletion);
        assertNotNull(chatCompletion.getChoices());
        ChatCompletionChoice choice = chatCompletion.getChoices().get(0);
        assertNotNull(choice);
        assertNotNull(choice.getMessage());
        assertNotNull(choice.getMessage().getContent());
    }