namankhurpia / Easy-open-ai

This repository contains the community-maintained library for OpenAI's API in java, the easiest way to use GPT 3/4 in your applications.
http://namank.xyz
MIT License
15 stars 3 forks source link

getAsync* methods are actually synchronous #31

Open mircea-cm opened 5 months ago

mircea-cm commented 5 months ago

All getAsync methods are actually synchronous.

For example, getAsyncChatCompletion (in AsyncDAOImpl) returns a POJO object: ChatCompletionResponse, and it should return a Future.

You create a CompletableFuture (all well for now), but the method ends in

return (ChatCompletionResponse)future.get();

Basically, it blocks the current thread until the future completes.

For the methods to be actually async they need to return Call<> or Future

namankhurpia commented 5 months ago

@mircea-cm you are absolutely right, making a PR for this right now, should be fixed easily