openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Completion with gpt-3.5-turbo is currently not supported

Open kubecutle opened this issue 1 year ago • 5 comments

I get the following error when trying to use gpt-3.5-turbo model. Is there a plan to support this model?

`` com.theokanning.openai.OpenAiHttpException: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions? at com.theokanning.openai.service.OpenAiService.execute(OpenAiService.java:220)

``

kubecutle avatar Mar 14 '23 19:03 kubecutle

You should use createChatCompletion().

kim-up avatar Mar 15 '23 07:03 kim-up

You should use createChatCompletion().

Can send me example please

ahmedaa6122 avatar Mar 15 '23 11:03 ahmedaa6122

@HendSame can send me example please

ahmedaa6122 avatar Mar 15 '23 11:03 ahmedaa6122

It looks like this has not been pushed to maven repo yet.

kubecutle avatar Mar 15 '23 12:03 kubecutle

Maven repo is still at 0.11.0 while github is at 0.19.0 already. It would be very much appreciated if the latest could be published to maven central.

kubecutle avatar Mar 15 '23 12:03 kubecutle

@HendSame can send me example please

Refer to the API documentation: https://platform.openai.com/docs/api-reference/chat/create

Code example:

        String token = System.getenv("OPENAI_TOKEN");
        OpenAiService service = new OpenAiService(token);

        List<ChatMessage> chatMessageList = new ArrayList<>();
        ChatMessage chatMessage = new ChatMessage();
        chatMessage.setContent("Hello!");
        chatMessage.setRole("user");
        chatMessageList.add(chatMessage);

        ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
                                                                           .model("gpt-3.5-turbo")
                                                                           .messages(chatMessageList).build();
       service.createChatCompletion(chatCompletionRequest);

kim-up avatar Mar 16 '23 02:03 kim-up

It looks like this has not been pushed to maven repo yet.

Yes, current version(0.19.0) is required. You can package it by yourself.

kim-up avatar Mar 16 '23 02:03 kim-up

createChatCompletion should be supported in 0.11.0

I have a few changes going out in 0.11.1 but they're all minor

TheoKanning avatar Mar 16 '23 03:03 TheoKanning

Thanks. I did compile and it works great. I would be thrilled to see an example that uses streaming. Or some explanation of how to get the incremental content from openai server.

kubecutle avatar Mar 16 '23 03:03 kubecutle